def METHOD_NAME(cost_matrix, path, ax, theme=None):
    _check_soft_dependencies("matplotlib")
    import matplotlib.colors as colorplt
    if theme is None:
        theme = colorplt.LinearSegmentedColormap.from_list("", ["#c9cacb", "white"])
    plot_matrix = np.zeros_like(cost_matrix)
    max_size = max(cost_matrix.shape)
    for i in range(max_size):
        for j in range(max_size):
            if (i, j) in path:
                plot_matrix[i, j] = 1.0
            elif cost_matrix[i, j] == np.inf:
                plot_matrix[i, j] = 0.0
            else:
                plot_matrix[i, j] = 0.25
    for i in range(max_size):
        for j in range(max_size):
            c = cost_matrix[j, i]
            ax.text(i, j, str(round(c, 2)), va="center", ha="center", size=10)
            ax.text(i, j, str(round(c, 2)), va="center", ha="center", size=10)
    ax.matshow(plot_matrix, cmap=theme)