code: def to_gray(tens: Tensor) -> Tensor:  # type: ignore[return]
      r"""
          Converts any supported colorspace to grayscale
  
      Args:
          tens (Tensor)
  
      Returns:
          Tensor
      """
      if not isinstance(tens, Tensor):
          raise TypeError("`tens` must be a caer.Tensor")
  
      # Convert to tensor
      tens._nullprt()  # raises a ValueError if we're dealing with a Foreign Tensor with illegal `.cspace` value
      cspace = tens.cspace
  
      if cspace == "gray":
          return tens
  
      elif cspace == "bgr":
          img = bgr2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "rgb":
          img = rgb2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "hls":
          img = hls2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "hsv":
          img = hsv2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "lab":
          img = lab2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "yuv":
          img = yuv2gray(tens)
          return to_tensor(img, cspace="gray")
  
      elif cspace == "luv":
          img = luv2gray(tens)
          return to_tensor(img, cspace="gray")
  
file_path: caer/caer/color/core.py
imports: from ..coreten import Tensor, to_tensor
  from ..annotations import Union, Optional
  from ._bgr import bgr2gray, bgr2hsv, bgr2lab, bgr2rgb, bgr2hls, bgr2yuv, bgr2luv
  from ._rgb import rgb2gray, rgb2hsv, rgb2lab, rgb2bgr, rgb2hls, rgb2yuv, rgb2luv
  from ._gray import gray2lab, gray2rgb, gray2hsv, gray2bgr, gray2hls, gray2yuv, gray2luv
  from ._hsv import hsv2gray, hsv2rgb, hsv2lab, hsv2bgr, hsv2hls, hsv2yuv, hsv2luv
  from ._hls import hls2gray, hls2rgb, hls2lab, hls2bgr, hls2hsv, hls2yuv, hls2luv
  from ._lab import lab2gray, lab2rgb, lab2hsv, lab2bgr, lab2hls, lab2yuv, lab2luv
  from ._yuv import yuv2bgr, yuv2rgb, yuv2hsv, yuv2hls, yuv2gray, yuv2lab, yuv2luv
  from ._luv import luv2bgr, luv2rgb, luv2hsv, luv2hls, luv2gray, luv2lab, luv2yuv
label_desc: Use image node_id 3 for calling a global function with example usage: to_gray(tens) and returns: tens, to_tensor, to_tensor, to_tensor, to_tensor, to_tensor, to_tensor, to_tensor