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","`","."]
code: def __init__(
      self,
      rnn_type,
      bidirectional_encoder,
      num_layers,
      hidden_size,
      attn_type="general",
      attn_func="softmax",
      coverage_attn=False,
      context_gate=None,
      copy_attn=False,
      dropout=0.0,
      embeddings=None,
      reuse_copy_attn=False,
      copy_attn_type="general",
  ):
      super(RNNDecoderBase, self).__init__(
          attentional=attn_type != "none" and attn_type is not None
      )
  
      self.bidirectional_encoder = bidirectional_encoder
      self.num_layers = num_layers
      self.hidden_size = hidden_size
      self.embeddings = embeddings
      self.dropout = nn.Dropout(dropout)
  
      # Decoder state
      self.state = {}
  
      # Build the RNN.
      self.rnn = self._build_rnn(
          rnn_type,
          input_size=self._input_size,
          hidden_size=hidden_size,
          num_layers=num_layers,
          dropout=dropout,
      )
  
      # Set up the context gate.
      self.context_gate = None
      if context_gate is not None:
          self.context_gate = context_gate_factory(
              context_gate,
              self._input_size,
              hidden_size,
              hidden_size,
              hidden_size,
          )
  
      # Set up the standard attention.
      self._coverage = coverage_attn
      if not self.attentional:
          if self._coverage:
              raise ValueError(
                  "Cannot use coverage term with no attention."
              )
          self.attn = None
      else:
          self.attn = GlobalAttention(
              hidden_size,
              coverage=coverage_attn,
              attn_type=attn_type,
              attn_func=attn_func,
          )
  
      if copy_attn and not reuse_copy_attn:
          if copy_attn_type == "none" or copy_attn_type is None:
              raise ValueError(
                  "Cannot use copy_attn with copy_attn_type none"
              )
          self.copy_attn = GlobalAttention(
              hidden_size, attn_type=copy_attn_type, attn_func=attn_func
          )
      else:
          self.copy_attn = None
  
      self._reuse_copy_attn = reuse_copy_attn and copy_attn
      if self._reuse_copy_attn and not self.attentional:
          raise ValueError(
              "Cannot reuse copy attention with no attention."
          )
  
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 1 to create a new RNNDecoderBase object from inherited base classes: DecoderBase with example: obj = RNNDecoderBase(rnn_type, bidirectional_encoder, num_layers, hidden_size, attn_type, attn_func, coverage_attn, context_gate, copy_attn, dropout, embeddings, reuse_copy_attn, copy_attn_type)