class_docstr: An implementation of convolution block with 1d or 2d convolutions (depthwise).
  
  Arguments
  ----------
  out_channels : int
      Number of output channels of this model (default 640).
  kernel_size : int
      Kernel size of convolution layers (default 3).
  strides : int
      Striding factor for this block (default 1).
  num_layers : int
      Number of depthwise convolution layers for this block.
  activation : torch class
      Activation function for this block.
  norm : torch class
      Normalization to regularize the model (default BatchNorm1d).
  residuals: bool
      Whether apply residual connection at this block (default None).
  
  Example
  -------
  >>> x = torch.rand((8, 30, 10))
  >>> conv = ConvBlock(2, 16, input_shape=x.shape)
  >>> out = conv(x)
  >>> x.shape
  torch.Size([8, 30, 10])
class_docstr_tok: ["An","implementation","of","convolution","block","with","1d","or","2d","convolutions","(","depthwise",")",".","Arguments","--","--","--","--","--","out_channels",":","int","Number","of","output","channels","of","this","model","(","default","640",")",".","kernel_size",":","int","Kernel","size","of","convolution","layers","(","default","3",")",".","strides",":","int","Striding","factor","for","this","block","(","default","1",")",".","num_layers",":","int","Number","of","depthwise","convolution","layers","for","this","block",".","activation",":","torch","class","Activation","function","for","this","block",".","norm",":","torch","class","Normalization","to","regularize","the","model","(","default","BatchNorm1d",")",".","residuals",":","bool","Whether","apply","residual","connection","at","this","block","(","default","None",")",".","Example","--","--","--","-",">",">",">","x","=","torch.rand","(","(","8",",","30",",","10",")",")",">",">",">","conv","=","ConvBlock","(","2",",","16",",","input_shape=x.shape",")",">",">",">","out","=","conv","(","x",")",">",">",">","x.shape","torch.Size","(","[","8",",","30",",","10","]",")"]
code: def __init__(
      self,
      num_layers,
      out_channels,
      input_shape,
      kernel_size=3,
      stride=1,
      dilation=1,
      residual=False,
      conv_module=Conv2d,
      activation=torch.nn.LeakyReLU,
      norm=None,
      dropout=0.1,
      conv_bias=True,
      padding="same",
      conv_init=None,
  ):
      super().__init__()
      self.convs = Sequential(input_shape=input_shape)
  
      for i in range(num_layers):
          self.convs.append(
              conv_module,
              out_channels=out_channels,
              kernel_size=kernel_size,
              stride=stride if i == num_layers - 1 else 1,
              dilation=dilation,
              layer_name=f"conv_{i}",
              bias=conv_bias,
              padding=padding,
              conv_init=conv_init,
          )
          if norm is not None:
              self.convs.append(norm, layer_name=f"norm_{i}")
          self.convs.append(activation(), layer_name=f"act_{i}")
          self.convs.append(
              torch.nn.Dropout(dropout), layer_name=f"dropout_{i}"
          )
  
      self.reduce_conv = None
      self.drop = None
      if residual:
          self.reduce_conv = Sequential(input_shape=input_shape)
          self.reduce_conv.append(
              conv_module,
              out_channels=out_channels,
              kernel_size=1,
              stride=stride,
              layer_name="conv",
          )
          self.reduce_conv.append(norm, layer_name="norm")
          self.drop = torch.nn.Dropout(dropout)
  
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 1 to create a new ConvBlock object from inherited base classes: torch.nn with example: obj = ConvBlock(num_layers, out_channels, input_shape, kernel_size, stride, dilation, residual, conv_module, activation, norm, dropout, conv_bias, padding, conv_init)