code: def group_metrics(preds, labels, span_type="exact", average=None):
      """
      Takes a set of group predictions and labels and returns either per-class
      metrics or average metrics.
  
      :param preds, labels: A list of list of groups. Output from joint grouping
      models should be unzipped to seperate group and NER predictions before
      being evaluated.
      :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
      """
      return get_metrics(
          preds,
          labels,
          metric_type="group",
          span_type=span_type,
          average=average,
      )
  
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 21 for calling a global function with example usage: group_metrics(preds, labels, span_type, average) and returns: get_metrics