class_docstr: Recurrent decoder module.
  
  Can be used as a standalone language model or paired with an encoder.
docstr: Initialize recurrent decoder.
docstr_tok: ["Initialize","recurrent","decoder","."]
code: def __init__(
      self,
      num_features,
      embeddingsize,
      hiddensize,
      padding_idx=0,
      rnn_class="lstm",
      numlayers=2,
      dropout=0.1,
      bidir_input=False,
      attn_type="none",
      attn_time="pre",
      attn_length=-1,
      sparse=False,
  ):
      """
      Initialize recurrent decoder.
      """
      super().__init__()
      self.dropout = nn.Dropout(p=dropout)
      self.layers = numlayers
      self.hsz = hiddensize
      self.esz = embeddingsize
  
      self.lt = nn.Embedding(
          num_features,
          embeddingsize,
          padding_idx=padding_idx,
          sparse=sparse,
      )
      self.rnn = rnn_class(
          embeddingsize,
          hiddensize,
          numlayers,
          dropout=dropout if numlayers > 1 else 0,
          batch_first=True,
      )
  
      self.attn_type = attn_type
      self.attn_time = attn_time
      self.attention = AttentionLayer(
          attn_type=attn_type,
          hiddensize=hiddensize,
          embeddingsize=embeddingsize,
          bidirectional=bidir_input,
          attn_length=attn_length,
          attn_time=attn_time,
      )
  
imports: import math
  import torch
  import torch.nn
  from torch.nn.parameter import Parameter
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
  import torch.nn.functional
  from parlai.utils.torch import neginf
  from parlai.core.torch_generator_agent import TorchGeneratorModel
label_desc: Use image node_id 1 to create a new RNNDecoder object from inherited base classes: nn with example: obj = RNNDecoder(num_features, embeddingsize, hiddensize, padding_idx, rnn_class, numlayers, dropout, bidir_input, attn_type, attn_time, attn_length, sparse)