code: def get_metrics(
      preds,
      labels,
      metric_type="group",
      span_type="exact",
      average=None,
  ):
      """
      Takes a set of group or joint group predictions and labels and returns
      either per-class metrics or average metrics.
  
      :param preds, labels: A list of list of groups or joint groups.
      :param span_type: A string, one of "exact", "token", "overlap", "superset"
      :param average: A string, one of "micro", "macro", "weighted"
      :return: Average F1 if average was specified, else per-class metrics
      """
      per_class_metrics = calc_class_metrics(
          preds, labels, metric_type=metric_type, span_type=span_type
      )
      if average:
          # Returns single F1 value
          return get_average(average, per_class_metrics)
      else:
          return per_class_metrics
  
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 17 for calling a global function with example usage: get_metrics(preds, labels, metric_type, span_type, average) and returns: get_average, per_class_metrics