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"]
docstr: Compute encoded features.
  
  Args:
      x_input (Union[Tuple, torch.Tensor]): Input tensor w/ or w/o pos emb.
          - w/ pos emb: Tuple of tensors [(#batch, time, size), (1, time, size)].
          - w/o pos emb: Tensor (#batch, time, size).
      mask (torch.Tensor): Mask tensor for the input (#batch, 1, time).
      cache (torch.Tensor): Cache tensor of the input (#batch, time - 1, size).
  Returns:
      torch.Tensor: Output tensor (#batch, time, size).
      torch.Tensor: Mask tensor (#batch, time).
docstr_tok: ["Compute","encoded","features",".","Args",":","x_input","(","Union","[","Tuple",",","torch.Tensor","]",")",":","Input","tensor","w\/","or","w\/o","pos","emb",".","-","w\/","pos","emb",":","Tuple","of","tensors","[","(","#","batch",",","time",",","size",")",",","(","1",",","time",",","size",")","]",".","-","w\/o","pos","emb",":","Tensor","(","#","batch",",","time",",","size",")",".","mask","(","torch.Tensor",")",":","Mask","tensor","for","the","input","(","#","batch",",","1",",","time",")",".","cache","(","torch.Tensor",")",":","Cache","tensor","of","the","input","(","#","batch",",","time","-","1",",","size",")",".","Returns",":","torch.Tensor",":","Output","tensor","(","#","batch",",","time",",","size",")",".","torch.Tensor",":","Mask","tensor","(","#","batch",",","time",")","."]
code: def forward(self, x_input, mask, cache=None):
      """Compute encoded features.
  
      Args:
          x_input (Union[Tuple, torch.Tensor]): Input tensor w/ or w/o pos emb.
              - w/ pos emb: Tuple of tensors [(#batch, time, size), (1, time, size)].
              - w/o pos emb: Tensor (#batch, time, size).
          mask (torch.Tensor): Mask tensor for the input (#batch, 1, time).
          cache (torch.Tensor): Cache tensor of the input (#batch, time - 1, size).
      Returns:
          torch.Tensor: Output tensor (#batch, time, size).
          torch.Tensor: Mask tensor (#batch, time).
      """
  
      if cache is not None:
          raise NotImplementedError(
              "cache is not None, which is not tested"
          )
  
      if isinstance(x_input, tuple):
          x, pos_emb = x_input[0], x_input[1]
      else:
          x, pos_emb = x_input, None
  
      if self.feed_forward_macaron is not None:
          residual = x
          x = self.norm_ff_macaron(x)
          x = residual + self.ff_scale * self.dropout(
              self.feed_forward_macaron(x)
          )
  
      # Two branches
      x1 = x
      x2 = x
  
      # Branch 1: multi-headed attention module
      x1 = self.norm_mha(x1)
  
      if isinstance(self.attn, FastSelfAttention):
          x_att = self.attn(x1, mask)
      else:
          if pos_emb is not None:
              x_att = self.attn(x1, x1, x1, pos_emb, mask)
          else:
              x_att = self.attn(x1, x1, x1, mask)
  
      x1 = self.dropout(x_att)
  
      # Branch 2: convolutional gating mlp
      x2 = self.norm_mlp(x2)
  
      if pos_emb is not None:
          x2 = (x2, pos_emb)
      x2 = self.cgmlp(x2, mask)
      if isinstance(x2, tuple):
          x2 = x2[0]
  
      x2 = self.dropout(x2)
  
      # Merge two branches
      x_concat = torch.cat([x1, x2], dim=-1)
      x_tmp = x_concat.transpose(1, 2)
      x_tmp = self.depthwise_conv_fusion(x_tmp)
      x_tmp = x_tmp.transpose(1, 2)
      x = x + self.dropout(self.merge_proj(x_concat + x_tmp))
  
      if self.feed_forward is not None:
          # feed forward module
          residual = x
          x = self.norm_ff(x)
          x = residual + self.ff_scale * self.dropout(
              self.feed_forward(x)
          )
  
      x = self.norm_final(x)
  
      if pos_emb is not None:
          return (x, pos_emb), mask
  
      return x, mask
  
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 2 for calling the EBranchformerEncoderLayer obj's underlying member method code with example usage: obj.forward(x_input, mask, cache) and returns: x,  mask, x,  pos_emb,  mask