class_docstr:     The graph2seq model consists the following components: 1) node embedding 2) graph embedding 3) decoding. # noqa
      Since the full pipeline will consist all parameters, so we will add prefix to the original parameters
       in each component as follows (except the listed four parameters):
          1) emb_ + parameter_name (eg: ``emb_input_size``)
          2) gnn_ + parameter_name (eg: ``gnn_direction_option``)
          3) dec_ + parameter_name (eg: ``dec_max_decoder_step``)
      Considering neatness, we will only present the four hyper-parameters which don't meet regulations.
      Examples
      -------
      # Build a vocab model from scratch
      >>> "It is just a how-to-use example."
      >>> from graph4nlp.pytorch.modules.config import get_basic_args
      >>> opt = get_basic_args(graph_construction_name="node_emb", graph_embedding_name="gat", decoder_name="stdrnn")
      >>> graph2seq = Graph2Seq.from_args(opt=opt, vocab_model=vocab_model, device=torch.device("cuda:0"))
      >>> batch_graph = [GraphData() for _ in range(2)]
      >>> tgt_seq = torch.Tensor([[1, 2, 3], [4, 5, 6]])
      >>> seq_out, _, _ = graph2seq(batch_graph=batch_graph, tgt_seq=tgt_seq)
      >>> print(seq_out.shape) # [2, 6, 5] (assume the vocabulary size is 5 and max_decoder_step is 6)
  Parameters
  ----------
  vocab_model: VocabModel
      The vocabulary.
  graph_name: str
      The graph type. Excepted in ["dependency", "constituency", "node_emb", "node_emb_refined"].
  gnn: str
      The graph neural network's name. Expected in ["gcn", "gat", "graphsage", "ggnn"]
class_docstr_tok: ["The","graph2seq","model","consists","the","following","components",":","1",")","node","embedding","2",")","graph","embedding","3",")","decoding",".","#","noqa","Since","the","full","pipeline","will","consist","all","parameters",",","so","we","will","add","prefix","to","the","original","parameters","in","each","component","as","follows","(","except","the","listed","four","parameters",")",":","1",")","emb_","+","parameter_name","(","eg",":","``","emb_input_size","``",")","2",")","gnn_","+","parameter_name","(","eg",":","``","gnn_direction_option","``",")","3",")","dec_","+","parameter_name","(","eg",":","``","dec_max_decoder_step","``",")","Considering","neatness",",","we","will","only","present","the","four","hyper-parameters","which","do","n't","meet","regulations",".","Examples","--","--","--","-","#","Build","a","vocab","model","from","scratch",">",">",">","``","It","is","just","a","how-to-use","example",".","''",">",">",">","from","graph4nlp.pytorch.modules.config","import","get_basic_args",">",">",">","opt","=","get_basic_args","(","graph_construction_name=","''","node_emb","''",",","graph_embedding_name=","''","gat","''",",","decoder_name=","''","stdrnn","''",")",">",">",">","graph2seq","=","Graph2Seq.from_args","(","opt=opt",",","vocab_model=vocab_model",",","device=torch.device","(","``","cuda:0","''",")",")",">",">",">","batch_graph","=","[","GraphData","(",")","for","_","in","range","(","2",")","]",">",">",">","tgt_seq","=","torch.Tensor","(","[","[","1",",","2",",","3","]",",","[","4",",","5",",","6","]","]",")",">",">",">","seq_out",",","_",",","_","=","graph2seq","(","batch_graph=batch_graph",",","tgt_seq=tgt_seq",")",">",">",">","print","(","seq_out.shape",")","#","[","2",",","6",",","5","]","(","assume","the","vocabulary","size","is","5","and","max_decoder_step","is","6",")","Parameters","--","--","--","--","--","vocab_model",":","VocabModel","The","vocabulary",".","graph_name",":","str","The","graph","type",".","Excepted","in","[","``","dependency","''",",","``","constituency","''",",","``","node_emb","''",",","``","node_emb_refined","''","]",".","gnn",":","str","The","graph","neural","network","'s","name",".","Expected","in","[","``","gcn","''",",","``","gat","''",",","``","graphsage","''",",","``","ggnn","''","]"]
docstr:     Decoding with the support of beam_search.
      Specifically, when ``beam_size`` is 1, it is equal to greedy search.
  Parameters
  ----------
  batch_graph: GraphData
      The graph input
  beam_size: int
      The beam width. When it is 1, the output is equal to greedy search's output.
  topk: int, default=1
      The number of decoded sequence to be reserved.
      Usually, ``topk`` should be smaller or equal to ``beam_size``
  oov_dict: VocabModel, default=None
      The vocabulary for copy.
  
  Returns
  -------
  results: torch.Tensor
      The results with the shape of ``[batch_size, topk, max_decoder_step]`` containing the word indexes. # noqa
docstr_tok: ["Decoding","with","the","support","of","beam_search",".","Specifically",",","when","``","beam_size","``","is","1",",","it","is","equal","to","greedy","search",".","Parameters","--","--","--","--","--","batch_graph",":","GraphData","The","graph","input","beam_size",":","int","The","beam","width",".","When","it","is","1",",","the","output","is","equal","to","greedy","search","'s","output",".","topk",":","int",",","default=1","The","number","of","decoded","sequence","to","be","reserved",".","Usually",",","``","topk","``","should","be","smaller","or","equal","to","``","beam_size","``","oov_dict",":","VocabModel",",","default=None","The","vocabulary","for","copy",".","Returns","--","--","--","-","results",":","torch.Tensor","The","results","with","the","shape","of","``","[","batch_size",",","topk",",","max_decoder_step","]","``","containing","the","word","indexes",".","#","noqa"]
code: def translate(self, batch_graph, beam_size, topk=1, oov_dict=None):
      """
          Decoding with the support of beam_search.
          Specifically, when ``beam_size`` is 1, it is equal to greedy search.
      Parameters
      ----------
      batch_graph: GraphData
          The graph input
      beam_size: int
          The beam width. When it is 1, the output is equal to greedy search's output.
      topk: int, default=1
          The number of decoded sequence to be reserved.
          Usually, ``topk`` should be smaller or equal to ``beam_size``
      oov_dict: VocabModel, default=None
          The vocabulary for copy.
  
      Returns
      -------
      results: torch.Tensor
          The results with the shape of ``[batch_size, topk, max_decoder_step]`` containing the word indexes. # noqa
      """
  
      batch_graph = self.graph_initializer(batch_graph)
      if hasattr(self, "graph_topology") and hasattr(
          self.graph_topology, "dynamic_topology"
      ):
          batch_graph = self.graph_topology.dynamic_topology(
              batch_graph
          )
  
      return self.encoder_decoder_beam_search(
          batch_graph=batch_graph,
          beam_size=beam_size,
          topk=topk,
          oov_dict=oov_dict,
      )
  
imports: import copy
  import torch.nn.functional
  from graph4nlp.pytorch.modules.graph_embedding_initialization.embedding_construction import WordEmbedding
  from graph4nlp.pytorch.modules.prediction.generation.decoder_strategy import DecoderStrategy
  from graph4nlp.pytorch.modules.prediction.generation.StdRNNDecoder import StdRNNDecoder
  from graph4nlp.pytorch.modules.utils.generic_utils import wordid2str
  from .base import Graph2XBase
label_desc: Use image node_id 6 for calling the Graph2Seq obj's underlying member method code with example usage: obj.translate(batch_graph, beam_size, topk, oov_dict) and returns: self