code: def _hsv_to_rgb(img: torch.Tensor) -> torch.Tensor:
      h, s, v = img.unbind(dim=-3)
      h6 = h.mul(6)
      i = torch.floor(h6)
      f = h6.sub_(i)
      i = i.to(dtype=torch.int32)
  
      sxf = s * f
      one_minus_s = 1.0 - s
      q = (1.0 - sxf).mul_(v).clamp_(0.0, 1.0)
      t = sxf.add_(one_minus_s).mul_(v).clamp_(0.0, 1.0)
      p = one_minus_s.mul_(v).clamp_(0.0, 1.0)
      i.remainder_(6)
  
      vpqt = torch.stack((v, p, q, t), dim=-3)
  
      # vpqt -> rgb mapping based on i
      select = torch.tensor(
          [[0, 2, 1, 1, 3, 0], [3, 0, 0, 2, 1, 1], [1, 1, 3, 0, 0, 2]],
          dtype=torch.long,
      )
      select = select.to(device=img.device, non_blocking=True)
  
      select = select[:, i]
      if select.ndim > 3:
          # if input.shape is (B, ..., C, H, W) then
          # select.shape is (C, B, ...,  H, W)
          # thus we move C axis to get (B, ..., C, H, W)
          select = select.moveaxis(0, -3)
  
      return vpqt.gather(-3, select)
  
imports: from typing import List
  import PIL.Image
  import torch
  from torch.nn.functional import conv2d
  from torchvision import tv_tensors
  from torchvision.transforms import _functional_pil
  from torchvision.transforms._functional_tensor import _max_value
  from torchvision.utils import _log_api_usage_once
  from ._misc import _num_value_bits, to_dtype_image
  from ._type_conversion import pil_to_tensor, to_pil_image
  from ._utils import _get_kernel, _register_kernel_internal
label_desc: Use image node_id 21 for calling a global function with example usage: _hsv_to_rgb(img) and returns: vpqt