class_docstr: Base recurrent attention-based decoder class.
  
  Specifies the interface used by different decoder types
  and required by :class:`~onmt.models.NMTModel`.
  
  Args:
     rnn_type (str):
        style of recurrent unit to use, one of [RNN, LSTM, GRU, SRU]
     bidirectional_encoder (bool) : use with a bidirectional encoder
     num_layers (int) : number of stacked layers
     hidden_size (int) : hidden size of each layer
     attn_type (str) : see :class:`~onmt.modules.GlobalAttention`
     attn_func (str) : see :class:`~onmt.modules.GlobalAttention`
     coverage_attn (str): see :class:`~onmt.modules.GlobalAttention`
     context_gate (str): see :class:`~onmt.modules.ContextGate`
     copy_attn (bool): setup a separate copy attention mechanism
     dropout (float) : dropout value for :class:`torch.nn.Dropout`
     embeddings (onmt.modules.Embeddings): embedding module to use
     reuse_copy_attn (bool): reuse the attention for copying
     copy_attn_type (str): The copy attention style. See
      :class:`~onmt.modules.GlobalAttention`.
class_docstr_tok: ["Base","recurrent","attention-based","decoder","class",".","Specifies","the","interface","used","by","different","decoder","types","and","required","by",":","class",":","`","~onmt.models.NMTModel","`",".","Args",":","rnn_type","(","str",")",":","style","of","recurrent","unit","to","use",",","one","of","[","RNN",",","LSTM",",","GRU",",","SRU","]","bidirectional_encoder","(","bool",")",":","use","with","a","bidirectional","encoder","num_layers","(","int",")",":","number","of","stacked","layers","hidden_size","(","int",")",":","hidden","size","of","each","layer","attn_type","(","str",")",":","see",":","class",":","`","~onmt.modules.GlobalAttention","`","attn_func","(","str",")",":","see",":","class",":","`","~onmt.modules.GlobalAttention","`","coverage_attn","(","str",")",":","see",":","class",":","`","~onmt.modules.GlobalAttention","`","context_gate","(","str",")",":","see",":","class",":","`","~onmt.modules.ContextGate","`","copy_attn","(","bool",")",":","setup","a","separate","copy","attention","mechanism","dropout","(","float",")",":","dropout","value","for",":","class",":","`","torch.nn.Dropout","`","embeddings","(","onmt.modules.Embeddings",")",":","embedding","module","to","use","reuse_copy_attn","(","bool",")",":","reuse","the","attention","for","copying","copy_attn_type","(","str",")",":","The","copy","attention","style",".","See",":","class",":","`","~onmt.modules.GlobalAttention","`","."]
docstr: Args:
      tgt (LongTensor): sequences of padded tokens
           ``(batch, tgt_len, nfeats)``.
      enc_out (FloatTensor): vectors from the encoder
           ``(batch, src_len, hidden)``.
      src_len (LongTensor): the padded source lengths
          ``(batch,)``.
  
  Returns:
      (FloatTensor, dict[str, FloatTensor]):
  
      * dec_outs: output from the decoder (after attn)
        ``(batch, tgt_len, hidden)``.
      * attns: distribution over src at each tgt
        ``(batch, tgt_len, src_len)``.
docstr_tok: ["Args",":","tgt","(","LongTensor",")",":","sequences","of","padded","tokens","``","(","batch",",","tgt_len",",","nfeats",")","``",".","enc_out","(","FloatTensor",")",":","vectors","from","the","encoder","``","(","batch",",","src_len",",","hidden",")","``",".","src_len","(","LongTensor",")",":","the","padded","source","lengths","``","(","batch",",",")","``",".","Returns",":","(","FloatTensor",",","dict","[","str",",","FloatTensor","]",")",":","*","dec_outs",":","output","from","the","decoder","(","after","attn",")","``","(","batch",",","tgt_len",",","hidden",")","``",".","*","attns",":","distribution","over","src","at","each","tgt","``","(","batch",",","tgt_len",",","src_len",")","``","."]
code: def forward(self, tgt, enc_out, src_len=None, step=None, **kwargs):
      """
      Args:
          tgt (LongTensor): sequences of padded tokens
               ``(batch, tgt_len, nfeats)``.
          enc_out (FloatTensor): vectors from the encoder
               ``(batch, src_len, hidden)``.
          src_len (LongTensor): the padded source lengths
              ``(batch,)``.
  
      Returns:
          (FloatTensor, dict[str, FloatTensor]):
  
          * dec_outs: output from the decoder (after attn)
            ``(batch, tgt_len, hidden)``.
          * attns: distribution over src at each tgt
            ``(batch, tgt_len, src_len)``.
      """
      dec_state, dec_outs, attns = self._run_forward_pass(
          tgt, enc_out, src_len=src_len
      )
  
      # Update the state with the result.
      if not isinstance(dec_state, tuple):
          dec_state = (dec_state,)
      self.state["hidden"] = dec_state
  
      # Concatenates sequence of tensors along a new dimension.
      # NOTE: v0.3 to 0.4: dec_outs / attns[*] may not be list
      #       (in particular in case of SRU) it was not raising error in 0.3
      #       since stack(Variable) was allowed.
      #       In 0.4, SRU returns a tensor that shouldn't be stacke
      if type(dec_outs) == list:
          dec_outs = torch.stack(dec_outs, dim=1)
          for k in attns:
              if type(attns[k]) == list:
                  attns[k] = torch.stack(attns[k])
  
      self.state["input_feed"] = dec_outs[:, -1, :].unsqueeze(0)
      self.state["coverage"] = None
      if "coverage" in attns:
          self.state["coverage"] = attns["coverage"][
              -1, :, :
          ].unsqueeze(0)
  
      return dec_outs, attns
  
imports: import torch
  import torch.nn
  from onmt.modules.stacked_rnn import StackedLSTM, StackedGRU
  from onmt.modules import context_gate_factory, GlobalAttention
  from onmt.utils.rnn_factory import rnn_factory
label_desc: Use image node_id 6 for calling the RNNDecoderBase obj's underlying member method code with example usage: obj.forward(tgt, enc_out, src_len, step) and returns: dec_outs,  attns