class_docstr: Transformer decoder consisting of *args.decoder_layers* layers. Each layer
  is a :class:`TransformerAANDecoderLayer`.
class_docstr_tok: ["Transformer","decoder","consisting","of","*","args.decoder_layers","*","layers",".","Each","layer","is","a",":","class",":","`","TransformerAANDecoderLayer","`","."]
code: def __init__(
      self,
      args,
      src_dict,
      dst_dict,
      embed_tokens,
      no_encoder_attn=False,
      left_pad=False,
      final_norm=True,
  ):
      super().__init__(dst_dict)
      self.dropout = args.dropout
      self.share_input_output_embed = (
          args.share_decoder_input_output_embed
      )
  
      input_embed_dim = embed_tokens.embedding_dim
      embed_dim = args.decoder_embed_dim
  
      padding_idx = embed_tokens.padding_idx
      self.max_target_positions = args.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 = fairseq_transformer.PositionalEmbedding(
          1024, embed_dim, padding_idx, learned=args.decoder_learned_pos
      )
  
      self.layers = nn.ModuleList([])
      self.layers.extend(
          [
              TransformerAANDecoderLayer(args, no_encoder_attn)
              for _ in range(args.decoder_layers)
          ]
      )
  
      self.adaptive_softmax = None
  
      self.bottleneck_layer = None
      out_embed_dim = embed_dim
      if args.decoder_out_embed_dim is not None:
          assert (
              not args.share_all_embeddings
              and not args.share_decoder_input_output_embed
          ), "--decoder-out-embed-dim is incompatible with sharing output embeddings!"
          self.bottleneck_layer = Linear(
              embed_dim, args.decoder_out_embed_dim
          )
          out_embed_dim = args.decoder_out_embed_dim
  
      if args.adaptive_softmax_cutoff is not None:
          self.adaptive_softmax = AdaptiveSoftmax(
              len(dst_dict),
              out_embed_dim,
              options.eval_str_list(
                  args.adaptive_softmax_cutoff, type=int
              ),
              dropout=args.adaptive_softmax_dropout,
              adaptive_inputs=embed_tokens
              if args.tie_adaptive_weights
              else None,
              factor=args.adaptive_softmax_factor,
              tie_proj=args.tie_adaptive_proj,
          )
      elif not self.share_input_output_embed:
          self.embed_out = nn.Parameter(
              torch.Tensor(len(dst_dict), out_embed_dim)
          )
          nn.init.normal_(
              self.embed_out, mean=0, std=out_embed_dim**-0.5
          )
      self.register_buffer("version", torch.Tensor([2]))
      self.normalize = args.decoder_normalize_before and final_norm
      if self.normalize:
          self.layer_norm = LayerNorm(embed_dim)
  
      self.vocab_reduction_module = None
      if args.vocab_reduction_params:
          assert (
              self.adaptive_softmax is None
          ), "vocabulary reduction not compatible with adaptive softmax!"
          self.vocab_reduction_module = vocab_reduction.VocabReduction(
              src_dict,
              dst_dict,
              args.vocab_reduction_params,
              fp16=args.fp16,
          )
  
      self.onnx_trace = False
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import options, utils
  from fairseq.models import FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture, transformer
  from fairseq.modules import AdaptiveSoftmax, LearnedPositionalEmbedding, MultiheadAttention, SinusoidalPositionalEmbedding
  from pytorch_translate import transformer, vocab_reduction
  from pytorch_translate.average_attention import AverageAttention, AverageWindowAttention
  from pytorch_translate.utils import torch_find
label_desc: Use image node_id 1 to create a new TransformerAANDecoder object from inherited base classes: FairseqIncrementalDecoder with example: obj = TransformerAANDecoder(args, src_dict, dst_dict, embed_tokens, no_encoder_attn, left_pad, final_norm)