code: def downscale_image(
      image: Tensor,
      size: tuple,
      mode: ImageUpscaleMode = ImageUpscaleMode.PADDING,
  ) -> Tensor:
      """Opposite of upscaling. This image downscales image to a desired size.
  
      Args:
          image (Tensor): Input image
          size (tuple): Size to which image is down scaled.
          mode (str, optional): Downscaling mode. Defaults to "padding".
  
      Examples:
          >>> x = torch.rand(1, 3, 512, 512)
          >>> y = upscale_image(image, upscale_size=(555, 555), mode="padding")
          >>> y = downscale_image(y, size=(512, 512), mode='padding')
          >>> torch.allclose(x, y)
          True
  
      Returns:
          Tensor: Downscaled image
      """
      input_h, input_w = size
      if mode == ImageUpscaleMode.PADDING:
          image = image[:, :, :input_h, :input_w]
      else:
          image = F.interpolate(input=image, size=(input_h, input_w))
  
      return image
  
imports: from __future__ import annotations
  from enum import Enum
  from itertools import product
  from math import ceil
  from typing import Sequence
  import torch
  import torchvision.transforms
  from torch import Tensor
  from torch.nn import functional
label_desc: Use image node_id 3 for calling a global function with example usage: downscale_image(image, size, mode) and returns: image