code: def losses_over_time(
      runs,
      get_loss_from_run_fn=lambda r: r.loss,
      cmap=plt.get_cmap("tab10"),
      show=False,
  ):
      budgets = set([r.budget for r in runs])
  
      data = {}
      for b in budgets:
          data[b] = []
  
      for r in runs:
          if r.loss is None:
              continue
          b = r.budget
          t = r.time_stamps["finished"]
          l = get_loss_from_run_fn(r)
          data[b].append((t, l))
  
      for b in budgets:
          data[b].sort()
  
      fig, ax = plt.subplots()
  
      for i, b in enumerate(budgets):
          data[b] = np.array(data[b])
          ax.scatter(
              data[b][:, 0],
              data[b][:, 1],
              color=cmap(i),
              label="b=%f" % b,
          )
  
          ax.step(
              data[b][:, 0],
              np.minimum.accumulate(data[b][:, 1]),
              where="post",
          )
  
      ax.set_title("Losses for different budgets over time")
      ax.set_xlabel("wall clock time [s]")
      ax.set_ylabel("loss")
      ax.legend()
      if show:
          plt.show()
      return (fig, ax)
  
file_path: HpBandSter/hpbandster/visualization.py
imports: import copy
  import numpy
  import scipy.stats
  import matplotlib.pyplot
  from matplotlib.widgets import CheckButtons, Button
label_desc: Use image node_id 6 for calling a global function with example usage: losses_over_time(runs, get_loss_from_run_fn, cmap, show) and returns: fig,  ax