def METHOD_NAME(save_path, image_groundtruth, groundtruth,
                               image_predict, predict, legend):
    tail = save_path.split(".")[-1]
    save_path = (save_path[:-len(tail)] + "png")
    import matplotlib.patches as mpatches
    from matplotlib import use
    use('Agg')
    if image_groundtruth is not None:
        image_groundtruth = image_groundtruth[..., ::-1]
    image_predict = image_predict[..., ::-1]
    if groundtruth is not None:
        groundtruth = groundtruth[..., ::-1]
    predict = predict[..., ::-1]
    fig = plt.figure()
    red_patches = []
    for key, value in legend.items():
        red_patch = mpatches.Patch(
            color=[x / 255.0 for x in value[::-1]], label=key)
        red_patches.append(red_patch)
    plt.legend(
        handles=red_patches, bbox_to_anchor=(1.05, 0), loc=3, borderaxespad=0)
    plt.axis('off')
    if image_groundtruth is not None and \
            groundtruth is not None:
        left, bottom, width, height = 0.02, 0.51, 0.38, 0.38
        fig.add_axes([left, bottom, width, height])
        plt.imshow(image_groundtruth)
        plt.axis('off')
        plt.title("Ground Truth", loc='left')
        left, bottom, width, height = 0.52, 0.51, 0.38, 0.38
        fig.add_axes([left, bottom, width, height])
        plt.imshow(groundtruth)
        plt.axis('off')
        left, bottom, width, height = 0.01, 0.5, 0.9, 0.45
        fig.add_axes([left, bottom, width, height])
        currentAxis = plt.gca()
        rect = patches.Rectangle(
            (0.0, 0.0), 1.0, 1.0, linewidth=1, edgecolor='k', facecolor='none')
        currentAxis.add_patch(rect)
        plt.axis('off')
        left, bottom, width, height = 0.02, 0.06, 0.38, 0.38
        fig.add_axes([left, bottom, width, height])
        plt.imshow(image_predict)
        plt.axis('off')
        plt.title("Prediction", loc='left')
        left, bottom, width, height = 0.52, 0.06, 0.38, 0.38
        fig.add_axes([left, bottom, width, height])
        plt.imshow(predict)
        plt.axis('off')
        left, bottom, width, height = 0.01, 0.05, 0.9, 0.45
        fig.add_axes([left, bottom, width, height])
        currentAxis = plt.gca()
        rect = patches.Rectangle(
            (0.0, 0.0), 1.0, 1.0, linewidth=1, edgecolor='k', facecolor='none')
        currentAxis.add_patch(rect)
        plt.axis('off')
    else:
        plt.subplot(1, 2, 1)
        plt.imshow(image_predict)
        plt.axis('off')
        plt.title("Combination ", y=-0.12)
        plt.subplot(1, 2, 2)
        plt.imshow(predict)
        plt.axis('off')
        plt.title("Prediction", y=-0.12)
    plt.savefig(save_path, dpi=200, bbox_inches='tight')
    plt.close()