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: Alternate constructor.
docstr_tok: ["Alternate","constructor","."]
code: def from_opt(cls, opt, embeddings):
      """Alternate constructor."""
      return cls(
          opt.rnn_type,
          opt.src_word_vec_size,
          opt.src_ggnn_size,
          opt.state_dim,
          opt.bidir_edges,
          opt.n_edge_types,
          opt.n_node,
          opt.bridge_extra_node,
          opt.n_steps,
          opt.src_vocab,
      )
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from onmt.encoders.encoder import EncoderBase
label_desc: Use image node_id 2 for calling the GGNNEncoder obj's underlying member method code with example usage: obj.from_opt(cls, opt, embeddings) and returns: cls