code: def _string_to_rgb(color):
      """Convert user string or hex color to color array (length 3 or 4)"""
      if not color.startswith("#"):
          if color.lower() not in _color_dict:
              raise ValueError('Color "%s" unknown' % color)
          color = _color_dict[color.lower()]
          assert color[0] == "#"
      # hex color
      color = color[1:]
      lc = len(color)
      if lc in (3, 4):
          color = "".join(c + c for c in color)
          lc = len(color)
      if lc not in (6, 8):
          raise ValueError(
              "Hex color must have exactly six or eight "
              "elements following the # sign"
          )
      color = np.array(
          [int(color[i : i + 2], 16) / 255.0 for i in range(0, lc, 2)]
      )
      return color
  
imports: from __future__ import division
  import numpy
  from copy import deepcopy
  from ..util import logger
  from ._color_dict import _color_dict
  from .color_space import _hex_to_rgba, _rgb_to_hex, _rgb_to_hsv, _hsv_to_rgb, _rgb_to_lab, _lab_to_rgb
label_desc: Use image node_id 1 for calling a global function with example usage: _string_to_rgb(color) and returns: color