<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def heatmap(data, scale, vmin=None, vmax=None, cmap=None, ax=None, scientific=False, style='triangular', colorbar=True, permutation=None, use_rgba=False, cbarlabel=None, cb_kwargs=None):
 """ Plots heatmap of given color values. Parameters data: dictionary A dictionary mapping the i, j polygon to the heatmap color, where i + j + k = scale. scale: Integer The scale used to partition the simplex. vmin: float, None The minimum color value, used to normalize colors. Computed if absent. vmax: float, None The maximum color value, used to normalize colors. Computed if absent. cmap: String or matplotlib.colors.Colormap, None The name of the Matplotlib colormap to use. ax: Matplotlib AxesSubplot, None The subplot to draw on. scientific: Bool, False Whether to use scientific notation for colorbar numbers. style: String, "triangular" The style of the heatmap, "triangular", "dual-triangular" or "hexagonal" colorbar: bool, True Show colorbar. permutation: string, None A permutation of the coordinates use_rgba: bool, False Use rgba color values cbarlabel: string, None Text label for the colorbar cb_kwargs: dict dict of kwargs to pass to colorbar Returns ------- ax: The matplotlib axis """


    if not ax:
        fig, ax = pyplot.subplots()
    # If use_rgba, make the RGBA values numpy arrays so that they can
    # be averaged.
    if use_rgba:
        for k, v in data.items():
            data[k] = numpy.array(v)
    else:
        cmap = get_cmap(cmap)
        if vmin is None:
            vmin = min(data.values())
        if vmax is None:
            vmax = max(data.values())
    style = style.lower()[0]
    if style not in ["t", "h", 'd']:
        raise ValueError("Heatmap style must be 'triangular', 'dual-triangular', or 'hexagonal'")

    vertices_values = polygon_generator(data, scale, style,
                                        permutation=permutation)

    # Draw the polygons and color them
    for vertices, value in vertices_values:
        if value is None:
            continue
        if not use_rgba:
            color = colormapper(value, vmin, vmax, cmap=cmap)
        else:
            color = value  # rgba tuple (r,g,b,a) all in [0,1]
        # Matplotlib wants a list of xs and a list of ys
        xs, ys = unzip(vertices)
        ax.fill(xs, ys, facecolor=color, edgecolor=color)

    if not cb_kwargs:
        cb_kwargs = dict()
    if colorbar:
        colorbar_hack(ax, vmin, vmax, cmap, scientific=scientific,
                      cbarlabel=cbarlabel, **cb_kwargs)
    return ax