def load_model_decode(data, name):
    print('Load Model from file: {}, name={}'.format(data.model_dir, name))
    if data.sentence_classification:
        model = SentClassifier(data)
    else:
        model = SeqLabel(data)
    model.load_state_dict(torch.load(data.load_model_dir))
    print(('Decode %s data, nbest: %s ...' % (name, data.nbest)))
    start_time = time.time()
    (speed, acc, p, r, f, pred_results, pred_scores) = evaluate(data, model, name, data.nbest)
    end_time = time.time()
    time_cost = (end_time - start_time)
    if data.seg:
        print(('%s: time:%.2fs, speed:%.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (name, time_cost, speed, acc, p, r, f)))
    else:
        print(('%s: time:%.2fs, speed:%.2fst/s; acc: %.4f' % (name, time_cost, speed, acc)))
    return (pred_results, pred_scores)
def load_model_decode(data, name):
    print('Load Model from file: {}, name={}'.format(data.model_dir, name))
    if data.sentence_classification:
        model = SentClassifier(data)
    else:
        model = SeqLabel(data)
    model.load_state_dict(torch.load(data.load_model_dir))
    print(('Decode %s data, nbest: %s ...' % (name, data.nbest)))
    start_time = time.time()
    (speed, acc, p, r, f, pred_results, pred_scores) = evaluate(data, model, name, data.nbest)
    end_time = time.time()
    time_cost = (end_time - start_time)
    if data.seg:
        print(('%s: time:%.2fs, speed:%.2fst/s; acc: %.4f, p: %.4f, r: %.4f, f: %.4f' % (name, time_cost, speed, acc, p, r, f)))
    else:
        print(('%s: time:%.2fs, speed:%.2fst/s; acc: %.4f' % (name, time_cost, speed, acc)))
    return (pred_results, pred_scores)