code: def ner_error_analysis(all_gt, all_predictions, gt_text):
      """
      Print out predictions and GT
      all_gt: [GT] list of tuples of (label, phrase, identifier idx)
      all_predictions: [hypothesis] list of tuples of (label, phrase, identifier idx)
      gt_text: list of GT text sentences
      """
      analysis_examples_dct = {}
      analysis_examples_dct["all"] = []
      for idx, text in enumerate(gt_text):
          if isinstance(text, list):
              text = " ".join(text)
          gt = all_gt[idx]
          pred = all_predictions[idx]
          entities_true = defaultdict(set)
          entities_pred = defaultdict(set)
          for type_name, entity_info1, entity_info2 in gt:
              entities_true[type_name].add((entity_info1, entity_info2))
          for type_name, entity_info1, entity_info2 in pred:
              entities_pred[type_name].add((entity_info1, entity_info2))
          target_names = sorted(
              set(entities_true.keys()) | set(entities_pred.keys())
          )
          analysis_examples_dct["all"].append(
              "\t".join([text, str(gt), str(pred)])
          )
          for tag_name in target_names:
              _ = analysis_examples_dct.setdefault(tag_name, [])
              entities_true_type = entities_true.get(tag_name, set())
              entities_pred_type = entities_pred.get(tag_name, set())
              num_gt = len(entities_true_type)
              num_correct = len(entities_true_type & entities_pred_type)
  
              new_gt = [(item1, item2) for item1, item2, _ in gt]
              new_pred = [(item1, item2) for item1, item2, _ in pred]
              analysis_examples_dct[tag_name].append(
                  "\t".join([text, str(new_gt), str(new_pred)])
              )
  
      return analysis_examples_dct
  
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 4 for calling a global function with example usage: ner_error_analysis(all_gt, all_predictions, gt_text) and returns: analysis_examples_dct