code: def rgb2short(rgb: str) -> Tuple[str, str]:
      """Find the closest xterm-256 approximation to the given RGB value.
  
      Args:
          rgb: Hex code representing an RGB value, eg, 'abcdef'.
  
      Returns:
          String between 0 and 255, compatible with xterm.
  
      Example:
          >>> rgb2short('123456')
          ('23', '005f5f')
          >>> rgb2short('ffffff')
          ('231', 'ffffff')
          >>> rgb2short('0DADD6')  # vimeo logo
          ('38', '00afd7')
      """
      rgb = _strip_hash(rgb)
      incs = (0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF)
      # Break 6-char RGB code into 3 integer vals.
      parts = [int(h, 16) for h in re.split(r"(..)(..)(..)", rgb)[1:4]]
      res = []
      for part in parts:
          i = 0
          while i < len(incs) - 1:
              s, b = incs[i], incs[i + 1]  # smaller, bigger
              if s <= part <= b:
                  s1 = abs(s - part)
                  b1 = abs(b - part)
                  if s1 < b1:
                      closest = s
                  else:
                      closest = b
                  res.append(closest)
                  break
              i += 1
      _res = "".join([("%02.x" % i) for i in res])
      equiv = RGB2SHORT_DICT[_res]
      return equiv, _res
  
file_path: kornia/kornia/utils/image_print.py
imports: import re
  from typing import Tuple, Union
  from torch import float16, float32, float64
  import kornia
  from kornia.core import Tensor
  from kornia.core.check import KORNIA_CHECK_IS_IMAGE, KORNIA_CHECK_SHAPE
  from kornia.io import ImageLoadType
label_desc: Use image node_id 4 for calling a global function with example usage: rgb2short(rgb) and returns: equiv,  _res