title: Rewrite Lambda function to custom keras layer
body: <p>to use LSTM in TfLite I would need to rewrite Lambda layer to a tf keras custom Layer object so that it can hold weights (because Lambda layer cannot do that). I am not quite sure how to that with the example here. Could anyone lend me a helping hand and show me how to rewrite correctly into a <a href="https://www.tensorflow.org/guide/keras/custom_layers_and_models" rel="nofollow noreferrer">custom layer</a>?</p>
  
  <pre><code>def buildLstmLayer(inputs):
  
    lstm_cells = []
  
    lstm_cells.append(TFLiteLSTMCell(256, forget_bias=0, name='rnn0'))
    lstm_cells.append(TFLiteLSTMCell(128, forget_bias=0, name='rnn1'))
    lstm_layers = tf.keras.layers.StackedRNNCells(lstm_cells)
  
    outputs, _ = dynamic_rnn(
        lstm_layers,
        inputs,
        dtype='float32',
        time_major=True)
  
    return outputs
  </code></pre>