code: def get_coco_style_results(
      filename,
      task="bbox",
      metric=None,
      prints="mPC",
      aggregate="benchmark",
  ):
      assert aggregate in ["benchmark", "all"]
  
      if prints == "all":
          prints = ["P", "mPC", "rPC"]
      elif isinstance(prints, str):
          prints = [prints]
      for p in prints:
          assert p in ["P", "mPC", "rPC"]
  
      if metric is None:
          metrics = [
              "mAP",
              "mAP_50",
              "mAP_75",
              "mAP_s",
              "mAP_m",
              "mAP_l",
          ]
      elif isinstance(metric, list):
          metrics = metric
      else:
          metrics = [metric]
  
      for metric_name in metrics:
          assert metric_name in [
              "mAP",
              "mAP_50",
              "mAP_75",
              "mAP_s",
              "mAP_m",
              "mAP_l",
          ]
  
      eval_output = load(filename)
  
      num_distortions = len(list(eval_output.keys()))
      results = np.zeros(
          (num_distortions, 6, len(metrics)), dtype="float32"
      )
  
      for corr_i, distortion in enumerate(eval_output):
          for severity in eval_output[distortion]:
              for metric_j, metric_name in enumerate(metrics):
                  metric_dict = eval_output[distortion][severity]
  
                  new_metric_dict = {}
                  for k, v in metric_dict.items():
                      if "/" in k:
                          new_metric_dict[k.split("/")[-1]] = v
                  mAP = new_metric_dict["_".join((task, metric_name))]
                  results[corr_i, severity, metric_j] = mAP
  
      P = results[0, 0, :]
      if aggregate == "benchmark":
          mPC = np.mean(results[:15, 1:, :], axis=(0, 1))
      else:
          mPC = np.mean(results[:, 1:, :], axis=(0, 1))
      rPC = mPC / P
  
      print(f"\nmodel: {osp.basename(filename)}")
      if metric is None:
          if "P" in prints:
              print(f"Performance on Clean Data [P] ({task})")
              print_coco_results(P)
          if "mPC" in prints:
              print(f"Mean Performance under Corruption [mPC] ({task})")
              print_coco_results(mPC)
          if "rPC" in prints:
              print(
                  f"Relative Performance under Corruption [rPC] ({task})"
              )
              print_coco_results(rPC)
      else:
          if "P" in prints:
              print(f"Performance on Clean Data [P] ({task})")
              for metric_i, metric_name in enumerate(metrics):
                  print(f"{metric_name:5} =  {P[metric_i]:0.3f}")
          if "mPC" in prints:
              print(f"Mean Performance under Corruption [mPC] ({task})")
              for metric_i, metric_name in enumerate(metrics):
                  print(f"{metric_name:5} =  {mPC[metric_i]:0.3f}")
          if "rPC" in prints:
              print(
                  f"Relative Performance under Corruption [rPC] ({task})"
              )
              for metric_i, metric_name in enumerate(metrics):
                  print(
                      f"{metric_name:5} => {rPC[metric_i] * 100:0.1f} %"
                  )
  
      return results
  
file_path: mmdetection/tools/analysis_tools/robustness_eval.py
imports: import os.path
  from argparse import ArgumentParser
  import numpy
  from mmengine.fileio import load
label_desc: Use image node_id 2 for calling a global function with example usage: get_coco_style_results(filename, task, metric, prints, aggregate) and returns: results