code: def aggregate_individual_pic_results(
      compute_pic_metrics_results: List[PicMetricResult],
      method: str = "median",
  ) -> AggregateMetricResult:
      """Aggregates PIC metrics of individual images to produce the aggregate curve.
  
      The method should be called after calling the compute_pic_metric(...) method
      on multiple images for a given single saliency method.
  
      Args:
        compute_pic_metrics_results: a list of PicMetricResult instances that are
          obtained by calling compute_pic_metric(...) on multiple images.
        method: method to use for the aggregation. The valid values are 'mean' and
          'median'.
      Returns:
        AggregateMetricResult - a tuple with x, y coordinates of the curve along
          with the AUC value.
  
  
      """
      if not compute_pic_metrics_results:
          raise ValueError(
              "The list of results should have at least one element."
          )
  
      curve_ys = [r.curve_y for r in compute_pic_metrics_results]
      curve_ys = np.asarray(curve_ys)
  
      # Validate that x-axis points for all individual results are the same.
      curve_xs = [r.curve_x for r in compute_pic_metrics_results]
      curve_xs = np.asarray(curve_xs)
      _, counts = np.unique(curve_xs, axis=1, return_counts=True)
      if not np.all(counts == 1):
          raise ValueError(
              "Individual results have different x-axis data points."
          )
  
      if method == "mean":
          aggr_curve_y = np.mean(curve_ys, axis=0)
      elif method == "median":
          aggr_curve_y = np.median(curve_ys, axis=0)
      else:
          raise ValueError("Unknown method {}.".format(method))
  
      auc = np.trapz(aggr_curve_y, curve_xs[0])
  
      return AggregateMetricResult(
          curve_x=curve_xs[0], curve_y=aggr_curve_y, auc=auc
      )
  
file_path: saliency/saliency/metrics/pic.py
imports: import io
  import numpy
  import os
  from PIL import Image
  from scipy import interpolate
  from typing import Callable, List, NamedTuple, Optional, Sequence, Tuple
label_desc: Use image node_id 5 for calling a global function with example usage: aggregate_individual_pic_results(compute_pic_metrics_results, method) and returns: AggregateMetricResult