code: def upscale_image(
      image: Tensor,
      size: tuple,
      mode: ImageUpscaleMode = ImageUpscaleMode.PADDING,
  ) -> Tensor:
      """Upscale image to the desired size via either padding or interpolation.
  
      Args:
          image (Tensor): Image
          size (tuple): tuple to which image is upscaled.
          mode (str, optional): Upscaling mode. Defaults to "padding".
  
      Examples:
          >>> image = torch.rand(1, 3, 512, 512)
          >>> image = upscale_image(image, size=(555, 555), mode="padding")
          >>> image.shape
          torch.Size([1, 3, 555, 555])
  
          >>> image = torch.rand(1, 3, 512, 512)
          >>> image = upscale_image(image, size=(555, 555), mode="interpolation")
          >>> image.shape
          torch.Size([1, 3, 555, 555])
  
      Returns:
          Tensor: Upscaled image.
      """
  
      image_h, image_w = image.shape[2:]
      resize_h, resize_w = size
  
      if mode == ImageUpscaleMode.PADDING:
          pad_h = resize_h - image_h
          pad_w = resize_w - image_w
  
          image = F.pad(image, [0, pad_w, 0, pad_h])
      elif mode == ImageUpscaleMode.INTERPOLATION:
          image = F.interpolate(input=image, size=(resize_h, resize_w))
      else:
          raise ValueError(
              f"Unknown mode {mode}. Only padding and interpolation is available."
          )
  
      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 2 for calling a global function with example usage: upscale_image(image, size, mode) and returns: image