class_docstr: A generic recurrent neural network encoder.
  
  Args:
     rnn_type (str):
        style of recurrent unit to use, one of [RNN, LSTM, GRU, SRU]
     bidirectional (bool) : use a bidirectional RNN
     num_layers (int) : number of stacked layers
     hidden_size (int) : hidden size of each layer
     dropout (float) : dropout value for :class:`torch.nn.Dropout`
     embeddings (onmt.modules.Embeddings): embedding module to use
class_docstr_tok: ["A","generic","recurrent","neural","network","encoder",".","Args",":","rnn_type","(","str",")",":","style","of","recurrent","unit","to","use",",","one","of","[","RNN",",","LSTM",",","GRU",",","SRU","]","bidirectional","(","bool",")",":","use","a","bidirectional","RNN","num_layers","(","int",")",":","number","of","stacked","layers","hidden_size","(","int",")",":","hidden","size","of","each","layer","dropout","(","float",")",":","dropout","value","for",":","class",":","`","torch.nn.Dropout","`","embeddings","(","onmt.modules.Embeddings",")",":","embedding","module","to","use"]
code: def __init__(
      self,
      rnn_type,
      bidirectional,
      num_layers,
      hidden_size,
      dropout=0.0,
      embeddings=None,
      use_bridge=False,
  ):
      super(RNNEncoder, self).__init__()
      assert embeddings is not None
  
      num_directions = 2 if bidirectional else 1
      assert hidden_size % num_directions == 0
      hidden_size = hidden_size // num_directions
      self.embeddings = embeddings
  
      self.rnn, self.no_pack_padded_seq = rnn_factory(
          rnn_type,
          input_size=embeddings.embedding_size,
          hidden_size=hidden_size,
          num_layers=num_layers,
          dropout=dropout,
          bidirectional=bidirectional,
      )
  
      # Initialize the bridge layer
      self.use_bridge = use_bridge
      if self.use_bridge:
          self._initialize_bridge(rnn_type, hidden_size, num_layers)
  
file_path: OpenNMT-py/onmt/encoders/rnn_encoder.py
imports: import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import pack_padded_sequence
  from torch.nn.utils.rnn import pad_packed_sequence
  from onmt.encoders.encoder import EncoderBase
  from onmt.utils.rnn_factory import rnn_factory
label_desc: Use image node_id 1 to create a new RNNEncoder object from inherited base classes: EncoderBase with example: obj = RNNEncoder(rnn_type, bidirectional, num_layers, hidden_size, dropout, embeddings, use_bridge)