code: def _reverse_cmap_spec(spec):
      """Reverses cmap specification *spec*, can handle both dict and tuple
      type specs."""
  
      if "listed" in spec:
          return {"listed": spec["listed"][::-1]}
  
      if "red" in spec:
          return revcmap(spec)
      else:
          revspec = list(reversed(spec))
          if len(revspec[0]) == 2:  # e.g., (1, (1.0, 0.0, 1.0))
              revspec = [(1.0 - a, b) for a, b in revspec]
          return revspec
  
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 3 for calling a global function with example usage: _reverse_cmap_spec(spec) and returns: dict, revcmap, revspec