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 of decoder layers.
  
  :param tensor:
      embedded input tensor for the decoder
  :param extra_args:
      any number of positional arguments to be passed to each layer
  :param incr_state:
      Dict mapping layer_idx to incremental state
  :param kwargs:
      any number of keyword (named) arguments to be passed to each layer
  
  :return (tensor, new_incr_state):
      return encoding after applying decoder layers, as well
      as new incremental decoding state.
docstr_tok: ["Forward","pass","of","decoder","layers",".",":","param","tensor",":","embedded","input","tensor","for","the","decoder",":","param","extra_args",":","any","number","of","positional","arguments","to","be","passed","to","each","layer",":","param","incr_state",":","Dict","mapping","layer_idx","to","incremental","state",":","param","kwargs",":","any","number","of","keyword","(","named",")","arguments","to","be","passed","to","each","layer",":","return","(","tensor",",","new_incr_state",")",":","return","encoding","after","applying","decoder","layers",",","as","well","as","new","incremental","decoding","state","."]
code: def forward_layers(
      self,
      tensor: torch.Tensor,
      *extra_args,
      incr_state: DecoderIncrState,
      **kwargs,
  ) -> Tuple[torch.Tensor, DecoderIncrState]:
      """
      Forward pass of decoder layers.
  
      :param tensor:
          embedded input tensor for the decoder
      :param extra_args:
          any number of positional arguments to be passed to each layer
      :param incr_state:
          Dict mapping layer_idx to incremental state
      :param kwargs:
          any number of keyword (named) arguments to be passed to each layer
  
      :return (tensor, new_incr_state):
          return encoding after applying decoder layers, as well
          as new incremental decoding state.
      """
      new_incr_state = {}
      if getattr(self.layers, "is_model_parallel", False):
          tensor, new_incr_state = self._apply_model_parallel(
              tensor, *extra_args, incr_state=incr_state
          )
      else:
          for idx, layer in enumerate(self.layers):
              tensor, new_incr_state[idx] = layer(
                  tensor,
                  *extra_args,
                  incr_state=incr_state.get(idx),
                  **kwargs,
              )
  
      return tensor, new_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 6 for calling the BaseTransformerDecoder obj's underlying member method code with example usage: obj.forward_layers(tensor) and returns: tensor,  new_incr_state