code: def probability_of_improvement(
      scores_x: np.ndarray, scores_y: np.ndarray
  ):
      """Overall Probability of imporvement of algorithm `X` over `Y`.
  
      Args:
        scores_x: A matrix of size (`num_runs_x` x `num_tasks`) where scores_x[n][m]
          represent the score on run `n` of task `m` for algorithm `X`.
        scores_y: A matrix of size (`num_runs_y` x `num_tasks`) where scores_x[n][m]
          represent the score on run `n` of task `m` for algorithm `Y`.
      Returns:
          P(X_m > Y_m) averaged across tasks.
      """
      num_tasks = scores_x.shape[1]
      task_improvement_probabilities = []
      num_runs_x, num_runs_y = scores_x.shape[0], scores_y.shape[0]
      for task in range(num_tasks):
          if np.array_equal(scores_x[:, task], scores_y[:, task]):
              task_improvement_prob = 0.5
          else:
              task_improvement_prob, _ = scipy.stats.mannwhitneyu(
                  scores_x[:, task],
                  scores_y[:, task],
                  alternative="greater",
              )
              task_improvement_prob /= num_runs_x * num_runs_y
          task_improvement_probabilities.append(task_improvement_prob)
      return np.mean(task_improvement_probabilities)
  
imports: import numpy
  import scipy.stats
label_desc: Use image node_id 5 for calling a global function with example usage: probability_of_improvement(scores_x, scores_y) and returns: np