code: def test_rotate(
      self, device, height, width, center, dt, angle, expand, fill, fn
  ):
      tensor, pil_img = _create_data(height, width, device=device)
  
      if dt == torch.float16 and torch.device(device).type == "cpu":
          # skip float16 on CPU case
          return
  
      if dt is not None:
          tensor = tensor.to(dtype=dt)
  
      f_pil = (
          int(fill[0]) if fill is not None and len(fill) == 1 else fill
      )
      out_pil_img = F.rotate(
          pil_img,
          angle=angle,
          interpolation=NEAREST,
          expand=expand,
          center=center,
          fill=f_pil,
      )
      out_pil_tensor = torch.from_numpy(
          np.array(out_pil_img).transpose((2, 0, 1))
      )
  
      out_tensor = fn(
          tensor,
          angle=angle,
          interpolation=NEAREST,
          expand=expand,
          center=center,
          fill=fill,
      ).cpu()
  
      if out_tensor.dtype != torch.uint8:
          out_tensor = out_tensor.to(torch.uint8)
  
      assert (
          out_tensor.shape == out_pil_tensor.shape
      ), f"{(height, width, NEAREST, dt, angle, expand, center)}: {out_tensor.shape} vs {out_pil_tensor.shape}"
  
      num_diff_pixels = (
          out_tensor != out_pil_tensor
      ).sum().item() / 3.0
      ratio_diff_pixels = (
          num_diff_pixels / out_tensor.shape[-1] / out_tensor.shape[-2]
      )
      # Tolerance : less than 3% of different pixels
      assert ratio_diff_pixels < 0.03, (
          f"{(height, width, NEAREST, dt, angle, expand, center, fill)}: "
          f"{ratio_diff_pixels}\n{out_tensor[0, :7, :7]} vs \n"
          f"{out_pil_tensor[0, :7, :7]}"
      )
  
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 1 for calling the TestRotate obj's underlying member method code with example usage: obj.test_rotate(device, height, width, center, dt, angle, expand, fill, fn) without return types