text: from fairseq.models.roberta import RobertaModel
  
  alias = ""
  
  roberta = RobertaModel.from_pretrained(
      f'/home/{alias}/data/linyong/cu/checkpoints/roberta_base_125k/finetune_QNLI',
      checkpoint_file='checkpoint_best.pt',
      data_name_or_path=f'/home/{alias}/data/linyong/cu/glue_data/bin/allcorpus_sp/QNLI-sp-bin',
      bpe="sentencepiece"
  )
  
  label_fn = lambda label: roberta.task.label_dictionary.string(
      [label + roberta.task.label_dictionary.nspecial]
  )
  ncorrect, nsamples = 0, 0
  roberta.cuda()
  roberta.eval()
  
  test_data_path = "../language_model/glue_data/QNLI/dev.tsv" # 2 classes
  # test_data_path = "../language_model/glue_data/MNLI/dev_matched.tsv" # 3 classes
  # test_data_path = "../language_model/glue_data/MNLI/dev_mismatched.tsv" # 3 classes
  
  # test_data_path = "EQUATE/raw/RTE_Quant.tsv" # 2 classes
  # test_data_path = "EQUATE/raw/NewsNLI.tsv" # 2 classes
  # test_data_path = "EQUATE/raw/AWPNLI.tsv" # 2 classes
  # test_data_path = "EQUATE/raw/RedditNLI.tsv" # 3 classes
  # test_data_path = "EQUATE/raw/StressTest.tsv" # 3 classes
  
  s1_i, s2_i, l_i = 1, 2, 3 # QNLI dev
  # s1_i, s2_i, l_i = 8, 9, 15 # MNLI dev
  # s1_i, s2_i, l_i = 0, 1, 2 # EQUATE
  
  with open(test_data_path) as fin:
      fin.readline()
      for index, line in enumerate(fin):
          tokens = line.strip().split('\t')
          sent1, sent2, target = tokens[s1_i], tokens[s2_i], tokens[l_i]
          tokens = roberta.encode(sent1, sent2)
          prediction = roberta.predict('sentence_classification_head', tokens).argmax().item()
          prediction_label = label_fn(prediction)
          ncorrect += int(prediction_label == target)
          nsamples += 1
  print('| Accuracy: ', float(ncorrect)/float(nsamples))