class_docstr: Implements functionality common to all transformer decoder variants. Not intended to
  be instantiated directly.
  
  For a (Vaswani 2017) style encoder-decoder transformer, use ``TransformerDecoder``. For a GPT-style decoder-only transformer, use ``TransformerDecoderOnly``.
  
  Subclasses are required to implement ``forward``. In your ``forward`` implementation, you can call ``forward_embedding`` to get embeddings for the input tokens and ``forward_layers`` to pass those embeddings sequentially through each layer.
  
  Subclasses can optionally override ``__init__``, ``build_layer``, and
  ``build_layers`` to customize subcomponents. In particular, ``build_layer`` can be used to instantiate heterogeneous layers (e.g. every other layer being a different type).
docstr: Forward pass.
  
  :param LongTensor[batch,seqlen] input:
      The decoder inputs (partial or full decoded token IDs).
  :param encoder_state:
      Output from the encoder module forward pass.
  :param incr_state:
      The incremental state: a dictionary whose keys index the layers and whose
      values contain the incremental state for each layer.
docstr_tok: ["Forward","pass",".",":","param","LongTensor","[","batch",",","seqlen","]","input",":","The","decoder","inputs","(","partial","or","full","decoded","token","IDs",")",".",":","param","encoder_state",":","Output","from","the","encoder","module","forward","pass",".",":","param","incr_state",":","The","incremental","state",":","a","dictionary","whose","keys","index","the","layers","and","whose","values","contain","the","incremental","state","for","each","layer","."]
code: def forward(
      self,
      input: torch.Tensor,
      encoder_state: Tuple[torch.Tensor, torch.Tensor],
      incr_state: Optional[DecoderIncrState] = None,
      **kwargs,
  ) -> Tuple[torch.Tensor, DecoderIncrState]:
      """
      Forward pass.
  
      :param LongTensor[batch,seqlen] input:
          The decoder inputs (partial or full decoded token IDs).
      :param encoder_state:
          Output from the encoder module forward pass.
      :param incr_state:
          The incremental state: a dictionary whose keys index the layers and whose
          values contain the incremental state for each layer.
      """
      raise NotImplementedError
  
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 BaseTransformerDecoder obj's underlying member method code with example usage: obj.forward(input, encoder_state, incr_state) without return types