class_docstr: Recurrent network.
class_docstr_tok: ["Recurrent","network","."]
docstr: Apply the network.
  
  Args:
    observation: A tuple of tensors matching `input_tensor_spec`.
    step_type: A tensor of `StepType.
    network_state: (optional.) The network state.
    training: Whether the output is being used for training.
  
  Returns:
    `(outputs, network_state)` - the network output and next network state.
  
  Raises:
    ValueError: If observation tensors lack outer `(batch,)` or
      `(batch, time)` axes.
docstr_tok: ["Apply","the","network",".","Args",":","observation",":","A","tuple","of","tensors","matching","`","input_tensor_spec","`",".","step_type",":","A","tensor","of","`","StepType",".","network_state",":","(","optional",".",")","The","network","state",".","training",":","Whether","the","output","is","being","used","for","training",".","Returns",":","`","(","outputs",",","network_state",")","`","-","the","network","output","and","next","network","state",".","Raises",":","ValueError",":","If","observation","tensors","lack","outer","`","(","batch",",",")","`","or","`","(","batch",",","time",")","`","axes","."]
code: def call(
      self, observation, step_type, network_state=(), training=False
  ):
      """Apply the network.
  
      Args:
        observation: A tuple of tensors matching `input_tensor_spec`.
        step_type: A tensor of `StepType.
        network_state: (optional.) The network state.
        training: Whether the output is being used for training.
  
      Returns:
        `(outputs, network_state)` - the network output and next network state.
  
      Raises:
        ValueError: If observation tensors lack outer `(batch,)` or
          `(batch, time)` axes.
      """
      num_outer_dims = nest_utils.get_outer_rank(
          observation, self.input_tensor_spec
      )
      if num_outer_dims not in (1, 2):
          raise ValueError(
              "Input observation must have a batch or batch x time outer shape."
          )
  
      has_time_dim = num_outer_dims == 2
      if not has_time_dim:
          # Add a time dimension to the inputs.
          observation = tf.nest.map_structure(
              lambda t: tf.expand_dims(t, 1), observation
          )
          step_type = tf.nest.map_structure(
              lambda t: tf.expand_dims(t, 1), step_type
          )
  
      state, _ = self._input_encoder(
          observation,
          step_type=step_type,
          network_state=(),
          training=training,
      )
  
      network_kwargs = {}
      if isinstance(
          self._lstm_network, dynamic_unroll_layer.DynamicUnroll
      ):
          network_kwargs["reset_mask"] = tf.equal(
              step_type, time_step.StepType.FIRST, name="mask"
          )
  
      # Unroll over the time sequence.
      output = self._lstm_network(
          inputs=state,
          initial_state=network_state,
          training=training,
          **network_kwargs,
      )
  
      if isinstance(
          self._lstm_network, dynamic_unroll_layer.DynamicUnroll
      ):
          state, network_state = output
      else:
          state = output[0]
          network_state = tf.nest.pack_sequence_as(
              self._lstm_network.cell.state_size,
              tf.nest.flatten(output[1:]),
          )
  
      for layer in self._output_encoder:
          state = layer(state, training=training)
  
      if not has_time_dim:
          # Remove time dimension from the state.
          state = tf.squeeze(state, [1])
  
      return state, network_state
  
file_path: agents/tf_agents/networks/lstm_encoding_network.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gin
  import tensorflow
  from tf_agents.keras_layers import dynamic_unroll_layer
  from tf_agents.networks import encoding_network
  from tf_agents.networks import network
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 2 for calling the LSTMEncodingNetwork obj's underlying member method code with example usage: obj.call(observation, step_type, network_state, training) and returns: state,  network_state