code: def aggregate_nvs_results(task_results):
      """
      Aggregate nvs results.
      For singlescene, this averages over all categories and scenes,
      for multiscene, the average is over all per-category results.
      """
      task_results_cat = [r_ for r in task_results for r_ in r]
      subsets, subsubsets = [
          _ordered_set([r[k] for r in task_results_cat])
          for k in ("subset", "subsubset")
      ]
      metrics = _ordered_set(
          [metric for r in task_results_cat for metric in r["metrics"]]
      )
      average_results = []
      for subset in subsets:
          for subsubset in subsubsets:
              metrics_lists = [
                  r["metrics"]
                  for r in task_results_cat
                  if r["subsubset"] == subsubset
                  and r["subset"] == subset
              ]
              avg_metrics = {}
              for metric in metrics:
                  avg_metrics[metric] = float(
                      np.nanmean(
                          np.array(
                              [
                                  metric_list[metric]
                                  for metric_list in metrics_lists
                              ]
                          )
                      )
                  )
              average_results.append(
                  {
                      "subset": subset,
                      "subsubset": subsubset,
                      "metrics": avg_metrics,
                  }
              )
      return average_results
  
imports: import copy
  import warnings
  from collections import OrderedDict
  from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
  import numpy
  import torch
  import torch.nn.functional
  from pytorch3d.implicitron.dataset.frame_data import FrameData
  from pytorch3d.implicitron.dataset.utils import is_train_frame
  from pytorch3d.implicitron.models.base_model import ImplicitronRender
  from pytorch3d.implicitron.tools import vis_utils
  from pytorch3d.implicitron.tools.image_utils import mask_background
  from pytorch3d.implicitron.tools.metric_utils import calc_psnr, eval_depth, iou, rgb_l1
  from pytorch3d.implicitron.tools.point_cloud_utils import get_rgbd_point_cloud
  from pytorch3d.implicitron.tools.vis_utils import make_depth_image
  from pytorch3d.renderer.cameras import PerspectiveCameras
  from pytorch3d.vis.plotly_vis import plot_scene
  from tabulate import tabulate
label_desc: Use image node_id 10 for calling a global function with example usage: aggregate_nvs_results(task_results) and returns: average_results