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"]
docstr: See :func:`EncoderBase.forward()`
docstr_tok: ["See",":","func",":","`","EncoderBase.forward","(",")","`"]
code: def forward(self, src, src_len=None):
      """See :func:`EncoderBase.forward()`"""
  
      emb = self.embeddings(src)
  
      packed_emb = emb
      if src_len is not None and not self.no_pack_padded_seq:
          # src lengths data is wrapped inside a Tensor.
          src_len_list = src_len.view(-1).tolist()
          packed_emb = pack(
              emb, src_len_list, batch_first=True, enforce_sorted=False
          )
  
      enc_out, enc_final_hs = self.rnn(packed_emb)
  
      if src_len is not None and not self.no_pack_padded_seq:
          enc_out = unpack(enc_out, batch_first=True)[0]
  
      if self.use_bridge:
          enc_final_hs = self._bridge(enc_final_hs)
  
      return enc_out, enc_final_hs, src_len
  
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 3 for calling the RNNEncoder obj's underlying member method code with example usage: obj.forward(src, src_len) and returns: enc_out,  enc_final_hs,  src_len