class_docstr: Convolution-augmented Emformer layer that constitutes ConvEmformer.
  
  Args:
      input_dim (int): input dimension.
      num_heads (int): number of attention heads.
      ffn_dim: (int): hidden layer dimension of feedforward network.
      segment_length (int): length of each input segment.
      kernel_size (int): size of kernel to use in convolution module.
      dropout (float, optional): dropout probability. (Default: 0.0)
      ffn_activation (str, optional): activation function to use in feedforward network.
          Must be one of ("relu", "gelu", "silu"). (Default: "relu")
      left_context_length (int, optional): length of left context. (Default: 0)
      right_context_length (int, optional): length of right context. (Default: 0)
      max_memory_size (int, optional): maximum number of memory elements to use. (Default: 0)
      weight_init_gain (float or None, optional): scale factor to apply when initializing
          attention module parameters. (Default: ``None``)
      tanh_on_mem (bool, optional): if ``True``, applies tanh to memory elements. (Default: ``False``)
      negative_inf (float, optional): value to use for negative infinity in attention weights. (Default: -1e8)
      conv_activation (str, optional): activation function to use in convolution module.
          Must be one of ("relu", "gelu", "silu"). (Default: "silu")
docstr: Forward pass for training.
  
  B: batch size;
  D: feature dimension of each frame;
  T: number of utterance frames;
  R: number of right context frames;
  M: number of memory elements.
  
  Args:
      utterance (torch.Tensor): utterance frames, with shape `(T, B, D)`.
      lengths (torch.Tensor): with shape `(B,)` and i-th element representing
          number of valid frames for i-th batch element in ``utterance``.
      right_context (torch.Tensor): right context frames, with shape `(R, B, D)`.
      mems (torch.Tensor): memory elements, with shape `(M, B, D)`.
      attention_mask (torch.Tensor): attention mask for underlying attention module.
  
  Returns:
      (Tensor, Tensor, Tensor):
          Tensor
              encoded utterance frames, with shape `(T, B, D)`.
          Tensor
              updated right context frames, with shape `(R, B, D)`.
          Tensor
              updated memory elements, with shape `(M, B, D)`.
docstr_tok: ["Forward","pass","for","training",".","B",":","batch","size",";","D",":","feature","dimension","of","each","frame",";","T",":","number","of","utterance","frames",";","R",":","number","of","right","context","frames",";","M",":","number","of","memory","elements",".","Args",":","utterance","(","torch.Tensor",")",":","utterance","frames",",","with","shape","`","(","T",",","B",",","D",")","`",".","lengths","(","torch.Tensor",")",":","with","shape","`","(","B",",",")","`","and","i-th","element","representing","number","of","valid","frames","for","i-th","batch","element","in","``","utterance","``",".","right_context","(","torch.Tensor",")",":","right","context","frames",",","with","shape","`","(","R",",","B",",","D",")","`",".","mems","(","torch.Tensor",")",":","memory","elements",",","with","shape","`","(","M",",","B",",","D",")","`",".","attention_mask","(","torch.Tensor",")",":","attention","mask","for","underlying","attention","module",".","Returns",":","(","Tensor",",","Tensor",",","Tensor",")",":","Tensor","encoded","utterance","frames",",","with","shape","`","(","T",",","B",",","D",")","`",".","Tensor","updated","right","context","frames",",","with","shape","`","(","R",",","B",",","D",")","`",".","Tensor","updated","memory","elements",",","with","shape","`","(","M",",","B",",","D",")","`","."]
code: def forward(
      self,
      utterance: torch.Tensor,
      lengths: torch.Tensor,
      right_context: torch.Tensor,
      mems: torch.Tensor,
      attention_mask: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
      r"""Forward pass for training.
  
      B: batch size;
      D: feature dimension of each frame;
      T: number of utterance frames;
      R: number of right context frames;
      M: number of memory elements.
  
      Args:
          utterance (torch.Tensor): utterance frames, with shape `(T, B, D)`.
          lengths (torch.Tensor): with shape `(B,)` and i-th element representing
              number of valid frames for i-th batch element in ``utterance``.
          right_context (torch.Tensor): right context frames, with shape `(R, B, D)`.
          mems (torch.Tensor): memory elements, with shape `(M, B, D)`.
          attention_mask (torch.Tensor): attention mask for underlying attention module.
  
      Returns:
          (Tensor, Tensor, Tensor):
              Tensor
                  encoded utterance frames, with shape `(T, B, D)`.
              Tensor
                  updated right context frames, with shape `(R, B, D)`.
              Tensor
                  updated memory elements, with shape `(M, B, D)`.
      """
      if self.use_mem:
          summary = self.memory_op(utterance.permute(1, 2, 0)).permute(
              2, 0, 1
          )
      else:
          summary = torch.empty(0).to(
              dtype=utterance.dtype, device=utterance.device
          )
  
      (
          ffn0_out,
          layer_norm_input_right_context,
          layer_norm_input_utterance,
          layer_norm_input_summary,
      ) = self._apply_pre_attention(utterance, right_context, summary)
  
      rc_output, output_mems = self.attention(
          utterance=layer_norm_input_utterance,
          lengths=lengths,
          right_context=layer_norm_input_right_context,
          summary=layer_norm_input_summary,
          mems=mems,
          attention_mask=attention_mask,
      )
  
      (
          output_utterance,
          output_right_context,
          _,
      ) = self._apply_post_attention(
          rc_output,
          ffn0_out,
          None,
          right_context.size(0),
          utterance.size(0),
      )
  
      return output_utterance, output_right_context, output_mems
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
  from torchaudio.models.emformer import _EmformerAttention, _EmformerImpl, _get_weight_init_gains
label_desc: Use image node_id 7 for calling the _ConvEmformerLayer obj's underlying member method code with example usage: obj.forward(utterance, lengths, right_context, mems, attention_mask) and returns: output_utterance,  output_right_context,  output_mems