class_docstr: This class implements the self-attention decoder layer.
  Arguments
  ----------
  d_ffn : int
      Hidden size of self-attention Feed Forward layer.
  nhead : int
      Number of attention heads.
  d_model : int
      Dimension of the model.
  kdim : int
      Dimension for key (optional).
  vdim : int
      Dimension for value (optional).
  dropout : float
      Dropout for the decoder (optional).
  Example
  -------
  >>> src = torch.rand((8, 60, 512))
  >>> tgt = torch.rand((8, 60, 512))
  >>> net = TransformerDecoderLayer(1024, 8, d_model=512)
  >>> output, self_attn, multihead_attn = net(src, tgt)
  >>> output.shape
  torch.Size([8, 60, 512])
docstr: Arguments
  ----------
  tgt: tensor
      The sequence to the decoder layer (required).
  memory: tensor
      The sequence from the last layer of the encoder (required).
  tgt_mask: tensor
      The mask for the tgt sequence (optional).
  memory_mask: tensor
      The mask for the memory sequence (optional).
  tgt_key_padding_mask: tensor
      The mask for the tgt keys per batch (optional).
  memory_key_padding_mask: tensor
      The mask for the memory keys per batch (optional).
docstr_tok: ["Arguments","--","--","--","--","--","tgt",":","tensor","The","sequence","to","the","decoder","layer","(","required",")",".","memory",":","tensor","The","sequence","from","the","last","layer","of","the","encoder","(","required",")",".","tgt_mask",":","tensor","The","mask","for","the","tgt","sequence","(","optional",")",".","memory_mask",":","tensor","The","mask","for","the","memory","sequence","(","optional",")",".","tgt_key_padding_mask",":","tensor","The","mask","for","the","tgt","keys","per","batch","(","optional",")",".","memory_key_padding_mask",":","tensor","The","mask","for","the","memory","keys","per","batch","(","optional",")","."]
code: def forward(
      self,
      tgt,
      memory,
      tgt_mask=None,
      memory_mask=None,
      tgt_key_padding_mask=None,
      memory_key_padding_mask=None,
      pos_embs_tgt=None,
      pos_embs_src=None,
  ):
      """
      Arguments
      ----------
      tgt: tensor
          The sequence to the decoder layer (required).
      memory: tensor
          The sequence from the last layer of the encoder (required).
      tgt_mask: tensor
          The mask for the tgt sequence (optional).
      memory_mask: tensor
          The mask for the memory sequence (optional).
      tgt_key_padding_mask: tensor
          The mask for the tgt keys per batch (optional).
      memory_key_padding_mask: tensor
          The mask for the memory keys per batch (optional).
      """
      if self.normalize_before:
          tgt1 = self.norm1(tgt)
      else:
          tgt1 = tgt
  
      # self-attention over the target sequence
      tgt2, self_attn = self.self_attn(
          query=tgt1,
          key=tgt1,
          value=tgt1,
          attn_mask=tgt_mask,
          key_padding_mask=tgt_key_padding_mask,
          pos_embs=pos_embs_tgt,
      )
  
      # add & norm
      tgt = tgt + self.dropout1(tgt2)
      if not self.normalize_before:
          tgt = self.norm1(tgt)
  
      if self.normalize_before:
          tgt1 = self.norm2(tgt)
      else:
          tgt1 = tgt
  
      # multi-head attention over the target sequence and encoder states
  
      tgt2, multihead_attention = self.mutihead_attn(
          query=tgt1,
          key=memory,
          value=memory,
          attn_mask=memory_mask,
          key_padding_mask=memory_key_padding_mask,
          pos_embs=pos_embs_src,
      )
  
      # add & norm
      tgt = tgt + self.dropout2(tgt2)
      if not self.normalize_before:
          tgt = self.norm2(tgt)
  
      if self.normalize_before:
          tgt1 = self.norm3(tgt)
      else:
          tgt1 = tgt
  
      tgt2 = self.pos_ffn(tgt1)
  
      # add & norm
      tgt = tgt + self.dropout3(tgt2)
      if not self.normalize_before:
          tgt = self.norm3(tgt)
  
      return tgt, self_attn, multihead_attention
  
imports: import math
  import torch
  import torch.nn
  import speechbrain
  from typing import Optional
  import numpy
  from .Conformer import ConformerEncoder
  from .Branchformer import BranchformerEncoder
  from speechbrain.nnet.activations import Swish
  from speechbrain.nnet.attention import RelPosEncXL
  from speechbrain.nnet.CNN import Conv1d
label_desc: Use image node_id 2 for calling the TransformerDecoderLayer obj's underlying member method code with example usage: obj.forward(tgt, memory, tgt_mask, memory_mask, tgt_key_padding_mask, memory_key_padding_mask, pos_embs_tgt, pos_embs_src) and returns: tgt,  self_attn,  multihead_attention