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 map_state(self, fn):
      self.state["hidden"] = tuple(
          fn(h.transpose(0, 1), 0).transpose(0, 1)
          for h in self.state["hidden"]
      )
      self.state["input_feed"] = fn(
          self.state["input_feed"].transpose(0, 1), 0
      ).transpose(0, 1)
      if self._coverage and self.state["coverage"] is not None:
          self.state["coverage"] = fn(
              self.state["coverage"].transpose(0, 1), 0
          ).transpose(0, 1)
  
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 4 for calling the RNNDecoderBase obj's underlying member method code with example usage: obj.map_state(fn) without return types