code: def colorbar(mappable, cax=None, ax=None, **kw):
      """
      Create a colorbar for a ScalarMappable instance.
  
      Documentation for the pylab thin wrapper:
  
      %s
      """
      import matplotlib.pyplot as plt
  
      if ax is None:
          ax = plt.gca()
      if cax is None:
          cax, kw = make_axes(ax, **kw)
      cax._hold = True
      cb = Colorbar(cax, mappable, **kw)
  
      def on_changed(m):
          cb.set_cmap(m.get_cmap())
          cb.set_clim(m.get_clim())
          cb.update_bruteforce(m)
  
      cbid = mappable.callbacksSM.connect("changed", on_changed)
      mappable.colorbar = cb
      ax.figure.sca(ax)
      return cb
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import xrange, zip
  import numpy
  import matplotlib
  import matplotlib.colors
  import matplotlib.cm
  from matplotlib import docstring
  import matplotlib.ticker
  import matplotlib.cbook
  import matplotlib.collections
  import matplotlib.contour
  from matplotlib.path import Path
  from matplotlib.patches import PathPatch
  from matplotlib.transforms import Bbox
label_desc: Use image node_id 2 for calling a global function with example usage: colorbar(mappable, cax, ax) and returns: cb