code: def group_exact_counts(pred, label):
      """
      Return TP if groups match exactly
  
      :param pred, label: A group, represeted as a dict
      :return: A Counts namedtuple with TP, FP and FN counts
      """
      if pred["label"] != label["label"] or len(pred["spans"]) != len(
          label["spans"]
      ):
          return Counts(0, 1, 1)
      pred_spans = sorted(pred["spans"], key=lambda x: x["start"])
      label_spans = sorted(label["spans"], key=lambda x: x["start"])
      for pred_span, label_span in zip(pred_spans, label_spans):
          if (
              pred_span["start"] != label_span["start"]
              or pred_span["end"] != label_span["end"]
          ):
              return Counts(0, 1, 1)
      return Counts(1, 0, 0)
  
imports: from copy import deepcopy
  from collections import namedtuple
  import numpy
  from scipy.optimize import linear_sum_assignment
  from finetune.util.metrics import _convert_to_token_list, _get_unique_classes, calc_precision, calc_recall, calc_f1
label_desc: Use image node_id 1 for calling a global function with example usage: group_exact_counts(pred, label) and returns: Counts, Counts, Counts