code: def get_count_fn(metric_type, span_type):
      """
      Returns a function used to count TPs, FPs and FNs between two groups
  
      Group count functions compare based on the label of the group and the text
      spans contained within the group.
  
      Joint count functions compare based on the label of the group and the
      entity spans contained within the group. Requires groups to be in joint
      group format with an "entities" key.
  
      :param metric_type: A string, either "group" or "joint"
      :param span_type: A string, one of "exact", "token", "overlap", "superset"
      :return: A function that takes two groups and returns a Counts namedtuple
      """
      fns = {
          "group": {
              "exact": group_exact_counts,
              "token": group_token_counts,
              "overlap": group_overlap_counts,
              "superset": group_superset_counts,
          },
          "joint": {
              "exact": joint_exact_counts,
              "token": joint_token_counts,
              "overlap": joint_overlap_counts,
              "superset": joint_superset_counts,
          },
      }
      return fns[metric_type.lower()][span_type.lower()]
  
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 9 for calling a global function with example usage: get_count_fn(metric_type, span_type) and returns: fns