class_docstr: An upsampling 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
               upsampling occurs in the inner-two dimensions.
code: def forward(self, x):
      assert x.shape[1] == self.channels
      if self.dims == 3:
          x = F.interpolate(
              x,
              (x.shape[2], x.shape[3] * 2, x.shape[4] * 2),
              mode="nearest",
          )
      else:
          x = F.interpolate(x, scale_factor=2, mode="nearest")
      if self.use_conv:
          x = self.conv(x)
      return x
  
imports: import math
  from abc import abstractmethod
  import torch
  import torch.nn
  import torch.nn.functional
  from .fp16_util import convert_module_to_f16, convert_module_to_f32
  from .nn import avg_pool_nd, conv_nd, linear, normalization, timestep_embedding, zero_module
label_desc: Use image node_id 2 for calling the Upsample obj's underlying member method code with example usage: obj.forward(x) and returns: x