def heatmap_sensitivity(sensitivities, modelname=DEFAULT_TRAINED_FILE, testname='', show_pad=False, show_vals=True, disable=False):
    '\n    Shows a heatmap for the sensitivity values, saves the heatmap to a PNG file,\n    and also saves the sensitivity matrix to an .npy file,\n    which we use for calculating correlations between models later.\n    :param sensitivities: This is a matrix of [num_tags, num_neurons],\n    which is [10 x 50] in our experimental configuration.\n    :param disable: disable is just to turn off for debugging\n    :return:\n    '
    sensitivities = np.transpose(sensitivities)
    start = 1
    if show_pad:
        start = 0
    sensitivities = sensitivities[0:50, start:10]
    sns.set()
    sns.set(font_scale=0.5)
    x_tick = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
    if show_pad:
        x_tick[0] = 'PAD'
    else:
        del x_tick[0]
    sensitivities_temp = np.zeros((50, 9))
    x_tick_output = ['B-PER', 'I-PER', 'B-LOC', 'I-LOC', 'B-ORG', 'I-ORG', 'B-MISC', 'I-MISC', 'O']
    for i in range(len(x_tick_output)):
        sensitivities_temp[:, i] = sensitivities[:, x_tick.index(x_tick_output[i])]
    np.save((modelname + '_sensitivities.npy'), sensitivities_temp)
    if (not disable):
        ax = sns.heatmap(sensitivities, xticklabels=x_tick, annot=show_vals, fmt='.2g')
        title = ('({}): '.format(testname) + modelname)
        plt.title(title, fontsize=18)
        ttl = ax.title
        ttl.set_position([0.5, 1.05])
        plt.show()
        ax.figure.savefig((modelname + '_heatmap.png'))
Shows a heatmap for the sensitivity values, saves the heatmap to a PNG file,
and also saves the sensitivity matrix to an .npy file,
which we use for calculating correlations between models later.
:param sensitivities: This is a matrix of [num_tags, num_neurons],
which is [10 x 50] in our experimental configuration.
:param disable: disable is just to turn off for debugging
:return:
def heatmap_sensitivity(sensitivities, modelname=DEFAULT_TRAINED_FILE, testname=, show_pad=False, show_vals=True, disable=False):
    '\n    Shows a heatmap for the sensitivity values, saves the heatmap to a PNG file,\n    and also saves the sensitivity matrix to an .npy file,\n    which we use for calculating correlations between models later.\n    :param sensitivities: This is a matrix of [num_tags, num_neurons],\n    which is [10 x 50] in our experimental configuration.\n    :param disable: disable is just to turn off for debugging\n    :return:\n    '
    sensitivities = np.transpose(sensitivities)
    start = 1
    if show_pad:
        start = 0
    sensitivities = sensitivities[0:50, start:10]
    sns.set()
    sns.set(font_scale=0.5)
    x_tick = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
    if show_pad:
        x_tick[0] = 'PAD'
    else:
        del x_tick[0]
    sensitivities_temp = np.zeros((50, 9))
    x_tick_output = ['B-PER', 'I-PER', 'B-LOC', 'I-LOC', 'B-ORG', 'I-ORG', 'B-MISC', 'I-MISC', 'O']
    for i in range(len(x_tick_output)):
        sensitivities_temp[:, i] = sensitivities[:, x_tick.index(x_tick_output[i])]
    np.save((modelname + '_sensitivities.npy'), sensitivities_temp)
    if (not disable):
        ax = sns.heatmap(sensitivities, xticklabels=x_tick, annot=show_vals, fmt='.2g')
        title = ('({}): '.format(testname) + modelname)
        plt.title(title, fontsize=18)
        ttl = ax.title
        ttl.set_position([0.5, 1.05])
        plt.show()
        ax.figure.savefig((modelname + '_heatmap.png'))