code: def get_ner_scores(all_gt, all_predictions):
      """
      Evalutes per-label and overall (micro and macro) metrics
      of precision, recall, and fscore
      Input:
          all_gt/all_predictions:
              List of list of tuples: (label, phrase, identifier)
              Each list of tuples correspond to a sentence:
                  label: entity tag
                  phrase: entity phrase
                  tuple_identifier: identifier to differentiate
                  repeating (label, phrase) pairs
      Returns:
          Dictionary of metrics
      Example:
          List of GT (label, phrase) pairs of a sentence:
          [(GPE, "eu"), (DATE, "today"), (GPE, "eu")]
          all_gt: [(GPE, "eu", 0), (DATE, "today", 0), (GPE, "eu", 1)]
      """
      metrics = {}
      stats = get_ner_stats(all_gt, all_predictions)
      num_correct, num_gt, num_pred = 0, 0, 0
      prec_lst, recall_lst, fscore_lst = [], [], []
      for tag_name, tag_stats in stats.items():
          precision, recall, fscore = get_metrics(
              np.sum(tag_stats["tp"]),
              np.sum(tag_stats["gt_cnt"]),
              np.sum(tag_stats["pred_cnt"]),
          )
          _ = metrics.setdefault(tag_name, {})
          metrics[tag_name]["precision"] = precision
          metrics[tag_name]["recall"] = recall
          metrics[tag_name]["fscore"] = fscore
  
          num_correct += np.sum(tag_stats["tp"])
          num_pred += np.sum(tag_stats["pred_cnt"])
          num_gt += np.sum(tag_stats["gt_cnt"])
  
          prec_lst.append(precision)
          recall_lst.append(recall)
          fscore_lst.append(fscore)
  
      precision, recall, fscore = get_metrics(
          num_correct, num_gt, num_pred
      )
      metrics["overall_micro"] = {}
      metrics["overall_micro"]["precision"] = precision
      metrics["overall_micro"]["recall"] = recall
      metrics["overall_micro"]["fscore"] = fscore
  
      metrics["overall_macro"] = {}
      metrics["overall_macro"]["precision"] = np.mean(prec_lst)
      metrics["overall_macro"]["recall"] = np.mean(recall_lst)
      metrics["overall_macro"]["fscore"] = np.mean(fscore_lst)
  
      return metrics
  
file_path: espnet/egs2/slue-voxpopuli/asr1/local/eval_utils.py
imports: from collections import defaultdict
  from typing import List
  import editdistance
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: get_ner_scores(all_gt, all_predictions) and returns: metrics