code: def _listify_validator(
      scalar_validator, allow_stringlist=False, *, n=None, doc=None
  ):
      def f(s):
          if isinstance(s, str):
              try:
                  val = [
                      scalar_validator(v.strip())
                      for v in s.split(",")
                      if v.strip()
                  ]
              except Exception:
                  if allow_stringlist:
                      # Sometimes, a list of colors might be a single string
                      # of single-letter colornames. So give that a shot.
                      val = [
                          scalar_validator(v.strip())
                          for v in s
                          if v.strip()
                      ]
                  else:
                      raise
          # Allow any ordered sequence type -- generators, np.ndarray, pd.Series
          # -- but not sets, whose iteration order is non-deterministic.
          elif np.iterable(s) and not isinstance(s, (set, frozenset)):
              # The condition on this list comprehension will preserve the
              # behavior of filtering out any empty strings (behavior was
              # from the original validate_stringlist()), while allowing
              # any non-string/text scalar values such as numbers and arrays.
              val = [
                  scalar_validator(v)
                  for v in s
                  if not isinstance(v, str) or v
              ]
          else:
              raise ValueError(
                  f"Expected str or other non-set iterable, but got {s}"
              )
          if n is not None and len(val) != n:
              raise ValueError(
                  f"Expected {n} values, but there are {len(val)} values in {s}"
              )
          return val
  
      try:
          f.__name__ = f"{scalar_validator.__name__}list"
      except AttributeError:  # class instance.
          f.__name__ = f"{type(scalar_validator).__name__}List"
      f.__qualname__ = (
          f.__qualname__.rsplit(".", 1)[0] + "." + f.__name__
      )
      f.__doc__ = doc if doc is not None else scalar_validator.__doc__
      return f
  
imports: import ast
  from functools import lru_cache, reduce
  from numbers import Real
  import operator
  import os
  import re
  import numpy
  from matplotlib import _api, cbook
  from matplotlib.cbook import ls_mapper
  from matplotlib.colors import Colormap, is_color_like
  from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
  from matplotlib._enums import JoinStyle, CapStyle
  from cycler import Cycler, cycler
label_desc: Use image node_id 1 for calling a global function with example usage: _listify_validator(scalar_validator, allow_stringlist) and returns: f, val