code: def register_cmap(name=None, cmap=None, data=None, lut=None):
      """
      Add a colormap to the set recognized by :func:`get_cmap`.
  
      It can be used in two ways::
  
          register_cmap(name='swirly', cmap=swirly_cmap)
  
          register_cmap(name='choppy', data=choppydata, lut=128)
  
      In the first case, *cmap* must be a :class:`matplotlib.colors.Colormap`
      instance.  The *name* is optional; if absent, the name will
      be the :attr:`~matplotlib.colors.Colormap.name` attribute of the *cmap*.
  
      In the second case, the three arguments are passed to
      the :class:`~matplotlib.colors.LinearSegmentedColormap` initializer,
      and the resulting colormap is registered.
  
      """
      if name is None:
          try:
              name = cmap.name
          except AttributeError:
              raise ValueError(
                  "Arguments must include a name or a Colormap"
              )
  
      if not isinstance(name, six.string_types):
          raise ValueError("Colormap name must be a string")
  
      if isinstance(cmap, colors.Colormap):
          cmap_d[name] = cmap
          return
  
      # For the remainder, let exceptions propagate.
      if lut is None:
          lut = mpl.rcParams["image.lut"]
      cmap = colors.LinearSegmentedColormap(name, data, lut)
      cmap_d[name] = cmap
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import numpy
  from numpy import ma
  import matplotlib
  import matplotlib.colors
  import matplotlib.cbook
  from matplotlib._cm import datad
  from matplotlib._cm_listed import cmaps
label_desc: Use image node_id 5 for calling a global function with example usage: register_cmap(name, cmap, data, lut) without return types