class_docstr: This class implements the Conformer encoder.
  
  Arguments
  ---------
  num_layers : int
      Number of layers.
  d_model : int
      Embedding dimension size.
  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
       Activation function used in each Confomer 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_emb = torch.rand((1, 2*60-1, 512))
  >>> net = ConformerEncoder(1, 512, 512, 8)
  >>> output, _ = net(x, pos_embs=pos_emb)
  >>> output.shape
  torch.Size([8, 60, 512])
docstr: Arguments
  ----------
  src : torch.Tensor
      The sequence to the encoder layer.
  src_mask : torch.Tensor, optional
      The mask for the src sequence.
  src_key_padding_mask : torch.Tensor, optional
      The mask for the src keys per batch.
  pos_embs: torch.Tensor, torch.nn.Module,
      Module or tensor containing the input sequence positional embeddings
      If custom pos_embs are given it needs to have the shape (1, 2*S-1, E)
      where S is the sequence length, and E is the embedding dimension.
  dynchunktrain_config: Optional[DynChunkTrainConfig]
      Dynamic Chunk Training configuration object for streaming,
      specifically involved here to apply Dynamic Chunk Convolution to the
      convolution module.
docstr_tok: ["Arguments","--","--","--","--","--","src",":","torch.Tensor","The","sequence","to","the","encoder","layer",".","src_mask",":","torch.Tensor",",","optional","The","mask","for","the","src","sequence",".","src_key_padding_mask",":","torch.Tensor",",","optional","The","mask","for","the","src","keys","per","batch",".","pos_embs",":","torch.Tensor",",","torch.nn.Module",",","Module","or","tensor","containing","the","input","sequence","positional","embeddings","If","custom","pos_embs","are","given","it","needs","to","have","the","shape","(","1",",","2","*","S-1",",","E",")","where","S","is","the","sequence","length",",","and","E","is","the","embedding","dimension",".","dynchunktrain_config",":","Optional","[","DynChunkTrainConfig","]","Dynamic","Chunk","Training","configuration","object","for","streaming",",","specifically","involved","here","to","apply","Dynamic","Chunk","Convolution","to","the","convolution","module","."]
code: def forward(
      self,
      src,
      src_mask: Optional[torch.Tensor] = None,
      src_key_padding_mask: Optional[torch.Tensor] = None,
      pos_embs: Optional[torch.Tensor] = None,
      dynchunktrain_config: Optional[DynChunkTrainConfig] = None,
  ):
      """
      Arguments
      ----------
      src : torch.Tensor
          The sequence to the encoder layer.
      src_mask : torch.Tensor, optional
          The mask for the src sequence.
      src_key_padding_mask : torch.Tensor, optional
          The mask for the src keys per batch.
      pos_embs: torch.Tensor, torch.nn.Module,
          Module or tensor containing the input sequence positional embeddings
          If custom pos_embs are given it needs to have the shape (1, 2*S-1, E)
          where S is the sequence length, and E is the embedding dimension.
      dynchunktrain_config: Optional[DynChunkTrainConfig]
          Dynamic Chunk Training configuration object for streaming,
          specifically involved here to apply Dynamic Chunk Convolution to the
          convolution module.
      """
      if self.attention_type == "RelPosMHAXL":
          if pos_embs is None:
              raise ValueError(
                  "The chosen attention type for the Conformer is RelPosMHAXL. For this attention type, the positional embeddings are mandatory"
              )
  
      output = src
      attention_lst = []
      for enc_layer in self.layers:
          output, attention = enc_layer(
              output,
              src_mask=src_mask,
              src_key_padding_mask=src_key_padding_mask,
              pos_embs=pos_embs,
              dynchunktrain_config=dynchunktrain_config,
          )
          attention_lst.append(attention)
      output = self.norm(output)
  
      return output, attention_lst
  
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 ConformerEncoder obj's underlying member method code with example usage: obj.forward(src, src_mask, src_key_padding_mask, pos_embs, dynchunktrain_config) and returns: output,  attention_lst