code: def _get_color_filter(name):
      """
      Given a color filter name, create a color filter function.
  
      Parameters
      ----------
      name : str
          The color filter name, one of the following:
  
          - ``"none"``: ...
          - ``"greyscale"``: Convert the input to luminosity.
          - ``"deuteranopia"``: Simulate the most common form of red-green
            colorblindness.
          - ``"protanopia"``: Simulate a rarer form of red-green colorblindness.
          - ``"tritanopia"``: Simulate the rare form of blue-yellow
            colorblindness.
  
          Color conversions use `colorspacious`_.
  
      Returns
      -------
      callable
          A color filter function that has the form:
  
          def filter(input: np.ndarray[M, N, D])-> np.ndarray[M, N, D]
  
          where (M, N) are the image dimensions, and D is the color depth (3 for
          RGB, 4 for RGBA). Alpha is passed through unchanged and otherwise
          ignored.
      """
      if name not in _MENU_ENTRIES:
          raise ValueError(f"Unsupported filter name: {name!r}")
      name = _MENU_ENTRIES[name]
  
      if name is None:
          return None
  
      elif name == "greyscale":
          rgb_to_jch = colorspacious.cspace_converter("sRGB1", "JCh")
          jch_to_rgb = colorspacious.cspace_converter("JCh", "sRGB1")
  
          def convert(im):
              greyscale_JCh = rgb_to_jch(im)
              greyscale_JCh[..., 1] = 0
              im = jch_to_rgb(greyscale_JCh)
              return im
  
      else:
          cvd_space = {
              "name": "sRGB1+CVD",
              "cvd_type": name,
              "severity": 100,
          }
          convert = colorspacious.cspace_converter(cvd_space, "sRGB1")
  
      def filter_func(im, dpi):
          alpha = None
          if im.shape[-1] == 4:
              im, alpha = im[..., :3], im[..., 3]
          im = convert(im)
          if alpha is not None:
              im = np.dstack((im, alpha))
          return np.clip(im, 0, 1), 0, 0
  
      return filter_func
  
file_path: matplotlib/galleries/examples/user_interfaces/mplcvd.py
imports: import functools
  from pathlib import Path
  import colorspacious
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _get_color_filter(name) and returns: filter_func, None, np,  int,  int, im