class_docstr: Conformer architecture introduced in
  *Conformer: Convolution-augmented Transformer for Speech Recognition*
  :cite:`gulati2020conformer`.
  
  Args:
      input_dim (int): input dimension.
      num_heads (int): number of attention heads in each Conformer layer.
      ffn_dim (int): hidden layer dimension of feedforward networks.
      num_layers (int): number of Conformer layers to instantiate.
      depthwise_conv_kernel_size (int): kernel size of each Conformer layer's depthwise convolution layer.
      dropout (float, optional): dropout probability. (Default: 0.0)
      use_group_norm (bool, optional): use ``GroupNorm`` rather than ``BatchNorm1d``
          in the convolution module. (Default: ``False``)
      convolution_first (bool, optional): apply the convolution module ahead of
          the attention module. (Default: ``False``)
  
  Examples:
      >>> conformer = Conformer(
      >>>     input_dim=80,
      >>>     num_heads=4,
      >>>     ffn_dim=128,
      >>>     num_layers=4,
      >>>     depthwise_conv_kernel_size=31,
      >>> )
      >>> lengths = torch.randint(1, 400, (10,))  # (batch,)
      >>> input = torch.rand(10, int(lengths.max()), input_dim)  # (batch, num_frames, input_dim)
      >>> output = conformer(input, lengths)
class_docstr_tok: ["Conformer","architecture","introduced","in","*","Conformer",":","Convolution-augmented","Transformer","for","Speech","Recognition","*",":","cite",":","`","gulati2020conformer","`",".","Args",":","input_dim","(","int",")",":","input","dimension",".","num_heads","(","int",")",":","number","of","attention","heads","in","each","Conformer","layer",".","ffn_dim","(","int",")",":","hidden","layer","dimension","of","feedforward","networks",".","num_layers","(","int",")",":","number","of","Conformer","layers","to","instantiate",".","depthwise_conv_kernel_size","(","int",")",":","kernel","size","of","each","Conformer","layer","'s","depthwise","convolution","layer",".","dropout","(","float",",","optional",")",":","dropout","probability",".","(","Default",":","0.0",")","use_group_norm","(","bool",",","optional",")",":","use","``","GroupNorm","``","rather","than","``","BatchNorm1d","``","in","the","convolution","module",".","(","Default",":","``","False","``",")","convolution_first","(","bool",",","optional",")",":","apply","the","convolution","module","ahead","of","the","attention","module",".","(","Default",":","``","False","``",")","Examples",":",">",">",">","conformer","=","Conformer","(",">",">",">","input_dim=80",",",">",">",">","num_heads=4",",",">",">",">","ffn_dim=128",",",">",">",">","num_layers=4",",",">",">",">","depthwise_conv_kernel_size=31",",",">",">",">",")",">",">",">","lengths","=","torch.randint","(","1",",","400",",","(","10",",",")",")","#","(","batch",",",")",">",">",">","input","=","torch.rand","(","10",",","int","(","lengths.max","(",")",")",",","input_dim",")","#","(","batch",",","num_frames",",","input_dim",")",">",">",">","output","=","conformer","(","input",",","lengths",")"]
docstr: Args:
      input (torch.Tensor): with shape `(B, T, input_dim)`.
      lengths (torch.Tensor): with shape `(B,)` and i-th element representing
          number of valid frames for i-th batch element in ``input``.
  
  Returns:
      (torch.Tensor, torch.Tensor)
          torch.Tensor
              output frames, with shape `(B, T, input_dim)`
          torch.Tensor
              output lengths, with shape `(B,)` and i-th element representing
              number of valid frames for i-th batch element in output frames.
docstr_tok: ["Args",":","input","(","torch.Tensor",")",":","with","shape","`","(","B",",","T",",","input_dim",")","`",".","lengths","(","torch.Tensor",")",":","with","shape","`","(","B",",",")","`","and","i-th","element","representing","number","of","valid","frames","for","i-th","batch","element","in","``","input","``",".","Returns",":","(","torch.Tensor",",","torch.Tensor",")","torch.Tensor","output","frames",",","with","shape","`","(","B",",","T",",","input_dim",")","`","torch.Tensor","output","lengths",",","with","shape","`","(","B",",",")","`","and","i-th","element","representing","number","of","valid","frames","for","i-th","batch","element","in","output","frames","."]
code: def forward(
      self, input: torch.Tensor, lengths: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      r"""
      Args:
          input (torch.Tensor): with shape `(B, T, input_dim)`.
          lengths (torch.Tensor): with shape `(B,)` and i-th element representing
              number of valid frames for i-th batch element in ``input``.
  
      Returns:
          (torch.Tensor, torch.Tensor)
              torch.Tensor
                  output frames, with shape `(B, T, input_dim)`
              torch.Tensor
                  output lengths, with shape `(B,)` and i-th element representing
                  number of valid frames for i-th batch element in output frames.
      """
      encoder_padding_mask = _lengths_to_padding_mask(lengths)
  
      x = input.transpose(0, 1)
      for layer in self.conformer_layers:
          x = layer(x, encoder_padding_mask)
      return x.transpose(0, 1), lengths
  
imports: from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 2 for calling the Conformer obj's underlying member method code with example usage: obj.forward(input, lengths) and returns: x,  lengths