class_docstr: This function implements quaternion-valued 1d convolution.
  
  Arguments
  ---------
  input_shape : tuple
      The shape of the input.
  out_channels : int
      Number of output channels. Please note
      that these are quaternion-valued neurons. If 256
      channels are specified, the output dimension
      will be 1024.
  kernel_size : int
      Kernel size of the convolutional filters.
  stride : int, optional
      Stride factor of the convolutional filters (default 1).
  dilation : int, optional
      Dilation factor of the convolutional filters (default 1).
  padding : str, optional
      (same, causal). If "valid", no padding is performed.
      If "same" and stride is 1, output shape is same as input shape (default "same").
  padding_mode : str, optional
      This flag specifies the type of padding. See torch.nn documentation
      for more information. (default "reflect")
  groups : int, optional
      This option specifies the convolutional groups. See torch.nn
      documentation for more information. (default 1).
  bias : bool, optional
      If True, the additive bias b is adopted (default True).
  init_criterion : str , optional
      (glorot, he).
      This parameter controls the initialization criterion of the weights.
      It is combined with weights_init to build the initialization method of
      the quaternion-valued weights (default "glorot").
  weight_init : str, optional
      (quaternion, unitary).
      This parameter defines the initialization procedure of the
      quaternion-valued weights. "quaternion" will generate random quaternion
      weights following the init_criterion and the quaternion polar form.
      "unitary" will normalize the weights to lie on the unit circle (default "quaternion").
      More details in: "Quaternion Recurrent Neural Networks",
      Parcollet T. et al.
  spinor : bool, optional
      When True, the layer will be turned into a spinor layer. More precisely
      W*x will be turned into W*x*W-1. The input x will be rotated by W such
      as in a spinor neural network. However, x MUST be a quaternion with
      the real part equal to zero. (0 + xi + yj + zk). Indeed, the rotation
      operation only acts on the vector part. Note that W will always be
      normalized before the rotation to ensure the quaternion algebra (default False).
      More details in: "Quaternion neural networks", Parcollet T.
  vector_scale : bool, optional
      The vector_scale is only used when spinor = True. In the context of a
      spinor neural network, multiple rotations of the input vector x are
      performed and summed. Hence, the norm of the output vector always
      increases with the number of layers, making the neural network instable
      with deep configurations. The vector_scale parameters are learnable
      parameters that acts like gates by multiplying the output vector with
      a small trainable parameter (default False).
  
  Example
  -------
  >>> inp_tensor = torch.rand([10, 4, 16, 40])
  >>> cnn_1d = QConv2d(
  ...     input_shape=inp_tensor.shape, out_channels=12, kernel_size=3
  ... )
  >>> out_tensor = cnn_1d(inp_tensor)
  >>> out_tensor.shape
  torch.Size([10, 4, 16, 48])
class_docstr_tok: ["This","function","implements","quaternion-valued","1d","convolution",".","Arguments","--","--","--","--","-","input_shape",":","tuple","The","shape","of","the","input",".","out_channels",":","int","Number","of","output","channels",".","Please","note","that","these","are","quaternion-valued","neurons",".","If","256","channels","are","specified",",","the","output","dimension","will","be","1024.","kernel_size",":","int","Kernel","size","of","the","convolutional","filters",".","stride",":","int",",","optional","Stride","factor","of","the","convolutional","filters","(","default","1",")",".","dilation",":","int",",","optional","Dilation","factor","of","the","convolutional","filters","(","default","1",")",".","padding",":","str",",","optional","(","same",",","causal",")",".","If","``","valid","''",",","no","padding","is","performed",".","If","``","same","''","and","stride","is","1",",","output","shape","is","same","as","input","shape","(","default","``","same","''",")",".","padding_mode",":","str",",","optional","This","flag","specifies","the","type","of","padding",".","See","torch.nn","documentation","for","more","information",".","(","default","``","reflect","''",")","groups",":","int",",","optional","This","option","specifies","the","convolutional","groups",".","See","torch.nn","documentation","for","more","information",".","(","default","1",")",".","bias",":","bool",",","optional","If","True",",","the","additive","bias","b","is","adopted","(","default","True",")",".","init_criterion",":","str",",","optional","(","glorot",",","he",")",".","This","parameter","controls","the","initialization","criterion","of","the","weights",".","It","is","combined","with","weights_init","to","build","the","initialization","method","of","the","quaternion-valued","weights","(","default","``","glorot","''",")",".","weight_init",":","str",",","optional","(","quaternion",",","unitary",")",".","This","parameter","defines","the","initialization","procedure","of","the","quaternion-valued","weights",".","``","quaternion","''","will","generate","random","quaternion","weights","following","the","init_criterion","and","the","quaternion","polar","form",".","``","unitary","''","will","normalize","the","weights","to","lie","on","the","unit","circle","(","default","``","quaternion","''",")",".","More","details","in",":","``","Quaternion","Recurrent","Neural","Networks","''",",","Parcollet","T.","et","al",".","spinor",":","bool",",","optional","When","True",",","the","layer","will","be","turned","into","a","spinor","layer",".","More","precisely","W","*","x","will","be","turned","into","W","*","x","*","W-1",".","The","input","x","will","be","rotated","by","W","such","as","in","a","spinor","neural","network",".","However",",","x","MUST","be","a","quaternion","with","the","real","part","equal","to","zero",".","(","0","+","xi","+","yj","+","zk",")",".","Indeed",",","the","rotation","operation","only","acts","on","the","vector","part",".","Note","that","W","will","always","be","normalized","before","the","rotation","to","ensure","the","quaternion","algebra","(","default","False",")",".","More","details","in",":","``","Quaternion","neural","networks","''",",","Parcollet","T.","vector_scale",":","bool",",","optional","The","vector_scale","is","only","used","when","spinor","=","True",".","In","the","context","of","a","spinor","neural","network",",","multiple","rotations","of","the","input","vector","x","are","performed","and","summed",".","Hence",",","the","norm","of","the","output","vector","always","increases","with","the","number","of","layers",",","making","the","neural","network","instable","with","deep","configurations",".","The","vector_scale","parameters","are","learnable","parameters","that","acts","like","gates","by","multiplying","the","output","vector","with","a","small","trainable","parameter","(","default","False",")",".","Example","--","--","--","-",">",">",">","inp_tensor","=","torch.rand","(","[","10",",","4",",","16",",","40","]",")",">",">",">","cnn_1d","=","QConv2d","(","...","input_shape=inp_tensor.shape",",","out_channels=12",",","kernel_size=3","...",")",">",">",">","out_tensor","=","cnn_1d","(","inp_tensor",")",">",">",">","out_tensor.shape","torch.Size","(","[","10",",","4",",","16",",","48","]",")"]
docstr: This function performs zero-padding on the time and frequency axises
  such that their lengths is unchanged after the convolution.
  
  Arguments
  ---------
  x : torch.Tensor
      Input tensor.
  kernel_size : int
      Kernel size.
  dilation : int
      Dilation.
  stride: int
      Stride.
docstr_tok: ["This","function","performs","zero-padding","on","the","time","and","frequency","axises","such","that","their","lengths","is","unchanged","after","the","convolution",".","Arguments","--","--","--","--","-","x",":","torch.Tensor","Input","tensor",".","kernel_size",":","int","Kernel","size",".","dilation",":","int","Dilation",".","stride",":","int","Stride","."]
code: def _manage_padding(
      self,
      x,
      kernel_size: Tuple[int, int],
      dilation: Tuple[int, int],
      stride: Tuple[int, int],
  ):
      """This function performs zero-padding on the time and frequency axises
      such that their lengths is unchanged after the convolution.
  
      Arguments
      ---------
      x : torch.Tensor
          Input tensor.
      kernel_size : int
          Kernel size.
      dilation : int
          Dilation.
      stride: int
          Stride.
      """
  
      # Detecting input shape
      L_in = x.shape[-1]
  
      # Time padding
      padding_time = get_padding_elem(
          L_in, stride[-1], kernel_size[-1], dilation[-1]
      )
  
      padding_freq = get_padding_elem(
          L_in, stride[-2], kernel_size[-2], dilation[-2]
      )
      padding = padding_time + padding_freq
  
      # Applying padding
      x = nn.functional.pad(x, padding, mode=self.padding_mode)
  
      return x
  
imports: import torch
  import torch.nn
  import logging
  import torch.nn.functional
  from speechbrain.nnet.CNN import get_padding_elem
  from speechbrain.nnet.quaternion_networks.q_ops import unitary_init, quaternion_init, affect_conv_init, quaternion_conv_op, quaternion_conv_rotation_op
  from typing import Tuple
label_desc: Use image node_id 5 for calling the QConv2d obj's underlying member method code with example usage: obj._manage_padding(x, kernel_size, dilation, stride) and returns: x