docstr: Args:
      dictionary: target text dictionary.
      embed_dim: embedding dimension for target tokens.
      num_layers: number of LSTM layers.
      hidden_size: hidden size for LSTM layers.
      dropout: dropout probability. Dropout can be applied to the
          embeddings, the LSTM layers, and the context vector.
      encoder_output_dim: encoder output dimension (hidden size of
          encoder LSTM).
      attention_dim: attention dimension for MLP attention.
      output_layer_dim: size of the linear layer prior to output
          projection.
docstr_tok: ["Args",":","dictionary",":","target","text","dictionary",".","embed_dim",":","embedding","dimension","for","target","tokens",".","num_layers",":","number","of","LSTM","layers",".","hidden_size",":","hidden","size","for","LSTM","layers",".","dropout",":","dropout","probability",".","Dropout","can","be","applied","to","the","embeddings",",","the","LSTM","layers",",","and","the","context","vector",".","encoder_output_dim",":","encoder","output","dimension","(","hidden","size","of","encoder","LSTM",")",".","attention_dim",":","attention","dimension","for","MLP","attention",".","output_layer_dim",":","size","of","the","linear","layer","prior","to","output","projection","."]
code: def __init__(
      self,
      dictionary,
      embed_dim,
      num_layers,
      hidden_size,
      dropout,
      encoder_output_dim,
      attention_dim,
      output_layer_dim,
  ):
      """
      Args:
          dictionary: target text dictionary.
          embed_dim: embedding dimension for target tokens.
          num_layers: number of LSTM layers.
          hidden_size: hidden size for LSTM layers.
          dropout: dropout probability. Dropout can be applied to the
              embeddings, the LSTM layers, and the context vector.
          encoder_output_dim: encoder output dimension (hidden size of
              encoder LSTM).
          attention_dim: attention dimension for MLP attention.
          output_layer_dim: size of the linear layer prior to output
              projection.
      """
      super().__init__(dictionary)
      self.num_layers = num_layers
      self.hidden_size = hidden_size
      num_embeddings = len(dictionary)
      padding_idx = dictionary.pad()
      self.embed_tokens = nn.Embedding(
          num_embeddings, embed_dim, padding_idx
      )
      if dropout > 0:
          self.dropout = nn.Dropout(p=dropout)
      else:
          self.dropout = None
  
      self.layers = nn.ModuleList()
      for layer_id in range(num_layers):
          input_size = (
              embed_dim if layer_id == 0 else encoder_output_dim
          )
          self.layers.append(
              nn.LSTMCell(
                  input_size=input_size, hidden_size=hidden_size
              )
          )
  
      self.context_dim = encoder_output_dim
      self.attention = MLPAttention(
          decoder_hidden_state_dim=hidden_size,
          context_dim=encoder_output_dim,
          attention_dim=attention_dim,
      )
  
      self.deep_output_layer = nn.Linear(
          hidden_size + encoder_output_dim + embed_dim, output_layer_dim
      )
      self.output_projection = nn.Linear(
          output_layer_dim, num_embeddings
      )
  
imports: from ast import literal_eval
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import checkpoint_utils, utils
  from fairseq.data.data_utils import lengths_to_padding_mask
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
label_desc: Use image node_id 1 to create a new LSTMDecoder object from inherited base classes: FairseqIncrementalDecoder with example: obj = LSTMDecoder(dictionary, embed_dim, num_layers, hidden_size, dropout, encoder_output_dim, attention_dim, output_layer_dim)