class_docstr: Transformer decoder consisting of *cfg.decoder.layers* layers. Each layer
  is a :class:`TransformerDecoderLayer`.
  
  Args:
      cfg (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).
class_docstr_tok: ["Transformer","decoder","consisting","of","*","cfg.decoder.layers","*","layers",".","Each","layer","is","a",":","class",":","`","TransformerDecoderLayer","`",".","Args",":","cfg","(","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",")","."]
docstr: Args:
      prev_output_tokens (LongTensor): previous decoder outputs of shape
          `(batch, tgt_len)`, for teacher forcing
      encoder_out (optional): output from the encoder, used for
          encoder-side attention, should be of size T x B x C
      incremental_state (dict): dictionary used for storing state during
          :ref:`Incremental decoding`
      features_only (bool, optional): only return features without
          applying output layer (default: False).
      full_context_alignment (bool, optional): don't apply
          auto-regressive mask to self-attention (default: False).
  
  Returns:
      tuple:
          - the decoder's output of shape `(batch, tgt_len, vocab)`
          - a dictionary with any model-specific outputs
docstr_tok: ["Args",":","prev_output_tokens","(","LongTensor",")",":","previous","decoder","outputs","of","shape","`","(","batch",",","tgt_len",")","`",",","for","teacher","forcing","encoder_out","(","optional",")",":","output","from","the","encoder",",","used","for","encoder-side","attention",",","should","be","of","size","T","x","B","x","C","incremental_state","(","dict",")",":","dictionary","used","for","storing","state","during",":","ref",":","`","Incremental","decoding","`","features_only","(","bool",",","optional",")",":","only","return","features","without","applying","output","layer","(","default",":","False",")",".","full_context_alignment","(","bool",",","optional",")",":","do","n't","apply","auto-regressive","mask","to","self-attention","(","default",":","False",")",".","Returns",":","tuple",":","-","the","decoder","'s","output","of","shape","`","(","batch",",","tgt_len",",","vocab",")","`","-","a","dictionary","with","any","model-specific","outputs"]
code: def forward(
      self,
      prev_output_tokens,
      encoder_out: Optional[Dict[str, List[Tensor]]] = None,
      incremental_state: Optional[
          Dict[str, Dict[str, Optional[Tensor]]]
      ] = None,
      features_only: bool = False,
      full_context_alignment: bool = False,
      alignment_layer: Optional[int] = None,
      alignment_heads: Optional[int] = None,
      src_lengths: Optional[Any] = None,
      return_all_hiddens: bool = False,
  ):
      """
      Args:
          prev_output_tokens (LongTensor): previous decoder outputs of shape
              `(batch, tgt_len)`, for teacher forcing
          encoder_out (optional): output from the encoder, used for
              encoder-side attention, should be of size T x B x C
          incremental_state (dict): dictionary used for storing state during
              :ref:`Incremental decoding`
          features_only (bool, optional): only return features without
              applying output layer (default: False).
          full_context_alignment (bool, optional): don't apply
              auto-regressive mask to self-attention (default: False).
  
      Returns:
          tuple:
              - the decoder's output of shape `(batch, tgt_len, vocab)`
              - a dictionary with any model-specific outputs
      """
  
      x, extra = self.extract_features(
          prev_output_tokens,
          encoder_out=encoder_out,
          incremental_state=incremental_state,
          full_context_alignment=full_context_alignment,
          alignment_layer=alignment_layer,
          alignment_heads=alignment_heads,
      )
  
      if not features_only:
          x = self.output_layer(x)
      return x, extra
  
imports: import math
  from typing import Any, Dict, List, Optional
  import torch
  import torch.nn
  from torch import Tensor
  from fairseq import utils
  from fairseq.distributed import fsdp_wrap
  from fairseq.models import FairseqIncrementalDecoder
  from fairseq.models.transformer import TransformerConfig
  from fairseq.modules import AdaptiveSoftmax, BaseLayer, FairseqDropout, LayerDropModuleList, LayerNorm, PositionalEmbedding, SinusoidalPositionalEmbedding, transformer_layer
  from fairseq.modules.checkpoint_activations import checkpoint_wrapper
  from fairseq.modules.quant_noise import quant_noise
label_desc: Use image node_id 4 for calling the TransformerDecoderBase obj's underlying member method code with example usage: obj.forward(prev_output_tokens, encoder_out, incremental_state, features_only, full_context_alignment, alignment_layer, alignment_heads, src_lengths, return_all_hiddens) and returns: x,  extra