code: def get_average(average, class_metrics):
      """
      Calculates average F1
  
      :param average: A string, one of "micro", "macro", "weighted"
      :param class_metrics: A dictionary of class metrics as produced by
      calc_class_metrics()
      :return: Average F1 as calculated by the appropriate function
      """
      fns = {
          "micro": micro_avg,
          "macro": macro_avg,
          "weighted": weighted_avg,
      }
      return fns[average.lower()](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 16 for calling a global function with example usage: get_average(average, class_metrics) and returns: fns