class_docstr: A recurrent LSTM encoder.
  
  This encoder has...
  - Zero or one tokenizers.
  - One or more LSTM layers.
  - One linear output layer.
code: def _forward(self, inputs: NestedDict, **kwargs) -> NestedDict:
      outputs = {}
  
      if self.tokenizer is not None:
          # Push observations through the tokenizer encoder if we built one.
          out = tokenize(self.tokenizer, inputs, framework="tf2")
      else:
          # Otherwise, just use the raw observations.
          out = tf.cast(inputs[SampleBatch.OBS], tf.float32)
  
      # States are batch-first when coming in. Make them layers-first.
      states_in = tree.map_structure(
          lambda s: tf.transpose(s, perm=[1, 0, 2]),
          inputs[STATE_IN],
      )
  
      states_out_h = []
      states_out_c = []
      for i, layer in enumerate(self.lstms):
          out, h, c = layer(out, (states_in["h"][i], states_in["c"][i]))
          states_out_h.append(h)
          states_out_c.append(c)
  
      # Insert them into the output dict.
      outputs[ENCODER_OUT] = out
      outputs[STATE_OUT] = {
          "h": tf.stack(states_out_h, 1),
          "c": tf.stack(states_out_c, 1),
      }
      return outputs
  
imports: from typing import Optional
  import tree
  from ray.rllib.core.models.base import Encoder, ActorCriticEncoder, StatefulActorCriticEncoder, STATE_IN, STATE_OUT, ENCODER_OUT, tokenize
  from ray.rllib.core.models.base import Model
  from ray.rllib.core.models.configs import ActorCriticEncoderConfig, CNNEncoderConfig, MLPEncoderConfig, RecurrentEncoderConfig
  from ray.rllib.core.models.tf.base import TfModel
  from ray.rllib.core.models.tf.primitives import TfMLP, TfCNN
  from ray.rllib.core.models.specs.specs_base import Spec
  from ray.rllib.core.models.specs.specs_dict import SpecDict
  from ray.rllib.core.models.specs.specs_base import TensorSpec
  from ray.rllib.models.utils import get_initializer_fn
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.nested_dict import NestedDict
label_desc: Use image node_id 5 for calling the TfLSTMEncoder obj's underlying member method code with example usage: obj._forward(inputs) and returns: outputs