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 pre_attention(
      self,
      prev_output_tokens,
      encoder_out_dict: Dict[str, List[Tensor]],
      incremental_state: Optional[
          Dict[str, Dict[str, Optional[Tensor]]]
      ] = None,
  ):
      positions = (
          self.embed_positions(
              prev_output_tokens,
              incremental_state=incremental_state,
          )
          if self.embed_positions is not None
          else None
      )
  
      if incremental_state is not None:
          prev_output_tokens = prev_output_tokens[:, -1:]
          if positions is not None:
              positions = positions[:, -1:]
      # embed tokens and positions
      x = self.embed_scale * self.embed_tokens(prev_output_tokens)
  
      if self.project_in_dim is not None:
          x = self.project_in_dim(x)
  
      if positions is not None:
          x += positions
  
      x = self.dropout_module(x)
  
      # B x T x C -> T x B x C
      x = x.transpose(0, 1)
  
      encoder_out = encoder_out_dict["encoder_out"][0]
  
      if "encoder_padding_mask" in encoder_out_dict:
          encoder_padding_mask = (
              encoder_out_dict["encoder_padding_mask"][0]
              if encoder_out_dict["encoder_padding_mask"]
              and len(encoder_out_dict["encoder_padding_mask"]) > 0
              else None
          )
      else:
          encoder_padding_mask = None
  
      return x, encoder_out, encoder_padding_mask
  
imports: from typing import Dict, List, NamedTuple, Optional
  import torch
  import torch.nn
  from examples.simultaneous_translation.modules.monotonic_transformer_layer import TransformerMonotonicDecoderLayer, TransformerMonotonicEncoderLayer
  from fairseq.models import register_model, register_model_architecture
  from fairseq.models.transformer import TransformerModel, TransformerEncoder, TransformerDecoder, base_architecture, transformer_iwslt_de_en, transformer_vaswani_wmt_en_de_big, tiny_architecture
  from torch import Tensor
label_desc: Use image node_id 3 for calling the TransformerMonotonicDecoder obj's underlying member method code with example usage: obj.pre_attention(prev_output_tokens, encoder_out_dict, incremental_state) and returns: x,  encoder_out,  encoder_padding_mask