code: def correlation_across_budgets(results_object, show=False):
      runs = results_object.get_all_runs()
      id2conf = results_object.get_id2config_mapping()
  
      budgets = list(set([r.budget for r in runs]))
      budgets.sort()
  
      import itertools
  
      loss_pairs = {}
      for b in budgets[:-1]:
          loss_pairs[b] = {}
  
      for b1, b2 in itertools.combinations(budgets, 2):
          loss_pairs[b1][b2] = []
  
      for cid in id2conf.keys():
          runs = results_object.get_runs_by_id(cid)
          if len(runs) < 2:
              continue
  
          for r1, r2 in itertools.combinations(runs, 2):
              if r1.loss is None or r2.loss is None:
                  continue
              if not np.isfinite(r1.loss) or not np.isfinite(r2.loss):
                  continue
              loss_pairs[float(r1.budget)][float(r2.budget)].append(
                  (r1.loss, r2.loss)
              )
  
      rhos = np.eye(len(budgets) - 1)
      rhos.fill(np.nan)
  
      ps = np.eye(len(budgets) - 1)
      ps.fill(np.nan)
  
      for i in range(len(budgets) - 1):
          for j in range(i + 1, len(budgets)):
              spr = sps.spearmanr(loss_pairs[budgets[i]][budgets[j]])
              rhos[i][j - 1] = spr.correlation
              ps[i][j - 1] = spr.pvalue
  
      fig, ax = plt.subplots()
  
      cax = ax.matshow(rhos, vmin=-1, vmax=1)
      fig.colorbar(cax)
  
      ax.set_yticks(range(len(budgets) - 1))
      ax.set_yticklabels(
          budgets[:-1],
      )
  
      ax.set_xticks(range(len(budgets) - 1))
      ax.set_xticklabels(
          budgets[1:],
      )
  
      ax.set_title("Rank correlation of the loss across the budgets")
  
      for i in range(len(budgets) - 1):
          for j in range(i + 1, len(budgets)):
              plt.text(
                  j - 1,
                  i,
                  r"$\rho_{spearman}= %f$" % rhos[i][j - 1]
                  + "\n"
                  + r"$p = %f$" % ps[i][j - 1]
                  + "\n"
                  + r"$n = %i$"
                  % len(loss_pairs[budgets[i]][budgets[j]]),
                  horizontalalignment="center",
                  verticalalignment="center",
              )
  
      if show:
          plt.show()
      return (fig, ax)
  
file_path: auptimizer/src/aup/Proposer/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 5 for calling a global function with example usage: correlation_across_budgets(results_object, show) and returns: fig,  ax