class_docstr: This module implementing CSGU as defined in:
  Branchformer: Parallel MLP-Attention Architectures
  to Capture Local and Global Context for Speech Recognition
  and Understanding"
  
  The code is heavily inspired from the original ESPNet
  implementation.
  
  Arguments
  ----------
  input_size: int
      Size of the feature (channel) dimension.
  kernel_size: int, optional
      Size of the kernel
  dropout: float, optional
      Dropout rate to be applied at the output
  use_linear_after_conv: bool, optional
      If True, will apply a linear transformation of size input_size//2
  activation: torch.class, optional
      Activation function to use on the gate, default is Identity.
  
  Example
  -------
  >>> x = torch.rand((8, 30, 10))
  >>> conv = ConvolutionalSpatialGatingUnit(input_size=x.shape[-1])
  >>> out = conv(x)
  >>> out.shape
  torch.Size([8, 30, 5])
class_docstr_tok: ["This","module","implementing","CSGU","as","defined","in",":","Branchformer",":","Parallel","MLP-Attention","Architectures","to","Capture","Local","and","Global","Context","for","Speech","Recognition","and","Understanding","''","The","code","is","heavily","inspired","from","the","original","ESPNet","implementation",".","Arguments","--","--","--","--","--","input_size",":","int","Size","of","the","feature","(","channel",")","dimension",".","kernel_size",":","int",",","optional","Size","of","the","kernel","dropout",":","float",",","optional","Dropout","rate","to","be","applied","at","the","output","use_linear_after_conv",":","bool",",","optional","If","True",",","will","apply","a","linear","transformation","of","size","input_size\/\/2","activation",":","torch.class",",","optional","Activation","function","to","use","on","the","gate",",","default","is","Identity",".","Example","--","--","--","-",">",">",">","x","=","torch.rand","(","(","8",",","30",",","10",")",")",">",">",">","conv","=","ConvolutionalSpatialGatingUnit","(","input_size=x.shape","[","-1","]",")",">",">",">","out","=","conv","(","x",")",">",">",">","out.shape","torch.Size","(","[","8",",","30",",","5","]",")"]
docstr: Arguments
  ----------
  x: torch.Tensor -> (B, T, D)
docstr_tok: ["Arguments","--","--","--","--","--","x",":","torch.Tensor","-",">","(","B",",","T",",","D",")"]
code: def forward(self, x):
      """
      Arguments
      ----------
      x: torch.Tensor -> (B, T, D)
  
      """
  
      # We create two sequences where feat dim is halved
      x1, x2 = x.chunk(2, dim=-1)
  
      x2 = self.norm(x2)
      x2 = self.conv(x2)
      if self.use_linear_after_conv:
          x2 = self.linear(x2)
      x2 = self.activation(x2)
  
      return self.dropout(x2 * x1)
  
file_path: speechbrain/speechbrain/lobes/models/convolution.py
imports: import torch
  from speechbrain.nnet.CNN import Conv2d, Conv1d
  from speechbrain.nnet.containers import Sequential
  from speechbrain.nnet.normalization import LayerNorm
label_desc: Use image node_id 2 for calling the ConvolutionalSpatialGatingUnit obj's underlying member method code with example usage: obj.forward(x) and returns: self