code: def _check_color(color):
      from matplotlib.colors import colorConverter
  
      if isinstance(color, str):
          color = colorConverter.to_rgb(color)
      elif isinstance(color, collections.abc.Iterable):
          np_color = np.array(color)
          if np_color.size % 3 != 0 and np_color.size % 4 != 0:
              raise ValueError(
                  "The expected valid format is RGB or RGBA."
              )
          if np_color.dtype in (np.int64, np.int32):
              if (np_color < 0).any() or (np_color > 255).any():
                  raise ValueError("Values out of range [0, 255].")
          elif np_color.dtype == np.float64:
              if (np_color < 0.0).any() or (np_color > 1.0).any():
                  raise ValueError("Values out of range [0.0, 1.0].")
          else:
              raise TypeError(
                  "Expected data type is `np.int64`, `np.int32`, or `np.float64` but "
                  f"{np_color.dtype} was given."
              )
      else:
          raise TypeError(
              f"Expected type is `str` or iterable but {type(color)} was given."
          )
      return color
  
imports: import collections.abc
  import functools
  import os
  import platform
  import signal
  import sys
  from colorsys import rgb_to_hls
  from contextlib import contextmanager
  from ctypes import c_char_p, c_void_p, cdll
  from pathlib import Path
  import numpy
  from ...fixes import _compare_version
  from ...utils import _check_qt_version, _validate_type, logger, warn
  from ..utils import _get_cmap
label_desc: Use image node_id 2 for calling a global function with example usage: _check_color(color) and returns: color