class_docstr: Conformer layer that constitutes Conformer.
  
  Args:
      input_dim (int): input dimension.
      ffn_dim (int): hidden layer dimension of feedforward network.
      num_attention_heads (int): number of attention heads.
      depthwise_conv_kernel_size (int): kernel size of 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``)
class_docstr_tok: ["Conformer","layer","that","constitutes","Conformer",".","Args",":","input_dim","(","int",")",":","input","dimension",".","ffn_dim","(","int",")",":","hidden","layer","dimension","of","feedforward","network",".","num_attention_heads","(","int",")",":","number","of","attention","heads",".","depthwise_conv_kernel_size","(","int",")",":","kernel","size","of","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","``",")"]
docstr: Args:
      input (torch.Tensor): input, with shape `(T, B, D)`.
      key_padding_mask (torch.Tensor or None): key padding mask to use in self attention layer.
  
  Returns:
      torch.Tensor: output, with shape `(T, B, D)`.
docstr_tok: ["Args",":","input","(","torch.Tensor",")",":","input",",","with","shape","`","(","T",",","B",",","D",")","`",".","key_padding_mask","(","torch.Tensor","or","None",")",":","key","padding","mask","to","use","in","self","attention","layer",".","Returns",":","torch.Tensor",":","output",",","with","shape","`","(","T",",","B",",","D",")","`","."]
code: def forward(
      self,
      input: torch.Tensor,
      key_padding_mask: Optional[torch.Tensor],
  ) -> torch.Tensor:
      r"""
      Args:
          input (torch.Tensor): input, with shape `(T, B, D)`.
          key_padding_mask (torch.Tensor or None): key padding mask to use in self attention layer.
  
      Returns:
          torch.Tensor: output, with shape `(T, B, D)`.
      """
      residual = input
      x = self.ffn1(input)
      x = x * 0.5 + residual
  
      if self.convolution_first:
          x = self._apply_convolution(x)
  
      residual = x
      x = self.self_attn_layer_norm(x)
      x, _ = self.self_attn(
          query=x,
          key=x,
          value=x,
          key_padding_mask=key_padding_mask,
          need_weights=False,
      )
      x = self.self_attn_dropout(x)
      x = x + residual
  
      if not self.convolution_first:
          x = self._apply_convolution(x)
  
      residual = x
      x = self.ffn2(x)
      x = x * 0.5 + residual
  
      x = self.final_layer_norm(x)
      return x
  
imports: from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 3 for calling the ConformerLayer obj's underlying member method code with example usage: obj.forward(input, key_padding_mask) and returns: x