code: def balanced_mean(arr):
      # each entry is of the form (acc score, class label)
      # first group the results
      by_class = defaultdict(list)
      for acc, label in arr:
          by_class[label].append(acc)
  
      # calculate class averages
      avgs = []
      for key, vals in by_class.items():
          avgs.append(sum(vals) / len(vals))
  
      # average the class values
      return sum(avgs) / len(avgs)
  
imports: import math
  from collections.abc import Iterable
  import numpy
  import sacrebleu
  import sklearn.metrics
  import random
  from collections import defaultdict
label_desc: Use image node_id 6 for calling a global function with example usage: balanced_mean(arr) and returns: unknown