code: def test_rgb2hsv(device):
      scripted_fn = torch.jit.script(F_t._rgb2hsv)
      shape = (3, 150, 100)
      for _ in range(10):
          rgb_img = torch.rand(*shape, dtype=torch.float, device=device)
          hsv_img = F_t._rgb2hsv(rgb_img)
          ft_hsv_img = hsv_img.permute(1, 2, 0).flatten(0, 1)
  
          (
              r,
              g,
              b,
          ) = rgb_img.unbind(dim=-3)
          r = r.flatten().cpu().numpy()
          g = g.flatten().cpu().numpy()
          b = b.flatten().cpu().numpy()
  
          hsv = []
          for r1, g1, b1 in zip(r, g, b):
              hsv.append(colorsys.rgb_to_hsv(r1, g1, b1))
  
          colorsys_img = torch.tensor(
              hsv, dtype=torch.float32, device=device
          )
  
          ft_hsv_img_h, ft_hsv_img_sv = torch.split(
              ft_hsv_img, [1, 2], dim=1
          )
          colorsys_img_h, colorsys_img_sv = torch.split(
              colorsys_img, [1, 2], dim=1
          )
  
          max_diff_h = (
              (
                  (colorsys_img_h * 2 * math.pi).sin()
                  - (ft_hsv_img_h * 2 * math.pi).sin()
              )
              .abs()
              .max()
          )
          max_diff_sv = (colorsys_img_sv - ft_hsv_img_sv).abs().max()
          max_diff = max(max_diff_h, max_diff_sv)
          assert max_diff < 1e-5
  
          s_hsv_img = scripted_fn(rgb_img)
          torch.testing.assert_close(
              hsv_img, s_hsv_img, rtol=1e-5, atol=1e-7
          )
  
      batch_tensors = _create_data_batch(
          120, 100, num_samples=4, device=device
      ).float()
      _test_fn_on_batch(batch_tensors, F_t._rgb2hsv)
  
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 34 for calling a global function with example usage: test_rgb2hsv(device) without return types