class_docstr: Transformer Decoder only layer block in GPT style.
  Args:
       See TransformerDecoderLayerBase
class_docstr_tok: ["Transformer","Decoder","only","layer","block","in","GPT","style",".","Args",":","See","TransformerDecoderLayerBase"]
docstr: A naive forward pass for transformer decoder.
  
  # T: could be 1 in the case of stepwise decoding or tgt_len
  
  Args:
      layer_in (FloatTensor): ``(batch_size, T, model_dim)``
      tgt_pad_mask (bool): ``(batch_size, 1, T)``
      layer_cache (dict or None): cached layer info when stepwise decode
      step (int or None): stepwise decoding counter
      future (bool): If set True, do not apply future_mask.
      return_attn (bool): If set True return attn
  
  Returns:
      (FloatTensor, FloatTensor):
  
      * layer_out ``(batch_size, T, model_dim)``
      * attns ``(batch_size, head, T, T)``
docstr_tok: ["A","naive","forward","pass","for","transformer","decoder",".","#","T",":","could","be","1","in","the","case","of","stepwise","decoding","or","tgt_len","Args",":","layer_in","(","FloatTensor",")",":","``","(","batch_size",",","T",",","model_dim",")","``","tgt_pad_mask","(","bool",")",":","``","(","batch_size",",","1",",","T",")","``","layer_cache","(","dict","or","None",")",":","cached","layer","info","when","stepwise","decode","step","(","int","or","None",")",":","stepwise","decoding","counter","future","(","bool",")",":","If","set","True",",","do","not","apply","future_mask",".","return_attn","(","bool",")",":","If","set","True","return","attn","Returns",":","(","FloatTensor",",","FloatTensor",")",":","*","layer_out","``","(","batch_size",",","T",",","model_dim",")","``","*","attns","``","(","batch_size",",","head",",","T",",","T",")","``"]
code: def _forward(
      self,
      layer_in,
      tgt_pad_mask,
      step=None,
      future=False,
      return_attn=False,
  ):
      """A naive forward pass for transformer decoder.
  
      # T: could be 1 in the case of stepwise decoding or tgt_len
  
      Args:
          layer_in (FloatTensor): ``(batch_size, T, model_dim)``
          tgt_pad_mask (bool): ``(batch_size, 1, T)``
          layer_cache (dict or None): cached layer info when stepwise decode
          step (int or None): stepwise decoding counter
          future (bool): If set True, do not apply future_mask.
          return_attn (bool): If set True return attn
  
      Returns:
          (FloatTensor, FloatTensor):
  
          * layer_out ``(batch_size, T, model_dim)``
          * attns ``(batch_size, head, T, T)``
  
      """
      dec_mask = None
  
      if layer_in.size(1) > 1:
          # Masking is necessary when sequence length is greater than one
          # The decoding has not started yet,
          # we compute the scores on the source tokens in one shot.
          dec_mask = self._compute_dec_mask(tgt_pad_mask, future)
          dec_mask = dec_mask.unsqueeze(1)
          dec_mask = dec_mask.expand(-1, -1, dec_mask.size(3), -1)
          # mask now are (batch x 1 x tlen x tlen)
          # 1 = heads to be expanded in MHA
  
      norm_layer_in = self.layer_norm_1(layer_in)
  
      attn_output, attns = self._forward_self_attn(
          norm_layer_in, dec_mask, step, return_attn=return_attn
      )
      if self.dropout_p > 0:
          attn_output = self.dropout(attn_output)
      if self.parallel_residual:
          # feed_forward applies residual, so we remove and apply residual with un-normed
          if not self.shared_layer_norm:
              norm_res_layer_in = self.layer_norm_res(layer_in)
              ff_in = norm_res_layer_in
          else:
              ff_in = norm_layer_in
          layer_out = (
              self.feed_forward(ff_in) - ff_in + layer_in + attn_output
          )
      else:
          layer_out = attn_output + layer_in
          layer_out = self.feed_forward(layer_out)
  
      return layer_out, attns
  
imports: import torch
  import torch.nn
  from onmt.decoders.decoder import DecoderBase
  from onmt.modules import MultiHeadedAttention, AverageAttention
  from onmt.modules.position_ffn import PositionwiseFeedForward
  from onmt.modules.position_ffn import ActivationFunction
  from onmt.modules.moe import MoE
  from onmt.utils.misc import sequence_mask
  from onmt.modules.rmsnorm import RMSNorm
label_desc: Use image node_id 1 for calling the TransformerLMDecoderLayer obj's underlying member method code with example usage: obj._forward(layer_in, tgt_pad_mask, step, future, return_attn) and returns: layer_out,  attns