class_docstr: Represents a Transformer decoder layer.
class_docstr_tok: ["Represents","a","Transformer","decoder","layer","."]
docstr: :param seqs:
      The sequences to process. *Shape:* :math:`(N,S,M)`, where :math:`N`
      is the batch size, :math:`S` is the sequence length, and :math:`M`
      is the dimensionality of the model.
  :param padding_mask:
      The padding mask of ``seqs``. *Shape:* :math:`(N,S)`, where :math:`N`
      is the batch size and :math:`S` is the sequence length.
  :param self_attn_mask:
      The mask that will be added to attention weights before computing
      the self attention. *Shape:* :math:`([H],S,S)`, where :math:`H` is
      the number of attention heads and :math:`S` is the sequence length.
  :param encoder_output:
      The encoder output to use in encoder-decoder attention. *Shape:*
      :math:`(N,S_{enc},M_{enc})`, where :math:`N` is the batch size,
      :math:`S_{enc}` is the encoder output sequence length, and
      :math:`M_{enc}` is the dimensionality of the encoder.
  :param encoder_padding_mask:
      The padding mask of ``encoder_output``. *Shape:* :math:`(N,S_{enc})`,
      where :math:`N` is the batch size and :math:`S_{enc}` is the encoder
      output sequence length.
  :param state_bag:
      The state bag to use for incremental decoding.
  
  :returns:
      - The decoder layer output. *Shape:* Same as ``seqs``.
      - The padding mask of the decoder layer output. *Shape:* Same as
        ``padding_mask``.
docstr_tok: [":","param","seqs",":","The","sequences","to","process",".","*","Shape",":","*",":","math",":","`","(","N",",","S",",","M",")","`",",","where",":","math",":","`","N","`","is","the","batch","size",",",":","math",":","`","S","`","is","the","sequence","length",",","and",":","math",":","`","M","`","is","the","dimensionality","of","the","model",".",":","param","padding_mask",":","The","padding","mask","of","``","seqs","``",".","*","Shape",":","*",":","math",":","`","(","N",",","S",")","`",",","where",":","math",":","`","N","`","is","the","batch","size","and",":","math",":","`","S","`","is","the","sequence","length",".",":","param","self_attn_mask",":","The","mask","that","will","be","added","to","attention","weights","before","computing","the","self","attention",".","*","Shape",":","*",":","math",":","`","(","[","H","]",",","S",",","S",")","`",",","where",":","math",":","`","H","`","is","the","number","of","attention","heads","and",":","math",":","`","S","`","is","the","sequence","length",".",":","param","encoder_output",":","The","encoder","output","to","use","in","encoder-decoder","attention",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","enc","}",",","M_","{","enc","}",")","`",",","where",":","math",":","`","N","`","is","the","batch","size",",",":","math",":","`","S_","{","enc","}","`","is","the","encoder","output","sequence","length",",","and",":","math",":","`","M_","{","enc","}","`","is","the","dimensionality","of","the","encoder",".",":","param","encoder_padding_mask",":","The","padding","mask","of","``","encoder_output","``",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","enc","}",")","`",",","where",":","math",":","`","N","`","is","the","batch","size","and",":","math",":","`","S_","{","enc","}","`","is","the","encoder","output","sequence","length",".",":","param","state_bag",":","The","state","bag","to","use","for","incremental","decoding",".",":","returns",":","-","The","decoder","layer","output",".","*","Shape",":","*","Same","as","``","seqs","``",".","-","The","padding","mask","of","the","decoder","layer","output",".","*","Shape",":","*","Same","as","``","padding_mask","``","."]
code: def forward(
      self,
      seqs: Tensor,
      padding_mask: Optional[PaddingMask],
      self_attn_mask: Optional[AttentionMask] = None,
      encoder_output: Optional[Tensor] = None,
      encoder_padding_mask: Optional[PaddingMask] = None,
      *,
      state_bag: Optional[IncrementalStateBag] = None,
  ) -> Tuple[Tensor, Optional[PaddingMask]]:
      """
      :param seqs:
          The sequences to process. *Shape:* :math:`(N,S,M)`, where :math:`N`
          is the batch size, :math:`S` is the sequence length, and :math:`M`
          is the dimensionality of the model.
      :param padding_mask:
          The padding mask of ``seqs``. *Shape:* :math:`(N,S)`, where :math:`N`
          is the batch size and :math:`S` is the sequence length.
      :param self_attn_mask:
          The mask that will be added to attention weights before computing
          the self attention. *Shape:* :math:`([H],S,S)`, where :math:`H` is
          the number of attention heads and :math:`S` is the sequence length.
      :param encoder_output:
          The encoder output to use in encoder-decoder attention. *Shape:*
          :math:`(N,S_{enc},M_{enc})`, where :math:`N` is the batch size,
          :math:`S_{enc}` is the encoder output sequence length, and
          :math:`M_{enc}` is the dimensionality of the encoder.
      :param encoder_padding_mask:
          The padding mask of ``encoder_output``. *Shape:* :math:`(N,S_{enc})`,
          where :math:`N` is the batch size and :math:`S_{enc}` is the encoder
          output sequence length.
      :param state_bag:
          The state bag to use for incremental decoding.
  
      :returns:
          - The decoder layer output. *Shape:* Same as ``seqs``.
          - The padding mask of the decoder layer output. *Shape:* Same as
            ``padding_mask``.
      """
  
imports: from abc import ABC, abstractmethod
  from typing import Optional, Tuple, cast, final
  import torch
  import torch.nn
  from torch import Tensor
  from torch.nn import Dropout, Module
  from torch.nn.parameter import Parameter
  from fairseq2.nn.incremental_state import IncrementalStateBag
  from fairseq2.nn.normalization import LayerNorm
  from fairseq2.nn.padding import PaddingMask
  from fairseq2.nn.transformer.attention_mask import AttentionMask
  from fairseq2.nn.transformer.ffn import FeedForwardNetwork
  from fairseq2.nn.transformer.layer_norm import LayerNormFactory, create_standard_layer_norm
  from fairseq2.nn.transformer.multihead_attention import MultiheadAttention
  from fairseq2.nn.transformer.norm_order import TransformerNormOrder
  from fairseq2.typing import DataType, Device, finaloverride
label_desc: Use image node_id 2 for calling the TransformerDecoderLayer obj's underlying member method code with example usage: obj.forward(seqs, padding_mask, _attn_mask, encoder_output, encoder_padding_mask) without return types