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: Forward hidden state through bridge.
  final hidden state ``(num_layers x dir, batch, hidden_size)``
docstr_tok: ["Forward","hidden","state","through","bridge",".","final","hidden","state","``","(","num_layers","x","dir",",","batch",",","hidden_size",")","``"]
code: def _bridge(self, hidden):
      """Forward hidden state through bridge.
      final hidden state ``(num_layers x dir, batch, hidden_size)``
      """
  
      def bottle_hidden(linear, states):
          """
          Transform from 3D to 2D, apply linear and return initial size
          """
          states = states.permute(1, 0, 2).contiguous()
          size = states.size()
          result = linear(states.view(-1, self.total_hidden_dim))
          result = F.relu(result).view(size)
          return result.permute(1, 0, 2).contiguous()
  
      if isinstance(hidden, tuple):  # LSTM
          outs = tuple(
              [
                  bottle_hidden(layer, hidden[ix])
                  for ix, layer in enumerate(self.bridge)
              ]
          )
      else:
          outs = bottle_hidden(self.bridge[0], hidden)
      return outs
  
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 5 for calling the RNNEncoder obj's underlying member method code with example usage: obj._bridge(hidden) and returns: outs, result