def load_model_to_test(data, train=False, dev=True, test=False, tag=None):
    '\n    Set any ONE of train, dev, test to true, in order to evaluate on that set.\n    :param data:\n    :param train:\n    :param dev: Default set to test, because that was what the original experiment did\n    :param test:\n    :return:\n    '
    print('Load pretrained model...')
    if data.sentence_classification:
        model = SentClassifier(data)
    else:
        model = SeqLabel(data)
    model.load_state_dict(torch.load(data.pretrained_model_path))
    '----------------TESTING----------------'
    if train:
        (speed, acc, p, r, f, _, _, train_sensitivities) = evaluate(data, model, 'train')
        heatmap_sensitivity(train_sensitivities, data.pretrained_model_path, testname='train')
        if data.seg:
            current_score = f
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            current_score = acc
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
    if dev:
        (speed, acc, p, r, f, _, _, sensitivities) = evaluate(data, model, 'dev', tag_to_ablate=tag)
        if data.seg:
            current_score = f
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            current_score = acc
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
        if (data.ablate_num == 0):
            heatmap_sensitivity(sensitivities, data.pretrained_model_path, testname='dev')
            importance_matrix(sensitivities, data)
    if test:
        (speed, acc, p, r, f, _, _) = evaluate(data, model, 'test')
        if data.seg:
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
    return
Set any ONE of train, dev, test to true, in order to evaluate on that set.
:param data:
:param train:
:param dev: Default set to test, because that was what the original experiment did
:param test:
:return:
def load_model_to_test(data, train=False, dev=True, test=False, tag=None):
    '\n    Set any ONE of train, dev, test to true, in order to evaluate on that set.\n    :param data:\n    :param train:\n    :param dev: Default set to test, because that was what the original experiment did\n    :param test:\n    :return:\n    '
    print('Load pretrained model...')
    if data.sentence_classification:
        model = SentClassifier(data)
    else:
        model = SeqLabel(data)
    model.load_state_dict(torch.load(data.pretrained_model_path))
    '----------------TESTING----------------'
    if train:
        (speed, acc, p, r, f, _, _, train_sensitivities) = evaluate(data, model, 'train')
        heatmap_sensitivity(train_sensitivities, data.pretrained_model_path, testname='train')
        if data.seg:
            current_score = f
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            current_score = acc
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
    if dev:
        (speed, acc, p, r, f, _, _, sensitivities) = evaluate(data, model, 'dev', tag_to_ablate=tag)
        if data.seg:
            current_score = f
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            current_score = acc
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
        if (data.ablate_num == 0):
            heatmap_sensitivity(sensitivities, data.pretrained_model_path, testname='dev')
            importance_matrix(sensitivities, data)
    if test:
        (speed, acc, p, r, f, _, _) = evaluate(data, model, 'test')
        if data.seg:
            print(('Speed: %.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (speed, acc, p, r, f)))
        else:
            print(('Speed: %.2fst/s; acc: %.4f' % (speed, acc)))
    return