class_docstr: E-Branchformer encoder layer module.
  
  Args:
      size (int): model dimension
      attn: standard self-attention or efficient attention
      cgmlp: ConvolutionalGatingMLP
      feed_forward: feed-forward module, optional
      feed_forward: macaron-style feed-forward module, optional
      dropout_rate (float): dropout probability
      merge_conv_kernel (int): kernel size of the depth-wise conv in merge module
class_docstr_tok: ["E-Branchformer","encoder","layer","module",".","Args",":","size","(","int",")",":","model","dimension","attn",":","standard","self-attention","or","efficient","attention","cgmlp",":","ConvolutionalGatingMLP","feed_forward",":","feed-forward","module",",","optional","feed_forward",":","macaron-style","feed-forward","module",",","optional","dropout_rate","(","float",")",":","dropout","probability","merge_conv_kernel","(","int",")",":","kernel","size","of","the","depth-wise","conv","in","merge","module"]
code: def __init__(
      self,
      size: int,
      attn: torch.nn.Module,
      cgmlp: torch.nn.Module,
      feed_forward: Optional[torch.nn.Module],
      feed_forward_macaron: Optional[torch.nn.Module],
      dropout_rate: float,
      merge_conv_kernel: int = 3,
  ):
      super().__init__()
  
      self.size = size
      self.attn = attn
      self.cgmlp = cgmlp
  
      self.feed_forward = feed_forward
      self.feed_forward_macaron = feed_forward_macaron
      self.ff_scale = 1.0
      if self.feed_forward is not None:
          self.norm_ff = LayerNorm(size)
      if self.feed_forward_macaron is not None:
          self.ff_scale = 0.5
          self.norm_ff_macaron = LayerNorm(size)
  
      self.norm_mha = LayerNorm(size)  # for the MHA module
      self.norm_mlp = LayerNorm(size)  # for the MLP module
      self.norm_final = LayerNorm(
          size
      )  # for the final output of the block
  
      self.dropout = torch.nn.Dropout(dropout_rate)
  
      self.depthwise_conv_fusion = torch.nn.Conv1d(
          size + size,
          size + size,
          kernel_size=merge_conv_kernel,
          stride=1,
          padding=(merge_conv_kernel - 1) // 2,
          groups=size + size,
          bias=True,
      )
      self.merge_proj = torch.nn.Linear(size + size, size)
  
imports: import logging
  from typing import List, Optional, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.ctc import CTC
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.layers.cgmlp import ConvolutionalGatingMLP
  from espnet2.asr.layers.fastformer import FastSelfAttention
  from espnet.nets.pytorch_backend.nets_utils import get_activation, make_pad_mask
  from espnet.nets.pytorch_backend.transformer.attention import LegacyRelPositionMultiHeadedAttention, MultiHeadedAttention, RelPositionMultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.embedding import LegacyRelPositionalEncoding, PositionalEncoding, RelPositionalEncoding, ScaledPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
  from espnet.nets.pytorch_backend.transformer.subsampling import Conv1dSubsampling1, Conv1dSubsampling2, Conv1dSubsampling3, Conv2dSubsampling, Conv2dSubsampling1, Conv2dSubsampling2, Conv2dSubsampling6, Conv2dSubsampling8, TooShortUttError, check_short_utt
label_desc: Use image node_id 1 to create a new EBranchformerEncoderLayer object from inherited base classes: torch.nn with example: obj = EBranchformerEncoderLayer(size, attn, cgmlp, feed_forward, feed_forward_macaron, dropout_rate, merge_conv_kernel)