<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hist2d(h, axes=None, colorbar=False, **kwargs):
 """ Draw a 2D matplotlib histogram plot from a 2D ROOT histogram. Parameters h : Hist2D A rootpy Hist2D axes : matplotlib Axes instance, optional (default=None) The axes to plot on. If None then use the global current axes. colorbar : Boolean, optional (default=False) If True, include a colorbar in the produced plot kwargs : additional keyword arguments, optional Additional keyword arguments are passed directly to matplotlib's hist2d function. Returns ------- Returns the value from matplotlib's hist2d function. """

    if axes is None:
        axes = plt.gca()
    X, Y = np.meshgrid(list(h.x()), list(h.y()))
    x = X.ravel()
    y = Y.ravel()
    z = np.array(h.z()).T
    # returns of hist2d: (counts, xedges, yedges, Image)
    return_values = axes.hist2d(x, y, weights=z.ravel(),
                                bins=(list(h.xedges()), list(h.yedges())),
                                **kwargs)
    if colorbar:
        mappable = return_values[-1]
        plt.colorbar(mappable, ax=axes)
    return return_values