class_docstr: Transformer decoder consisting of *args.decoder_layers* layers. Each layer
  is a :class:`TransformerDecoderLayer`.
  Args:
      args (argparse.Namespace): parsed command-line arguments
      dictionary (~fairseq.data.Dictionary): decoding dictionary
      embed_tokens (torch.nn.Embedding): output embedding
      no_encoder_attn (bool, optional): whether to attend to encoder outputs.
          Default: ``False``
      left_pad (bool, optional): whether the input is left-padded. Default:
          ``False``
class_docstr_tok: ["Transformer","decoder","consisting","of","*","args.decoder_layers","*","layers",".","Each","layer","is","a",":","class",":","`","TransformerDecoderLayer","`",".","Args",":","args","(","argparse.Namespace",")",":","parsed","command-line","arguments","dictionary","(","~fairseq.data.Dictionary",")",":","decoding","dictionary","embed_tokens","(","torch.nn.Embedding",")",":","output","embedding","no_encoder_attn","(","bool",",","optional",")",":","whether","to","attend","to","encoder","outputs",".","Default",":","``","False","``","left_pad","(","bool",",","optional",")",":","whether","the","input","is","left-padded",".","Default",":","``","False","``"]
docstr: Args:
      prev_output_tokens (LongTensor): previous decoder outputs of shape
          `(batch, tgt_len)`, for input feeding/teacher forcing
      encoder_out (Tensor, optional): output from the encoder, used for
          encoder-side attention
      incremental_state (dict): dictionary used for storing state during
          :ref:`Incremental decoding`
  Returns:
      tuple:
          - the last decoder layer's output of shape `(batch, tgt_len,
            vocab)`
          - the last decoder layer's attention weights of shape `(batch,
            tgt_len, src_len)`
docstr_tok: ["Args",":","prev_output_tokens","(","LongTensor",")",":","previous","decoder","outputs","of","shape","`","(","batch",",","tgt_len",")","`",",","for","input","feeding\/teacher","forcing","encoder_out","(","Tensor",",","optional",")",":","output","from","the","encoder",",","used","for","encoder-side","attention","incremental_state","(","dict",")",":","dictionary","used","for","storing","state","during",":","ref",":","`","Incremental","decoding","`","Returns",":","tuple",":","-","the","last","decoder","layer","'s","output","of","shape","`","(","batch",",","tgt_len",",","vocab",")","`","-","the","last","decoder","layer","'s","attention","weights","of","shape","`","(","batch",",","tgt_len",",","src_len",")","`"]
code: def forward(
      self, prev_output_tokens, encoder_out=None, incremental_state=None
  ):
      """
      Args:
          prev_output_tokens (LongTensor): previous decoder outputs of shape
              `(batch, tgt_len)`, for input feeding/teacher forcing
          encoder_out (Tensor, optional): output from the encoder, used for
              encoder-side attention
          incremental_state (dict): dictionary used for storing state during
              :ref:`Incremental decoding`
      Returns:
          tuple:
              - the last decoder layer's output of shape `(batch, tgt_len,
                vocab)`
              - the last decoder layer's attention weights of shape `(batch,
                tgt_len, src_len)`
      """
      target_padding_mask = (
          (prev_output_tokens == self.padding_idx).to(
              prev_output_tokens.device
          )
          if incremental_state is None
          else None
      )
  
      if incremental_state is not None:
          prev_output_tokens = prev_output_tokens[:, -1:]
  
      # embed tokens
      x = self.embed_tokens(prev_output_tokens)
  
      # B x T x C -> T x B x C
      x = self._transpose_if_training(x, incremental_state)
  
      for layer in self.conv_layers:
          if isinstance(layer, LinearizedConvolution):
              x = layer(x, incremental_state)
          else:
              x = layer(x)
  
      # B x T x C -> T x B x C
      x = self._transpose_if_inference(x, incremental_state)
  
      # decoder layers
      for layer in self.layers:
          if isinstance(layer, TransformerDecoderLayer):
              x, *_ = layer(
                  x,
                  (
                      encoder_out["encoder_out"]
                      if encoder_out is not None
                      else None
                  ),
                  (
                      encoder_out["encoder_padding_mask"].t()
                      if encoder_out["encoder_padding_mask"] is not None
                      else None
                  ),
                  incremental_state,
                  self_attn_mask=(
                      self.buffered_future_mask(x)
                      if incremental_state is None
                      else None
                  ),
                  self_attn_padding_mask=(
                      target_padding_mask
                      if incremental_state is None
                      else None
                  ),
              )
          else:
              x = layer(x)
  
      # T x B x C -> B x T x C
      x = x.transpose(0, 1)
  
      x = self.fc_out(x)
  
      return x, None
  
imports: import argparse
  import math
  from collections.abc import Iterable
  import torch
  import torch.nn
  from examples.speech_recognition.data.data_utils import lengths_to_encoder_padding_mask
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqEncoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.modules import LinearizedConvolution, TransformerDecoderLayer, TransformerEncoderLayer, VGGBlock
label_desc: Use image node_id 2 for calling the TransformerDecoder obj's underlying member method code with example usage: obj.forward(prev_output_tokens, encoder_out, incremental_state) and returns: x,  None