code: def average_points(points, num_points, cmp):
      averaged = []
      best = []
      for point in points:
          insort(best, point)
          best = best[:num_points] if cmp is min else best[-num_points:]
          averaged.append(sum(best) / len(best))
      return averaged
  
file_path: sockeye/sockeye_contrib/plot_metrics.py
imports: from argparse import ArgumentParser
  from bisect import insort
  from collections import defaultdict
  from os import path
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: average_points(points, num_points, cmp) and returns: averaged