human
Complete the below
def colorbar(mappable, cax=None, ax=None, **kw):

    ''''Create a colorbar for a ScalarMappable instance.
    Documentation for the pylab thin wrapper:
    %(colorbar_doc)s'
    '''
 ... Give me a the Python code you requested?
assistant
#Here is the Python code you requested.
    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(u'changed', on_changed)
    mappable.colorbar = cb
    ax.figure.sca(ax)
    return cb