class_docstr: Implements functionality common to all transformer decoder layer variants. Subclass
  this if you'd like to modify the behavior of any layer in a transformer decoder.
  
  While this code is functional, it is not intended to be instantiated directly. If
  this functionality is desired as-is, use TransformerDecoderOnlyLayer instead to gain
  the ability to swap self-attention and feedforward classes at instantiation.
docstr: Forward pass.
  
  The incremental state is a dict with values for self-attention states.
docstr_tok: ["Forward","pass",".","The","incremental","state","is","a","dict","with","values","for","self-attention","states","."]
code: def forward(
      self,
      x: torch.Tensor,
      *extra_args,
      incr_state: Optional[DecoderLayerIncrState] = None,
      **kwargs,
  ) -> Tuple[torch.Tensor, DecoderLayerIncrState]:
      """
      Forward pass.
  
      The incremental state is a dict with values for self-attention states.
      """
      if incr_state is None:
          incr_state = {}
  
      decoder_mask = self._create_selfattn_mask(x)
      # first self attn
      residual = x
      if self.variant == "prelayernorm":
          x = self.norm1(x)
  
      # don't peak into the future!
      x, final_self_attn_incr_state = self.self_attention(
          query=x,
          mask=decoder_mask,
          incr_state=incr_state.get("self_attn"),
          static_kv=False,
          **kwargs,
      )[:2]
      x = self.dropout(x)  # --dropout
      x = x + residual
      if (
          self.variant == "aiayn"
          or self.variant == "xlm"
          or self.variant == "bart"
      ):
          x = self.norm1(x)
  
      # finally the ffn
      residual = x
      if self.variant == "prelayernorm":
          x = self.norm3(x)
      x = self.ffn(x, **kwargs)
      x = self.dropout(x)  # --dropout
      x = residual + x
      if (
          self.variant == "aiayn"
          or self.variant == "xlm"
          or self.variant == "bart"
      ):
          x = self.norm3(x)
  
      return x, {"self_attn": final_self_attn_incr_state}
  
imports: from __future__ import annotations
  from abc import ABC
  from typing import Dict, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  from parlai.agents.transformer.modules import create_position_codes, get_n_positions_from_options, LAYER_NORM_EPS, MultiHeadAttention, TransformerFFN
  from parlai.agents.transformer.modules.modular import swappable
  from parlai.core.opt import Opt
  from parlai.core.params import default
  from parlai.core.torch_agent import DictionaryAgent
  from parlai.utils.misc import warn_once
  from parlai.utils.torch import PipelineHelper
  from parlai.utils.fsdp import fsdp_wrap
  from parlai.nn.checkpoint import checkpoint_wrapper
label_desc: Use image node_id 4 for calling the BaseTransformerDecoderLayer obj's underlying member method code with example usage: obj.forward(x) and returns: x,  dict