class_docstr: A gated graph neural network configured as an encoder.
     Based on github.com/JamesChuanggg/ggnn.pytorch.git,
     which is based on the paper "Gated Graph Sequence Neural Networks"
     by Y. Li, D. Tarlow, M. Brockschmidt, and R. Zemel.
  
  Args:
     rnn_type (str):
        style of recurrent unit to use, one of [LSTM]
     src_ggnn_size (int) : Size of token-to-node embedding input
     src_word_vec_size (int) : Size of token-to-node embedding output
     state_dim (int) : Number of state dimensions in nodes
     n_edge_types (int) : Number of edge types
     bidir_edges (bool): True if reverse edges should be autocreated
     n_node (int) : Max nodes in graph
     bridge_extra_node (bool): True indicates only 1st extra node
        (after token listing) should be used for decoder init.
     n_steps (int): Steps to advance graph encoder for stabilization
     src_vocab (int): Path to source vocabulary.(The ggnn uses src_vocab
          during training because the graph is built using edge information
          which requires parsing the input sequence.)
class_docstr_tok: ["A","gated","graph","neural","network","configured","as","an","encoder",".","Based","on","github.com\/JamesChuanggg\/ggnn.pytorch.git",",","which","is","based","on","the","paper","``","Gated","Graph","Sequence","Neural","Networks","''","by","Y.","Li",",","D.","Tarlow",",","M.","Brockschmidt",",","and","R.","Zemel",".","Args",":","rnn_type","(","str",")",":","style","of","recurrent","unit","to","use",",","one","of","[","LSTM","]","src_ggnn_size","(","int",")",":","Size","of","token-to-node","embedding","input","src_word_vec_size","(","int",")",":","Size","of","token-to-node","embedding","output","state_dim","(","int",")",":","Number","of","state","dimensions","in","nodes","n_edge_types","(","int",")",":","Number","of","edge","types","bidir_edges","(","bool",")",":","True","if","reverse","edges","should","be","autocreated","n_node","(","int",")",":","Max","nodes","in","graph","bridge_extra_node","(","bool",")",":","True","indicates","only","1st","extra","node","(","after","token","listing",")","should","be","used","for","decoder","init",".","n_steps","(","int",")",":","Steps","to","advance","graph","encoder","for","stabilization","src_vocab","(","int",")",":","Path","to","source","vocabulary",".","(","The","ggnn","uses","src_vocab","during","training","because","the","graph","is","built","using","edge","information","which","requires","parsing","the","input","sequence",".",")"]
docstr: Forward hidden state through bridge.
docstr_tok: ["Forward","hidden","state","through","bridge","."]
code: def _bridge(self, hidden):
      """Forward hidden state through bridge."""
  
      def bottle_hidden(linear, states):
          """
          Transform from 3D to 2D, apply linear and return initial size
          """
          size = states.size()
          result = linear(states.view(-1, self.total_hidden_dim))
          return F.leaky_relu(result).view(size)
  
      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
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from onmt.encoders.encoder import EncoderBase
label_desc: Use image node_id 6 for calling the GGNNEncoder obj's underlying member method code with example usage: obj._bridge(hidden) and returns: outs, F