code: def resize(
      img: Tensor,
      size: List[int],
      interpolation: InterpolationMode = InterpolationMode.BILINEAR,
      max_size: Optional[int] = None,
      antialias: Optional[bool] = True,
  ) -> Tensor:
      r"""Resize the input image to the given size.
      If the image is torch Tensor, it is expected
      to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions
  
      Args:
          img (PIL Image or Tensor): Image to be resized.
          size (sequence or int): Desired output size. If size is a sequence like
              (h, w), the output size will be matched to this. If size is an int,
              the smaller edge of the image will be matched to this number maintaining
              the aspect ratio. i.e, if height > width, then image will be rescaled to
              :math:`\left(\text{size} \times \frac{\text{height}}{\text{width}}, \text{size}\right)`.
  
              .. note::
                  In torchscript mode size as single int is not supported, use a sequence of length 1: ``[size, ]``.
          interpolation (InterpolationMode): Desired interpolation enum defined by
              :class:`torchvision.transforms.InterpolationMode`.
              Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``,
              ``InterpolationMode.NEAREST_EXACT``, ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are
              supported.
              The corresponding Pillow integer constants, e.g. ``PIL.Image.BILINEAR`` are accepted as well.
          max_size (int, optional): The maximum allowed for the longer edge of
              the resized image. If the longer edge of the image is greater
              than ``max_size`` after being resized according to ``size``,
              ``size`` will be overruled so that the longer edge is equal to
              ``max_size``.
              As a result, the smaller edge may be shorter than ``size``. This
              is only supported if ``size`` is an int (or a sequence of length
              1 in torchscript mode).
          antialias (bool, optional): Whether to apply antialiasing.
              It only affects **tensors** with bilinear or bicubic modes and it is
              ignored otherwise: on PIL images, antialiasing is always applied on
              bilinear or bicubic modes; on other modes (for PIL images and
              tensors), antialiasing makes no sense and this parameter is ignored.
              Possible values are:
  
              - ``True`` (default): will apply antialiasing for bilinear or bicubic modes.
                Other mode aren't affected. This is probably what you want to use.
              - ``False``: will not apply antialiasing for tensors on any mode. PIL
                images are still antialiased on bilinear or bicubic modes, because
                PIL doesn't support no antialias.
              - ``None``: equivalent to ``False`` for tensors and ``True`` for
                PIL images. This value exists for legacy reasons and you probably
                don't want to use it unless you really know what you are doing.
  
              The default value changed from ``None`` to ``True`` in
              v0.17, for the PIL and Tensor backends to be consistent.
  
      Returns:
          PIL Image or Tensor: Resized image.
      """
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
          _log_api_usage_once(resize)
  
      if isinstance(interpolation, int):
          interpolation = _interpolation_modes_from_int(interpolation)
      elif not isinstance(interpolation, InterpolationMode):
          raise TypeError(
              "Argument interpolation should be a InterpolationMode or a corresponding Pillow integer constant"
          )
  
      if isinstance(size, (list, tuple)):
          if len(size) not in [1, 2]:
              raise ValueError(
                  f"Size must be an int or a 1 or 2 element tuple/list, not a {len(size)} element tuple/list"
              )
          if max_size is not None and len(size) != 1:
              raise ValueError(
                  "max_size should only be passed if size specifies the length of the smaller edge, "
                  "i.e. size should be an int or a sequence of length 1 in torchscript mode."
              )
  
      _, image_height, image_width = get_dimensions(img)
      if isinstance(size, int):
          size = [size]
      output_size = _compute_resized_output_size(
          (image_height, image_width), size, max_size
      )
  
      if [image_height, image_width] == output_size:
          return img
  
      if not isinstance(img, torch.Tensor):
          if antialias is False:
              warnings.warn(
                  "Anti-alias option is always applied for PIL Image input. Argument antialias is ignored."
              )
          pil_interpolation = pil_modes_mapping[interpolation]
          return F_pil.resize(
              img, size=output_size, interpolation=pil_interpolation
          )
  
      return F_t.resize(
          img,
          size=output_size,
          interpolation=interpolation.value,
          antialias=antialias,
      )
  
imports: import math
  import numbers
  import sys
  import warnings
  from enum import Enum
  from typing import Any, List, Optional, Tuple, Union
  import numpy
  import torch
  from PIL import Image
  from torch import Tensor
  from ..utils import _log_api_usage_once
  from .None import _functional_pil, _functional_tensor
label_desc: Use image node_id 13 for calling a global function with example usage: resize(img, size, interpolation, max_size, antialias) and returns: F_t, img, F_pil