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: Pipeline application of model parallelism.
docstr_tok: ["Pipeline","application","of","model","parallelism","."]
code: def _apply_model_parallel(
      self,
      tensor: torch.Tensor,
      *extra_args,
      incr_state: DecoderIncrState,
  ) -> Tuple[torch.Tensor, DecoderIncrState]:
      """
      Pipeline application of model parallelism.
      """
      chunks = PipelineHelper.split((tensor, *extra_args, incr_state))
      work_items = PipelineHelper.schedule_work_items(
          self.layers, chunks
      )
  
      new_incr_state = {i: [] for i, _ in enumerate(self.layers)}
  
      for chunk_idx, layer_nos, next_device in work_items:
          s_tensor, *s_extra_args, s_incr_state = chunks[chunk_idx]
          for layer_no in layer_nos:
              s_tensor, nis = self.layers[layer_no](
                  s_tensor,
                  *s_extra_args,
                  incr_state=s_incr_state.get(layer_no),
              )
              new_incr_state[layer_no].append(nis)
          # don't move incr state, it's always on the correct device
          s_layer_args = PipelineHelper.chunk_to(
              (s_tensor, *s_extra_args), next_device
          )
          chunks[chunk_idx] = (*s_layer_args, s_incr_state)
  
      tensor_out = PipelineHelper.join([c[0] for c in chunks])
      new_incr_state = {
          layer_no: PipelineHelper.join(pieces)
          for layer_no, pieces in new_incr_state.items()
      }
  
      return tensor_out, 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 7 for calling the BaseTransformerDecoder obj's underlying member method code with example usage: obj._apply_model_parallel(tensor) and returns: tensor_out,  new_incr_state