def plot_attention(attention, sentence, predicted_sentence, img_path):
    """
    Plotting the attention weights
    :param attention:
    :param sentence:
    :param predicted_sentence:
    :param img_path:
    :return:
    """
    import matplotlib.pyplot as plt
    import matplotlib.ticker as ticker
    from matplotlib import font_manager
    my_font = font_manager.FontProperties(fname='/Library/Fonts/Songti.ttc')
    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(1, 1, 1)
    ax.matshow(attention, cmap='viridis')
    fontdict = {'fontsize': 12}
    ax.set_xticklabels([''] + sentence, fontdict=fontdict, fontproperties=
        my_font)
    ax.set_yticklabels([''] + predicted_sentence, fontdict=fontdict,
        fontproperties=my_font)
    ax.xaxis.set_major_locator(ticker.MultipleLocator(1))
    ax.yaxis.set_major_locator(ticker.MultipleLocator(1))
    plt.savefig(img_path)
    print('save attention weight image to :', img_path)
    plt.clf()
