class_docstr: StdTreeDecoder: This is a tree decoder implementation, which is used for tree object decoding.
  
  Attributes
  ----------
  attn_type : str,
      Describe which attention mechanism is used, can be ``uniform``,
      ``separate_on_encoder_type``, ``separate_on_node_type``.
  
  embeddings : torch.nn.Module,
      Embedding layer, input is tensor of word index, output is word embedding tensor.
  
  enc_hidden_size : int,
      Size of encoder hidden state.
  
  dec_emb_size : int,
      Size of decoder word embedding layer output size.
  
  dec_hidden_size : int,
      Size of decoder hidden state. (namely the ``lstm`` or ``gru``
      hidden size when rnn unit has been specified)
  
  output_size : int,
      Size of output vocabulary size.
  
  teacher_force_ratio : float,
      The ratio of possibility to use teacher force training.
  
  use_sibling : boolean,
      Whether feed sibling state in each decoding step.
  
  use_copy : boolean,
      Whether use copy mechanism in decoding.
  
  fuse_strategy: str, option=[None, "average", "concatenate"], default=None
      The strategy to fuse attention results generated by separate attention.
      "None": If we do ``uniform`` attention, we will set it to None.
      "``average``": We will take an average on all results.
      "``concatenate``": We will concatenate all results to one.
  
  num_layers : int, optional,
      Layer number of decoder rnn unit.
  
  dropout_for_decoder: float,
      Dropout ratio for decoder(include both the dropout for word embedding
      and the dropout for attention layer)
  
  tgt_vocab : object,
      The vocab object used in decoder, including all the word<->id pairs
      appeared in the output sentences.
  
  graph_pooling_strategy : str,
      The graph pooling strategy used to generate the graph embedding with node embeddings
  
  rnn_type: str, optional,
      The rnn unit is used, option=["lstm", "gru"], default="lstm".
  
  max_dec_seq_length : int, optional,
      In decoding, the decoding steps upper limit.
  
  max_dec_tree_depth : int, optional,
      In decoding, the tree depth lower limit.
code: def __init__(
      self,
      attn_type,
      embeddings,
      enc_hidden_size,
      dec_emb_size,
      dec_hidden_size,
      output_size,
      criterion,
      teacher_force_ratio,
      use_sibling=True,
      use_attention=True,
      use_copy=False,
      fuse_strategy="average",
      num_layers=1,
      dropout_for_decoder=0.1,
      rnn_type="lstm",
      max_dec_seq_length=512,
      max_dec_tree_depth=256,
      tgt_vocab=None,
      graph_pooling_strategy="max",
  ):
      super(StdTreeDecoder, self).__init__(
          use_attention=True,
          use_copy=use_copy,
          use_coverage=False,
          attention_type="uniform",
          fuse_strategy="average",
      )
      self.num_layers = num_layers
      self.criterion = criterion
      self.rnn_size = dec_hidden_size
      self.enc_hidden_size = enc_hidden_size
      self.hidden_size = dec_hidden_size
      self.max_dec_seq_length = max_dec_seq_length
      self.max_dec_tree_depth = max_dec_tree_depth
      self.tgt_vocab = tgt_vocab
      self.teacher_force_ratio = teacher_force_ratio
      self.use_sibling = use_sibling
      self.dec_emb_size = dec_emb_size
      self.dropout_input = dropout_for_decoder
      self.embeddings = embeddings
      self.graph_pooling_strategy = graph_pooling_strategy
  
      self.attn_state = {}
      self.use_copy = use_copy
      self.attention = Attention(
          query_size=dec_hidden_size,
          memory_size=enc_hidden_size * 2
          if (enc_hidden_size * 2 == dec_hidden_size)
          else enc_hidden_size,
          hidden_size=dec_hidden_size,
          has_bias=True,
          dropout=dropout_for_decoder,
          attention_funtion="dot",
      )
      self.separate_attn = attn_type != "uniform"
  
      if self.separate_attn:
          self.linear_att = nn.Linear(
              3 * dec_hidden_size, dec_hidden_size
          )
      else:
          self.linear_att = nn.Linear(
              2 * dec_hidden_size, dec_hidden_size
          )
      self.linear_out = nn.Linear(dec_hidden_size, output_size)
      self.dropout_attn = nn.Dropout(dropout_for_decoder)
      self.logsoftmax = nn.LogSoftmax(dim=1)
  
      if self.use_copy:
          ptr_size = self.embeddings.embedding_dim
          ptr_size += 4 * self.rnn_size
          self.ptr = nn.Linear(ptr_size, 1)
  
      self.rnn = self._build_rnn(
          rnn_type=rnn_type,
          input_size=output_size,
          emb_size=dec_emb_size,
          hidden_size=dec_hidden_size,
          dropout_input=dropout_for_decoder,
          use_sibling=use_sibling,
      )
  
imports: import random
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from graph4nlp.pytorch.modules.utils.tree_utils import Tree, to_cuda
  from .attention import Attention
  from .base import RNNTreeDecoderBase
label_desc: Use image node_id 1 to create a new StdTreeDecoder object from inherited base classes: RNNTreeDecoderBase with example: obj = StdTreeDecoder(attn_type, embeddings, enc_hidden_size, dec_emb_size, dec_hidden_size, output_size, criterion, teacher_force_ratio, use_sibling, use_attention, use_copy, fuse_strategy, num_layers, dropout_for_decoder, rnn_type, max_dec_seq_length, max_dec_tree_depth, tgt_vocab, graph_pooling_strategy)