class_docstr: A general N-dimensional convolutional module.
docstr: Constructs a `ConvND` module.
  
  Args:
    num_spatial_dims: The number of spatial dimensions of the input.
    output_channels: The number of output channels.
    kernel_shape: Sequence of kernel sizes (of length num_spatial_dims), or an
      integer. `kernel_shape` will be expanded to define a kernel size in all
      dimensions.
    stride: Sequence of strides (of length num_spatial_dims), or an integer.
      `stride` will be expanded to define stride in all dimensions.
    rate: Sequence of dilation rates (of length num_spatial_dims), or integer
      that is used to define dilation rate in all dimensions. 1 corresponds to
      standard ND convolution, `rate > 1` corresponds to dilated convolution.
    padding: Padding to apply to the input. This can either "SAME", "VALID" or
      a callable or sequence of callables up to size N. Any callables must
      take a single integer argument equal to the effective kernel size and
      return a list of two integers representing the padding before and after.
      See snt.pad.* for more details and example functions.
    with_bias: Whether to include bias parameters. Default `True`.
    w_init: Optional initializer for the weights. By default the weights are
      initialized truncated random normal values with a standard deviation of
      `1 / sqrt(input_feature_size)`, which is commonly used when the inputs
      are zero centered (see https://arxiv.org/abs/1502.03167v3).
    b_init: Optional initializer for the bias. By default the bias is
      initialized to zero.
    data_format: The data format of the input.
    name: Name of the module.
docstr_tok: ["Constructs","a","`","ConvND","`","module",".","Args",":","num_spatial_dims",":","The","number","of","spatial","dimensions","of","the","input",".","output_channels",":","The","number","of","output","channels",".","kernel_shape",":","Sequence","of","kernel","sizes","(","of","length","num_spatial_dims",")",",","or","an","integer",".","`","kernel_shape","`","will","be","expanded","to","define","a","kernel","size","in","all","dimensions",".","stride",":","Sequence","of","strides","(","of","length","num_spatial_dims",")",",","or","an","integer",".","`","stride","`","will","be","expanded","to","define","stride","in","all","dimensions",".","rate",":","Sequence","of","dilation","rates","(","of","length","num_spatial_dims",")",",","or","integer","that","is","used","to","define","dilation","rate","in","all","dimensions",".","1","corresponds","to","standard","ND","convolution",",","`","rate",">","1","`","corresponds","to","dilated","convolution",".","padding",":","Padding","to","apply","to","the","input",".","This","can","either","``","SAME","''",",","``","VALID","''","or","a","callable","or","sequence","of","callables","up","to","size","N.","Any","callables","must","take","a","single","integer","argument","equal","to","the","effective","kernel","size","and","return","a","list","of","two","integers","representing","the","padding","before","and","after",".","See","snt.pad",".","*","for","more","details","and","example","functions",".","with_bias",":","Whether","to","include","bias","parameters",".","Default","`","True","`",".","w_init",":","Optional","initializer","for","the","weights",".","By","default","the","weights","are","initialized","truncated","random","normal","values","with","a","standard","deviation","of","`","1","\/","sqrt","(","input_feature_size",")","`",",","which","is","commonly","used","when","the","inputs","are","zero","centered","(","see","https",":","\/\/arxiv.org\/abs\/1502.03167v3",")",".","b_init",":","Optional","initializer","for","the","bias",".","By","default","the","bias","is","initialized","to","zero",".","data_format",":","The","data","format","of","the","input",".","name",":","Name","of","the","module","."]
code: def __init__(
      self,
      num_spatial_dims: int,
      output_channels: int,
      kernel_shape: Union[int, Sequence[int]],
      stride: Union[int, Sequence[int]] = 1,
      rate: Union[int, Sequence[int]] = 1,
      padding: Union[str, pad.Paddings] = "SAME",
      with_bias: bool = True,
      w_init: Optional[initializers.Initializer] = None,
      b_init: Optional[initializers.Initializer] = None,
      data_format: Optional[str] = None,
      name: Optional[str] = None,
  ):
      """Constructs a `ConvND` module.
  
      Args:
        num_spatial_dims: The number of spatial dimensions of the input.
        output_channels: The number of output channels.
        kernel_shape: Sequence of kernel sizes (of length num_spatial_dims), or an
          integer. `kernel_shape` will be expanded to define a kernel size in all
          dimensions.
        stride: Sequence of strides (of length num_spatial_dims), or an integer.
          `stride` will be expanded to define stride in all dimensions.
        rate: Sequence of dilation rates (of length num_spatial_dims), or integer
          that is used to define dilation rate in all dimensions. 1 corresponds to
          standard ND convolution, `rate > 1` corresponds to dilated convolution.
        padding: Padding to apply to the input. This can either "SAME", "VALID" or
          a callable or sequence of callables up to size N. Any callables must
          take a single integer argument equal to the effective kernel size and
          return a list of two integers representing the padding before and after.
          See snt.pad.* for more details and example functions.
        with_bias: Whether to include bias parameters. Default `True`.
        w_init: Optional initializer for the weights. By default the weights are
          initialized truncated random normal values with a standard deviation of
          `1 / sqrt(input_feature_size)`, which is commonly used when the inputs
          are zero centered (see https://arxiv.org/abs/1502.03167v3).
        b_init: Optional initializer for the bias. By default the bias is
          initialized to zero.
        data_format: The data format of the input.
        name: Name of the module.
      """
      super().__init__(name=name)
  
      if not 1 <= num_spatial_dims <= 3:
          raise ValueError(
              "We only support convoltion operations for num_spatial_dims=1, 2 or "
              "3, received num_spatial_dims={}.".format(
                  num_spatial_dims
              )
          )
      self._num_spatial_dims = num_spatial_dims
      self.output_channels = output_channels
      self.kernel_shape = kernel_shape
      self.stride = stride
      self.rate = rate
  
      if isinstance(padding, str):
          self.conv_padding = padding.upper()
          self.padding_func = None
      else:
          self.conv_padding = "VALID"
          self.padding_func = padding
  
      self.data_format = data_format
      self._channel_index = utils.get_channel_index(data_format)
      self.with_bias = with_bias
  
      self.w_init = w_init
      if with_bias:
          self.b_init = (
              b_init if b_init is not None else initializers.Zeros()
          )
      elif b_init is not None:
          raise ValueError(
              "When not using a bias the b_init must be None."
          )
  
imports: from typing import Optional, Sequence, Union
  import numpy
  from sonnet.src import base
  from sonnet.src import initializers
  from sonnet.src import once
  from sonnet.src import pad
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 1 to create a new ConvND object from inherited base classes: base with example: obj = ConvND(num_spatial_dims, output_channels, kernel_shape, stride, rate, padding, with_bias, w_init, b_init, data_format, name)