code: def macro_avg(class_metrics):
      """
      Takes a dictionary of class metrics and calculates macro F1
  
      :param class_metrics: A dictionary of class metrics as produced by
      calc_class_metrics()
      :return: Macro F1
      """
      f1s = [c["f1-score"] for c in class_metrics.values()]
      return np.average(f1s)
  
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 14 for calling a global function with example usage: macro_avg(class_metrics) and returns: np