class_docstr: Convolutional Spatial Gating Unit module definition.
  
  Args:
      size: Initial size to determine the number of channels.
      kernel_size: Size of the convolving kernel.
      norm_class: Normalization module class.
      norm_args: Normalization module arguments.
      dropout_rate: Dropout rate.
      causal: Whether to use causal convolution (set to True if streaming).
class_docstr_tok: ["Convolutional","Spatial","Gating","Unit","module","definition",".","Args",":","size",":","Initial","size","to","determine","the","number","of","channels",".","kernel_size",":","Size","of","the","convolving","kernel",".","norm_class",":","Normalization","module","class",".","norm_args",":","Normalization","module","arguments",".","dropout_rate",":","Dropout","rate",".","causal",":","Whether","to","use","causal","convolution","(","set","to","True","if","streaming",")","."]
docstr: Compute convolution module.
  
  Args:
      x: ConvolutionalSpatialGatingUnit input sequences. (B, T, D_hidden)
      mask: Source mask. (B, T_2)
      cache: ConvolutionalSpationGatingUnit input cache.
             (1, D_hidden, conv_kernel)
  
  Returns:
      x: ConvolutionalSpatialGatingUnit output sequences. (B, ?, D_hidden)
docstr_tok: ["Compute","convolution","module",".","Args",":","x",":","ConvolutionalSpatialGatingUnit","input","sequences",".","(","B",",","T",",","D_hidden",")","mask",":","Source","mask",".","(","B",",","T_2",")","cache",":","ConvolutionalSpationGatingUnit","input","cache",".","(","1",",","D_hidden",",","conv_kernel",")","Returns",":","x",":","ConvolutionalSpatialGatingUnit","output","sequences",".","(","B",",","?",",","D_hidden",")"]
code: def forward(
      self,
      x: torch.Tensor,
      mask: Optional[torch.Tensor] = None,
      cache: Optional[torch.Tensor] = None,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Compute convolution module.
  
      Args:
          x: ConvolutionalSpatialGatingUnit input sequences. (B, T, D_hidden)
          mask: Source mask. (B, T_2)
          cache: ConvolutionalSpationGatingUnit input cache.
                 (1, D_hidden, conv_kernel)
  
      Returns:
          x: ConvolutionalSpatialGatingUnit output sequences. (B, ?, D_hidden)
  
      """
      x_r, x_g = x.chunk(2, dim=-1)
  
      x_g = self.norm(x_g).transpose(1, 2)
  
      if mask is not None:
          x_g.masked_fill_(mask.unsqueeze(1).expand_as(x_g), 0.0)
  
      if self.lorder > 0:
          if cache is None:
              x_g = torch.nn.functional.pad(
                  x_g, (self.lorder, 0), "constant", 0.0
              )
          else:
              x_g = torch.cat([cache, x_g], dim=2)
              cache = x_g[..., -self.lorder :]
  
      x_g = self.conv(x_g).transpose(1, 2)
  
      x = self.dropout(x_r * self.activation(x_g))
  
      return x, cache
  
file_path: espnet/espnet2/asr_transducer/encoder/modules/convolution.py
imports: from typing import Dict, Optional, Tuple
  import torch
label_desc: Use image node_id 2 for calling the ConvolutionalSpatialGatingUnit obj's underlying member method code with example usage: obj.forward(x, mask, cache) and returns: x,  cache