def importance_matrix(sensitivities, data, print_imp=True, show_table=True, tag_to_ablate=None):
    '\n    Builds a matrix of tag sensitivities\n    :param sensitivities: This is a matrix of [num_tags, num_neurons],\n    which is [10 x 50] in our experimental configuration.\n    :return:\n    '
    important_lists = []
    important_nps = np.zeros(50, dtype=int)
    sensitivities = sensitivities[1:]
    for i in range(len(sensitivities)):
        important_list = []
        important_np = np.zeros(50, dtype=int)
        tag_sensitivity_row = sensitivities[i]
        for j in range(len(tag_sensitivity_row)):
            most_important = np.argmax(tag_sensitivity_row)
            important_list.append(most_important)
            important_np[j] = most_important
            index = [most_important]
            tag_sensitivity_row[most_important] = np.NINF
        important_lists.append(important_list)
        important_nps = np.vstack((important_nps, important_np))
    important_nps = np.delete(important_nps, 0, axis=0)
    np.save('imps.npy', important_nps)
    important_nps = np.transpose(important_nps)
    if show_table:
        sns.set()
        sns.set(font_scale=0.5)
        x_tick = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
        del x_tick[0]
        ax = sns.heatmap(important_nps, annot=True, xticklabels=x_tick, cmap=ListedColormap(['white']), cbar=False, yticklabels=False, linecolor='gray', linewidths=0.4)
        title = 'Importance rankings of neurons per tag'
        plt.title(title, fontsize=18)
        ttl = ax.title
        ttl.set_position([0.5, 1.05])
        plt.show()

        def trim_model_dir(model_dir):
            model_dir = model_dir.replace('/', '-')
            return model_dir
        ax.figure.savefig('ImportanceRankings-{}.png'.format(trim_model_dir(data.model_dir)))
    if print_imp:
        imp_file = open('Importance-{}.txt'.format(trim_model_dir(data.model_dir)), 'w+')
        print('Neuron importance ranking for each NER tag:')
        for (i, l) in enumerate(important_lists):
            tags = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
            del tags[0]
            print('\t{}\t{}'.format(tags[i], l))
            imp_file.write('{}\t{}\n'.format(tags[i], l))
        imp_file.write('\n')
        np.savetxt('Importance-{}.tsv'.format(trim_model_dir(data.model_dir)), important_nps, fmt='%2.0d', delimiter='\t')
    return important_nps
Builds a matrix of tag sensitivities
:param sensitivities: This is a matrix of [num_tags, num_neurons],
which is [10 x 50] in our experimental configuration.
:return:
def importance_matrix(sensitivities, data, print_imp=True, show_table=True, tag_to_ablate=None):
    '\n    Builds a matrix of tag sensitivities\n    :param sensitivities: This is a matrix of [num_tags, num_neurons],\n    which is [10 x 50] in our experimental configuration.\n    :return:\n    '
    important_lists = []
    important_nps = np.zeros(50, dtype=int)
    sensitivities = sensitivities[1:]
    for i in range(len(sensitivities)):
        important_list = []
        important_np = np.zeros(50, dtype=int)
        tag_sensitivity_row = sensitivities[i]
        for j in range(len(tag_sensitivity_row)):
            most_important = np.argmax(tag_sensitivity_row)
            important_list.append(most_important)
            important_np[j] = most_important
            index = [most_important]
            tag_sensitivity_row[most_important] = np.NINF
        important_lists.append(important_list)
        important_nps = np.vstack((important_nps, important_np))
    important_nps = np.delete(important_nps, 0, axis=0)
    np.save('imps.npy', important_nps)
    important_nps = np.transpose(important_nps)
    if show_table:
        sns.set()
        sns.set(font_scale=0.5)
        x_tick = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
        del x_tick[0]
        ax = sns.heatmap(important_nps, annot=True, xticklabels=x_tick, cmap=ListedColormap(['white']), cbar=False, yticklabels=False, linecolor='gray', linewidths=0.4)
        title = 'Importance rankings of neurons per tag'
        plt.title(title, fontsize=18)
        ttl = ax.title
        ttl.set_position([0.5, 1.05])
        plt.show()

        def trim_model_dir(model_dir):
            model_dir = model_dir.replace('/', '-')
            return model_dir
        ax.figure.savefig('ImportanceRankings-{}.png'.format(trim_model_dir(data.model_dir)))
    if print_imp:
        imp_file = open('Importance-{}.txt'.format(trim_model_dir(data.model_dir)), 'w+')
        print('Neuron importance ranking for each NER tag:')
        for (i, l) in enumerate(important_lists):
            tags = [data.label_alphabet.get_instance(tag) for tag in sorted(data.tag_counts)]
            del tags[0]
            print('\t{}\t{}'.format(tags[i], l))
            imp_file.write('{}\t{}\n'.format(tags[i], l))
        imp_file.write('\n')
        np.savetxt('Importance-{}.tsv'.format(trim_model_dir(data.model_dir)), important_nps, fmt='%2.0d', delimiter='\t')
    return important_nps