class_docstr: Configuration for an LSTM-based or a GRU-based encoder.
  
  The encoder consists of...
  - Zero or one tokenizers
  - N LSTM/GRU layers stacked on top of each other and feeding
  their outputs as inputs to the respective next layer.
  - One linear output layer
  
  This makes for the following flow of tensors:
  
  Inputs
  |
  [Tokenizer if present]
  |
  LSTM layer 1
  |
  (...)
  |
  LSTM layer n
  |
  Linear output layer
  |
  Outputs
  
  The internal state is structued as (num_layers, B, hidden-size) for all hidden
  state components, e.g.
  h- and c-states of the LSTM layer(s) or h-state of the GRU layer(s).
  For example, the hidden states of an LSTMEncoder with num_layers=2 and hidden_dim=8
  would be: {"h": (2, B, 8), "c": (2, B, 8)}.
  
  `output_dims` is reached by the last recurrent layer's dimension, which is always
  the `hidden_dims` value.
  
  Example:
  .. testcode::
  
      # Configuration:
      config = RecurrentEncoderConfig(
          recurrent_layer_type="lstm",
          input_dims=[16],  # must be 1D tensor
          hidden_dim=128,
          num_layers=2,
          use_bias=True,
      )
      model = config.build(framework="torch")
  
      # Resulting stack in pseudocode:
      # LSTM(16, 128, bias=True)
      # LSTM(128, 128, bias=True)
  
      # Resulting shape of the internal states (c- and h-states):
      # (2, B, 128) for each c- and h-states.
  
  Example:
  .. testcode::
  
      # Configuration:
      config = RecurrentEncoderConfig(
          recurrent_layer_type="gru",
          input_dims=[32],  # must be 1D tensor
          hidden_dim=64,
          num_layers=1,
          use_bias=False,
      )
      model = config.build(framework="torch")
  
      # Resulting stack in pseudocode:
      # GRU(32, 64, bias=False)
  
      # Resulting shape of the internal state:
      # (1, B, 64)
  
  Attributes:
      input_dims: The input dimensions. Must be 1D. This is the 1D shape of the tensor
          that goes into the first recurrent layer.
      recurrent_layer_type: The type of the recurrent layer(s).
          Either "lstm" or "gru".
      hidden_dim: The size of the hidden internal state(s) of the recurrent layer(s).
          For example, for an LSTM, this would be the size of the c- and h-tensors.
      num_layers: The number of recurrent (LSTM or GRU) layers to stack.
      batch_major: Wether the input is batch major (B, T, ..) or
          time major (T, B, ..).
      hidden_weights_initializer: The initializer function or class to use for
          kernel initialization in the hidden layers. If `None` the default
          initializer of the respective recurrent layer of a framework (`"torch"` or
          `"tf2"`) is used. Note, all initializers defined in the frameworks (
          `"torch"` or `"tf2`) are allowed. For `"torch"` only the in-place
          initializers, i.e. ending with an underscore "_" are allowed.
      hidden_weights_initializer_config: Configuration to pass into the
          initializer defined in `hidden_weights_initializer`.
      use_bias: Whether to use bias on the recurrent layers in the network.
      hidden_bias_initializer: The initializer function or class to use for bias
          initialization in the hidden layers. If `None` the default initializer of
          the respective recurrent layer of a framework (`"torch"` or `"tf2"`) is
          used. For `"torch"` only the in-place initializers, i.e. ending with an
          underscore "_" are allowed.
      hidden_bias_initializer_config: Configuration to pass into the initializer
          defined in `hidden_bias_initializer`.
      view_requirements_dict: The view requirements to use if anything else than
          observation_space or action_space is to be encoded. This signifies an
          advanced use case.
      tokenizer_config: A ModelConfig to build tokenizers for observations,
          actions and other spaces that might be present in the
          view_requirements_dict.
class_docstr_tok: ["Configuration","for","an","LSTM-based","or","a","GRU-based","encoder",".","The","encoder","consists","of","...","-","Zero","or","one","tokenizers","-","N","LSTM\/GRU","layers","stacked","on","top","of","each","other","and","feeding","their","outputs","as","inputs","to","the","respective","next","layer",".","-","One","linear","output","layer","This","makes","for","the","following","flow","of","tensors",":","Inputs","|","[","Tokenizer","if","present","]","|","LSTM","layer","1","|","(","...",")","|","LSTM","layer","n","|","Linear","output","layer","|","Outputs","The","internal","state","is","structued","as","(","num_layers",",","B",",","hidden-size",")","for","all","hidden","state","components",",","e.g",".","h-","and","c-states","of","the","LSTM","layer","(","s",")","or","h-state","of","the","GRU","layer","(","s",")",".","For","example",",","the","hidden","states","of","an","LSTMEncoder","with","num_layers=2","and","hidden_dim=8","would","be",":","{","``","h","''",":","(","2",",","B",",","8",")",",","``","c","''",":","(","2",",","B",",","8",")","}",".","`","output_dims","`","is","reached","by","the","last","recurrent","layer","'s","dimension",",","which","is","always","the","`","hidden_dims","`","value",".","Example",":","..","testcode",":",":","#","Configuration",":","config","=","RecurrentEncoderConfig","(","recurrent_layer_type=","''","lstm","''",",","input_dims=","[","16","]",",","#","must","be","1D","tensor","hidden_dim=128",",","num_layers=2",",","use_bias=True",",",")","model","=","config.build","(","framework=","''","torch","''",")","#","Resulting","stack","in","pseudocode",":","#","LSTM","(","16",",","128",",","bias=True",")","#","LSTM","(","128",",","128",",","bias=True",")","#","Resulting","shape","of","the","internal","states","(","c-","and","h-states",")",":","#","(","2",",","B",",","128",")","for","each","c-","and","h-states",".","Example",":","..","testcode",":",":","#","Configuration",":","config","=","RecurrentEncoderConfig","(","recurrent_layer_type=","''","gru","''",",","input_dims=","[","32","]",",","#","must","be","1D","tensor","hidden_dim=64",",","num_layers=1",",","use_bias=False",",",")","model","=","config.build","(","framework=","''","torch","''",")","#","Resulting","stack","in","pseudocode",":","#","GRU","(","32",",","64",",","bias=False",")","#","Resulting","shape","of","the","internal","state",":","#","(","1",",","B",",","64",")","Attributes",":","input_dims",":","The","input","dimensions",".","Must","be","1D",".","This","is","the","1D","shape","of","the","tensor","that","goes","into","the","first","recurrent","layer",".","recurrent_layer_type",":","The","type","of","the","recurrent","layer","(","s",")",".","Either","``","lstm","''","or","``","gru","''",".","hidden_dim",":","The","size","of","the","hidden","internal","state","(","s",")","of","the","recurrent","layer","(","s",")",".","For","example",",","for","an","LSTM",",","this","would","be","the","size","of","the","c-","and","h-tensors",".","num_layers",":","The","number","of","recurrent","(","LSTM","or","GRU",")","layers","to","stack",".","batch_major",":","Wether","the","input","is","batch","major","(","B",",","T",",","..",")","or","time","major","(","T",",","B",",","..",")",".","hidden_weights_initializer",":","The","initializer","function","or","class","to","use","for","kernel","initialization","in","the","hidden","layers",".","If","`","None","`","the","default","initializer","of","the","respective","recurrent","layer","of","a","framework","(","`","``","torch","''","`","or","`","``","tf2","''","`",")","is","used",".","Note",",","all","initializers","defined","in","the","frameworks","(","`","``","torch","''","`","or","`","``","tf2","`",")","are","allowed",".","For","`","``","torch","''","`","only","the","in-place","initializers",",","i.e",".","ending","with","an","underscore","``","_","''","are","allowed",".","hidden_weights_initializer_config",":","Configuration","to","pass","into","the","initializer","defined","in","`","hidden_weights_initializer","`",".","use_bias",":","Whether","to","use","bias","on","the","recurrent","layers","in","the","network",".","hidden_bias_initializer",":","The","initializer","function","or","class","to","use","for","bias","initialization","in","the","hidden","layers",".","If","`","None","`","the","default","initializer","of","the","respective","recurrent","layer","of","a","framework","(","`","``","torch","''","`","or","`","``","tf2","''","`",")","is","used",".","For","`","``","torch","''","`","only","the","in-place","initializers",",","i.e",".","ending","with","an","underscore","``","_","''","are","allowed",".","hidden_bias_initializer_config",":","Configuration","to","pass","into","the","initializer","defined","in","`","hidden_bias_initializer","`",".","view_requirements_dict",":","The","view","requirements","to","use","if","anything","else","than","observation_space","or","action_space","is","to","be","encoded",".","This","signifies","an","advanced","use","case",".","tokenizer_config",":","A","ModelConfig","to","build","tokenizers","for","observations",",","actions","and","other","spaces","that","might","be","present","in","the","view_requirements_dict","."]
code: def output_dims(self):
      return (self.hidden_dim,)
  
imports: import abc
  from dataclasses import dataclass, field
  import functools
  from typing import Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from ray.rllib.models.torch.misc import same_padding, same_padding_transpose_after_stride, valid_padding
  from ray.rllib.models.utils import get_activation_fn, get_initializer_fn
  from ray.rllib.utils.annotations import ExperimentalAPI
label_desc: Use image node_id 1 for calling the RecurrentEncoderConfig obj's underlying member method code with example usage: obj.output_dims() and returns: self