class_docstr: This is an implementation of Conformer encoder layer.
  
  Arguments
  ----------
  d_model : int
      The expected size of the input embedding.
  d_ffn : int
      Hidden size of self-attention Feed Forward layer.
  nhead : int
      Number of attention heads.
  kernel_size : int, optional
      Kernel size of convolution model.
  kdim : int, optional
      Dimension of the key.
  vdim : int, optional
      Dimension of the value.
  activation: torch.nn.Module, optional
       Activation function used in each Conformer layer.
  bias : bool, optional
      Whether  convolution module.
  dropout : int, optional
      Dropout for the encoder.
  causal: bool, optional
      Whether the convolutions should be causal or not.
  attention_type: str, optional
      type of attention layer, e.g. regulaMHA for regular MultiHeadAttention.
  
  Example
  -------
  >>> import torch
  >>> x = torch.rand((8, 60, 512))
  >>> pos_embs = torch.rand((1, 2*60-1, 512))
  >>> net = ConformerEncoderLayer(d_ffn=512, nhead=8, d_model=512, kernel_size=3)
  >>> output = net(x, pos_embs=pos_embs)
  >>> output[0].shape
  torch.Size([8, 60, 512])
docstr: Arguments
  ----------
      tgt: torch.Tensor
          The sequence to the decoder layer.
      memory: torch.Tensor
          The sequence from the last layer of the encoder.
      tgt_mask: torch.Tensor, optional, optional
          The mask for the tgt sequence.
      memory_mask: torch.Tensor, optional
          The mask for the memory sequence.
      tgt_key_padding_mask : torch.Tensor, optional
          The mask for the tgt keys per batch.
      memory_key_padding_mask : torch.Tensor, optional
          The mask for the memory keys per batch.
      pos_emb_tgt: torch.Tensor, torch.nn.Module, optional
          Module or tensor containing the target sequence positional embeddings for each attention layer.
      pos_embs_src: torch.Tensor, torch.nn.Module, optional
          Module or tensor containing the source sequence positional embeddings for each attention layer.
docstr_tok: ["Arguments","--","--","--","--","--","tgt",":","torch.Tensor","The","sequence","to","the","decoder","layer",".","memory",":","torch.Tensor","The","sequence","from","the","last","layer","of","the","encoder",".","tgt_mask",":","torch.Tensor",",","optional",",","optional","The","mask","for","the","tgt","sequence",".","memory_mask",":","torch.Tensor",",","optional","The","mask","for","the","memory","sequence",".","tgt_key_padding_mask",":","torch.Tensor",",","optional","The","mask","for","the","tgt","keys","per","batch",".","memory_key_padding_mask",":","torch.Tensor",",","optional","The","mask","for","the","memory","keys","per","batch",".","pos_emb_tgt",":","torch.Tensor",",","torch.nn.Module",",","optional","Module","or","tensor","containing","the","target","sequence","positional","embeddings","for","each","attention","layer",".","pos_embs_src",":","torch.Tensor",",","torch.nn.Module",",","optional","Module","or","tensor","containing","the","source","sequence","positional","embeddings","for","each","attention","layer","."]
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: torch.Tensor
              The sequence to the decoder layer.
          memory: torch.Tensor
              The sequence from the last layer of the encoder.
          tgt_mask: torch.Tensor, optional, optional
              The mask for the tgt sequence.
          memory_mask: torch.Tensor, optional
              The mask for the memory sequence.
          tgt_key_padding_mask : torch.Tensor, optional
              The mask for the tgt keys per batch.
          memory_key_padding_mask : torch.Tensor, optional
              The mask for the memory keys per batch.
          pos_emb_tgt: torch.Tensor, torch.nn.Module, optional
              Module or tensor containing the target sequence positional embeddings for each attention layer.
          pos_embs_src: torch.Tensor, torch.nn.Module, optional
              Module or tensor containing the source sequence positional embeddings for each attention layer.
      """
      # ffn module
      tgt = tgt + 0.5 * self.ffn_module1(tgt)
      # muti-head attention module
      skip = tgt
      x = self.norm1(tgt)
      x, self_attn = self.mha_layer(
          x,
          memory,
          memory,
          attn_mask=memory_mask,
          key_padding_mask=memory_key_padding_mask,
          pos_embs=pos_embs_src,
      )
      x = x + skip
      # convolution module
      x = x + self.convolution_module(x)
      # ffn module
      x = self.norm2(x + 0.5 * self.ffn_module2(x))
      return x, self_attn, self_attn
  
imports: from dataclasses import dataclass
  import torch
  import torch.nn
  import torch.nn.functional
  from typing import Optional, List
  import speechbrain
  import warnings
  from speechbrain.nnet.attention import RelPosMHAXL, MultiheadAttention, PositionalwiseFeedForward
  from speechbrain.utils.dynamic_chunk_training import DynChunkTrainConfig
  from speechbrain.lobes.models.transformer.hypermixing import HyperMixing
  from speechbrain.nnet.normalization import LayerNorm
  from speechbrain.nnet.activations import Swish
label_desc: Use image node_id 2 for calling the ConformerDecoderLayer 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: x,  self_attn,  self_attn