code: def test_resize(device, dt, size, max_size, interpolation):
      if dt == torch.float16 and device == "cpu":
          # skip float16 on CPU case
          return
  
      if (
          max_size is not None
          and isinstance(size, Sequence)
          and len(size) != 1
      ):
          return  # unsupported
  
      torch.manual_seed(12)
      script_fn = torch.jit.script(F.resize)
      tensor, pil_img = _create_data(26, 36, device=device)
      batch_tensors = _create_data_batch(
          16, 18, num_samples=4, device=device
      )
  
      if dt is not None:
          # This is a trivial cast to float of uint8 data to test all cases
          tensor = tensor.to(dt)
          batch_tensors = batch_tensors.to(dt)
  
      resized_tensor = F.resize(
          tensor,
          size=size,
          interpolation=interpolation,
          max_size=max_size,
          antialias=True,
      )
      resized_pil_img = F.resize(
          pil_img,
          size=size,
          interpolation=interpolation,
          max_size=max_size,
          antialias=True,
      )
  
      assert resized_tensor.size()[1:] == resized_pil_img.size[::-1]
  
      if interpolation != NEAREST:
          # We can not check values if mode = NEAREST, as results are different
          # E.g. resized_tensor  = [[a, a, b, c, d, d, e, ...]]
          # E.g. resized_pil_img = [[a, b, c, c, d, e, f, ...]]
          resized_tensor_f = resized_tensor
          # we need to cast to uint8 to compare with PIL image
          if resized_tensor_f.dtype == torch.uint8:
              resized_tensor_f = resized_tensor_f.to(torch.float)
  
          # Pay attention to high tolerance for MAE
          _assert_approx_equal_tensor_to_pil(
              resized_tensor_f, resized_pil_img, tol=3.0
          )
  
      if isinstance(size, int):
          script_size = [size]
      else:
          script_size = size
  
      resize_result = script_fn(
          tensor,
          size=script_size,
          interpolation=interpolation,
          max_size=max_size,
          antialias=True,
      )
      assert_equal(resized_tensor, resize_result)
  
      _test_fn_on_batch(
          batch_tensors,
          F.resize,
          size=script_size,
          interpolation=interpolation,
          max_size=max_size,
          antialias=True,
      )
  
imports: import colorsys
  import itertools
  import math
  import os
  from functools import partial
  from typing import Sequence
  import numpy
  import PIL.Image
  import pytest
  import torch
  import torchvision.transforms
  import torchvision.transforms._functional_pil
  import torchvision.transforms._functional_tensor
  import torchvision.transforms.functional
  from common_utils import _assert_approx_equal_tensor_to_pil, _assert_equal_tensor_to_pil, _create_data, _create_data_batch, _test_fn_on_batch, assert_equal, cpu_and_cuda, needs_cuda
  from torchvision.transforms import InterpolationMode
label_desc: Use image node_id 7 for calling a global function with example usage: test_resize(device, dt, size, max_size, interpolation) without return types