code: def main():
      parser = argparse.ArgumentParser(
          description="Process some integers."
      )
      parser.add_argument(
          "--pred_file",
          type=str,
          help="Text file with test set prompts + model predictions. Prediction file can be made by running NeMo/examples/nlp/language_modeling/megatron_gpt_prompt_learning_eval.py",
      )
      parser.add_argument(
          "--pred_field",
          type=str,
          help="The field in the json file that contains the prediction tokens",
          default="pred",
      )
      parser.add_argument(
          "--label_field",
          type=str,
          help="The field in the json file that contains the ground truth tokens",
          default="label",
      )
  
      args = parser.parse_args()
  
      pred_file = args.pred_file
      scorer = rouge_scorer.RougeScorer(["rougeL"], use_stemmer=True)
      preds = open(pred_file, encoding="utf-8").readlines()
      f1 = exact_match = total = r_score = 0
  
      for i in range(len(preds)):
          pred_line = json.loads(preds[i])
  
          pred_answer = pred_line[args.pred_field]
          true_answers = pred_line[args.label_field]
          if not isinstance(true_answers, list):
              true_answers = [true_answers]
  
          r_scores = []
          for ta in true_answers:
              r_scores.append(
                  scorer.score(ta, pred_answer)["rougeL"].fmeasure
              )
          r_score += max(r_scores)
          exact_match += metric_max_over_ground_truths(
              exact_match_score, pred_answer, true_answers
          )
          f1 += metric_max_over_ground_truths(
              f1_score, pred_answer, true_answers
          )
          total += 1
  
      exact_match = 100.0 * exact_match / total
      f1 = 100.0 * f1 / total
      r_score = 100 * (r_score / total)
      res = {
          "exact_match": exact_match,
          "f1": f1,
          "rougeL": r_score,
          "total": total,
      }
      print("\t".join([f"{k} {v:.3f}" for k, v in res.items()]))
  
file_path: NeMo/scripts/metric_calculation/peft_metric_calc.py
imports: import argparse
  import json
  import re
  import string
  from collections import Counter
  from rouge_score import rouge_scorer
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types