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).
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",")","."]
code: def __init__(
      self,
      cfg: Wav2Vec2Seq2SeqConfig,
      dictionary,
      embed_tokens,
      no_encoder_attn=False,
  ):
      super().__init__(dictionary)
  
      self.dropout = cfg.decoder_dropout
      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.output_embed_dim = cfg.decoder_embed_dim
  
      self.layerdrop = cfg.decoder_layerdrop
  
      self.padding_idx = embed_tokens.padding_idx
      self.max_target_positions = cfg.max_target_positions
  
      self.embed_tokens = embed_tokens
      self.embed_scale = math.sqrt(
          embed_dim
      )  # todo: try with input_embed_dim
  
      self.project_in_dim = (
          Linear(input_embed_dim, embed_dim, bias=False)
          if embed_dim != input_embed_dim
          else None
      )
  
      self.embed_positions = (
          PositionalEmbedding(
              cfg.max_target_positions,
              embed_dim,
              self.padding_idx,
              learned=cfg.decoder_learned_pos,
          )
          if not cfg.no_token_positional_embeddings
          else None
      )
  
      # TODO: update this when transformer gets converted to dataclass configs
      transformer_cfg = copy.deepcopy(cfg)
      with open_dict(transformer_cfg):
          transformer_cfg.dropout = transformer_cfg.decoder_dropout
          transformer_cfg.attention_dropout = (
              transformer_cfg.decoder_attention_dropout
          )
          transformer_cfg.activation_dropout = (
              transformer_cfg.decoder_activation_dropout
          )
  
      self.layers = nn.ModuleList([])
      self.layers.extend(
          [
              TransformerDecoderLayer(transformer_cfg, no_encoder_attn)
              for _ in range(transformer_cfg.decoder_layers)
          ]
      )
  
      if not self.share_input_output_embed:
          self.embed_out = nn.Parameter(
              torch.Tensor(len(dictionary), self.output_embed_dim)
          )
          nn.init.normal_(
              self.embed_out, mean=0, std=self.output_embed_dim**-0.5
          )
  
      if transformer_cfg.decoder_normalize_before:
          self.layer_norm = LayerNorm(embed_dim)
      else:
          self.layer_norm = None
  
imports: import contextlib
  import copy
  import logging
  import math
  import re
  from argparse import Namespace
  from dataclasses import dataclass, field
  from typing import Any, Optional
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from omegaconf import II, MISSING, open_dict
  from fairseq import checkpoint_utils, tasks, utils
  from fairseq.dataclass import FairseqDataclass
  from fairseq.dataclass.utils import convert_namespace_to_omegaconf
  from fairseq.models import BaseFairseqModel, FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model
  from fairseq.models.wav2vec.wav2vec2 import MASKING_DISTRIBUTION_CHOICES, LAYER_TYPE_CHOICES, AdapterFast
  from fairseq.modules import LayerNorm, PositionalEmbedding, TransformerDecoderLayer
  from fairseq.tasks import FairseqTask
label_desc: Use image node_id 1 to create a new TransformerDecoder object from inherited base classes: FairseqIncrementalDecoder with example: obj = TransformerDecoder(cfg, dictionary, embed_tokens, no_encoder_attn)