In keras/tensorflow, I have a custom layer whose definition looks schematically like this:
class SlowLayer(keras.la