class_docstr: A downsampling layer with an optional convolution.
  
  :param channels: channels in the inputs and outputs. :param use_conv: a bool determining if a convolution is
  applied. :param dims: determines if the signal is 1D, 2D, or 3D. If 3D, then
               downsampling occurs in the inner-two dimensions.
class_docstr_tok: ["A","downsampling","layer","with","an","optional","convolution",".",":","param","channels",":","channels","in","the","inputs","and","outputs",".",":","param","use_conv",":","a","bool","determining","if","a","convolution","is","applied",".",":","param","dims",":","determines","if","the","signal","is","1D",",","2D",",","or","3D",".","If","3D",",","then","downsampling","occurs","in","the","inner-two","dimensions","."]
code: def __init__(
      self,
      channels,
      use_conv=False,
      out_channels=None,
      padding=1,
      name="conv",
  ):
      super().__init__()
      self.channels = channels
      self.out_channels = out_channels or channels
      self.use_conv = use_conv
      self.padding = padding
      stride = 2
      self.name = name
  
      if use_conv:
          conv = nn.Conv2D(
              self.channels,
              self.out_channels,
              3,
              stride=stride,
              padding=padding,
          )
      else:
          assert self.channels == self.out_channels
          conv = nn.AvgPool2D(kernel_size=stride, stride=stride)
  
      # TODO(Suraj, Patrick) - clean up after weight dicts are correctly renamed
      if name == "conv":
          self.Conv2d_0 = conv
          self.conv = conv
      elif name == "Conv2d_0":
          self.conv = conv
      else:
          self.conv = conv
  
imports: from functools import partial
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 to create a new Downsample2D object from inherited base classes: nn with example: obj = Downsample2D(channels, use_conv, out_channels, padding, name)