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 inference.
  
  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)`.
      state (List[torch.Tensor] or None): list of tensors representing layer internal state
          generated in preceding invocation of ``infer``.
      mems (torch.Tensor): memory elements, with shape `(M, B, D)`.
  
  Returns:
      (Tensor, Tensor, List[torch.Tensor], Tensor):
          Tensor
              encoded utterance frames, with shape `(T, B, D)`.
          Tensor
              updated right context frames, with shape `(R, B, D)`.
          List[Tensor]
              list of tensors representing layer internal state
              generated in current invocation of ``infer``.
          Tensor
              updated memory elements, with shape `(M, B, D)`.
docstr_tok: ["Forward","pass","for","inference",".","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",")","`",".","state","(","List","[","torch.Tensor","]","or","None",")",":","list","of","tensors","representing","layer","internal","state","generated","in","preceding","invocation","of","``","infer","``",".","mems","(","torch.Tensor",")",":","memory","elements",",","with","shape","`","(","M",",","B",",","D",")","`",".","Returns",":","(","Tensor",",","Tensor",",","List","[","torch.Tensor","]",",","Tensor",")",":","Tensor","encoded","utterance","frames",",","with","shape","`","(","T",",","B",",","D",")","`",".","Tensor","updated","right","context","frames",",","with","shape","`","(","R",",","B",",","D",")","`",".","List","[","Tensor","]","list","of","tensors","representing","layer","internal","state","generated","in","current","invocation","of","``","infer","``",".","Tensor","updated","memory","elements",",","with","shape","`","(","M",",","B",",","D",")","`","."]
code: def infer(
      self,
      utterance: torch.Tensor,
      lengths: torch.Tensor,
      right_context: torch.Tensor,
      state: Optional[List[torch.Tensor]],
      mems: torch.Tensor,
  ) -> Tuple[
      torch.Tensor, torch.Tensor, List[torch.Tensor], torch.Tensor
  ]:
      r"""Forward pass for inference.
  
      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)`.
          state (List[torch.Tensor] or None): list of tensors representing layer internal state
              generated in preceding invocation of ``infer``.
          mems (torch.Tensor): memory elements, with shape `(M, B, D)`.
  
      Returns:
          (Tensor, Tensor, List[torch.Tensor], Tensor):
              Tensor
                  encoded utterance frames, with shape `(T, B, D)`.
              Tensor
                  updated right context frames, with shape `(R, B, D)`.
              List[Tensor]
                  list of tensors representing layer internal state
                  generated in current invocation of ``infer``.
              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
          )[: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)
  
      if state is None:
          state = self._init_state(
              layer_norm_input_utterance.size(1),
              device=layer_norm_input_utterance.device,
          )
      pre_mems, lc_key, lc_val, conv_cache = self._unpack_state(state)
  
      rc_output, next_m, next_k, next_v = self.attention.infer(
          utterance=layer_norm_input_utterance,
          lengths=lengths,
          right_context=layer_norm_input_right_context,
          summary=layer_norm_input_summary,
          mems=pre_mems,
          left_context_key=lc_key,
          left_context_val=lc_val,
      )
  
      (
          output_utterance,
          output_right_context,
          conv_cache,
      ) = self._apply_post_attention(
          rc_output,
          ffn0_out,
          conv_cache,
          right_context.size(0),
          utterance.size(0),
      )
      output_state = self._pack_state(
          next_k, next_v, utterance.size(0), mems, conv_cache, state
      )
      return (
          output_utterance,
          output_right_context,
          output_state,
          next_m,
      )
  
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 8 for calling the _ConvEmformerLayer obj's underlying member method code with example usage: obj.infer(utterance, lengths, right_context, state, mems) and returns: output_utterance,  output_right_context,  output_state,  next_m