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",")","."]
code: def __init__(
      self,
      cfg,
      dictionary,
      embed_tokens,
      no_encoder_attn=False,
      output_projection=None,
  ):
      self.cfg = cfg
      super().__init__(dictionary)
      self.register_buffer("version", torch.Tensor([3]))
      self._future_mask = torch.empty(0)
  
      self.dropout_module = FairseqDropout(
          cfg.dropout,
          module_name=module_name_fordropout(self.__class__.__name__),
      )
      self.decoder_layerdrop = cfg.decoder.layerdrop
      self.share_input_output_embed = (
          cfg.share_decoder_input_output_embed
      )
  
      input_embed_dim = embed_tokens.embedding_dim
      embed_dim = cfg.decoder.embed_dim
      self.embed_dim = embed_dim
      self.output_embed_dim = cfg.decoder.output_dim
  
      self.padding_idx = embed_tokens.padding_idx
      self.max_target_positions = cfg.max_target_positions
  
      self.embed_tokens = embed_tokens
  
      self.embed_scale = (
          1.0 if cfg.no_scale_embedding else math.sqrt(embed_dim)
      )
  
      if not cfg.adaptive_input and cfg.quant_noise.pq > 0:
          self.quant_noise = apply_quant_noise_(
              nn.Linear(embed_dim, embed_dim, bias=False),
              cfg.quant_noise.pq,
              cfg.quant_noise.pq_block_size,
          )
      else:
          self.quant_noise = None
  
      self.project_in_dim = (
          Linear(input_embed_dim, embed_dim, bias=False)
          if embed_dim != input_embed_dim
          else None
      )
      self.embed_positions = (
          PositionalEmbedding(
              self.max_target_positions,
              embed_dim,
              self.padding_idx,
              learned=cfg.decoder.learned_pos,
          )
          if not cfg.no_token_positional_embeddings
          else None
      )
      if cfg.layernorm_embedding:
          self.layernorm_embedding = LayerNorm(
              embed_dim, export=cfg.export
          )
      else:
          self.layernorm_embedding = None
  
      self.cross_self_attention = cfg.cross_self_attention
  
      if self.decoder_layerdrop > 0.0:
          self.layers = LayerDropModuleList(p=self.decoder_layerdrop)
      else:
          self.layers = nn.ModuleList([])
      self.layers.extend(
          [
              self.build_decoder_layer(cfg, no_encoder_attn)
              for _ in range(cfg.decoder.layers)
          ]
      )
      self.num_layers = len(self.layers)
  
      if cfg.decoder.normalize_before and not cfg.no_decoder_final_norm:
          self.layer_norm = LayerNorm(embed_dim, export=cfg.export)
      else:
          self.layer_norm = None
  
      self.project_out_dim = (
          Linear(embed_dim, self.output_embed_dim, bias=False)
          if embed_dim != self.output_embed_dim
          and not cfg.tie_adaptive_weights
          else None
      )
  
      self.adaptive_softmax = None
      self.output_projection = output_projection
      if self.output_projection is None:
          self.build_output_projection(cfg, dictionary, embed_tokens)
  
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 1 to create a new TransformerDecoderBase object from inherited base classes: FairseqIncrementalDecoder with example: obj = TransformerDecoderBase(cfg, dictionary, embed_tokens, no_encoder_attn, output_projection)