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 forward(self, x: th.Tensor) -> th.Tensor:
      assert x.shape[1] == self.channels
  
      return self.op(x)
  
imports: import logging
  import math
  from abc import abstractmethod
  from typing import Iterable, List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from einops import rearrange
  from torch.utils.checkpoint import checkpoint
  from ...modules.attention import SpatialTransformer
  from ...modules.diffusionmodules.util import avg_pool_nd, conv_nd, linear, normalization, timestep_embedding, zero_module
  from ...modules.video_attention import SpatialVideoTransformer
  from ...util import exists
label_desc: Use image node_id 2 for calling the Downsample obj's underlying member method code with example usage: obj.forward(x) and returns: self