class_docstr: A recurrent GRU encoder.
  
  This encoder has...
  - Zero or one tokenizers.
  - One or more GRU layers.
  - One linear output layer.
code: def _forward(self, inputs: dict, **kwargs) -> dict:
      outputs = {}
  
      if self.tokenizer is not None:
          # Push observations through the tokenizer encoder if we built one.
          out = tokenize(self.tokenizer, inputs, framework="torch")
      else:
          # Otherwise, just use the raw observations.
          out = inputs[SampleBatch.OBS].float()
  
      # States are batch-first when coming in. Make them layers-first.
      states_in = tree.map_structure(
          lambda s: s.transpose(0, 1), inputs[STATE_IN]
      )
  
      out, states_out = self.gru(out, states_in["h"])
      states_out = {"h": states_out}
  
      # Insert them into the output dict.
      outputs[ENCODER_OUT] = out
      outputs[STATE_OUT] = tree.map_structure(
          lambda s: s.transpose(0, 1), states_out
      )
      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
  from ray.rllib.core.models.base import Model, tokenize
  from ray.rllib.core.models.configs import ActorCriticEncoderConfig, CNNEncoderConfig, MLPEncoderConfig, RecurrentEncoderConfig
  from ray.rllib.core.models.specs.specs_base import Spec
  from ray.rllib.core.models.specs.specs_base import TensorSpec
  from ray.rllib.core.models.specs.specs_dict import SpecDict
  from ray.rllib.core.models.torch.base import TorchModel
  from ray.rllib.core.models.torch.primitives import TorchMLP, TorchCNN
  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_torch
label_desc: Use image node_id 5 for calling the TorchGRUEncoder obj's underlying member method code with example usage: obj._forward(inputs) and returns: outputs