code: def summarize_nvs_eval_results(
      per_batch_eval_results: List[Dict[str, Any]],
      is_multisequence: bool,
  ) -> Tuple[Dict[str, Any], Dict[str, Any]]:
      """
      Compile the per-batch evaluation results `per_batch_eval_results` into
      a set of aggregate metrics. The produced metrics depend on is_multisequence.
  
      Args:
          per_batch_eval_results: Metrics of each per-batch evaluation.
          is_multisequence: Whether to evaluate as a multisequence task
          camera_difficulty_bin_breaks: edge hard-medium and medium-easy
  
  
      Returns:
          nvs_results_flat: A flattened dict of all aggregate metrics.
          aux_out: A dictionary holding a set of auxiliary results.
      """
      n_batches = len(per_batch_eval_results)
      eval_sets: List[Optional[str]] = []
      eval_sets = [None]
      if is_multisequence:
          eval_sets = ["train", "test"]
      batch_sizes = torch.tensor(
          [r["meta"]["batch_size"] for r in per_batch_eval_results]
      ).long()
  
      is_train = is_train_frame(
          [r["meta"]["frame_type"] for r in per_batch_eval_results]
      )
  
      # init the result database dict
      results = []
  
      # add per set averages
      for SET in eval_sets:
          if SET is None:
              ok_set = torch.ones(n_batches, dtype=torch.bool)
              set_name = "test"
          else:
              ok_set = is_train == int(SET == "train")
              set_name = SET
  
          # average over all results
          bin_results = average_per_batch_results(
              per_batch_eval_results, idx=torch.where(ok_set)[0]
          )
          results.append(
              {
                  "subset": set_name,
                  "subsubset": "diff=all",
                  "metrics": bin_results,
              }
          )
  
          if is_multisequence:
              # split based on n_src_views
              n_src_views = batch_sizes - 1
              for n_src in EVAL_N_SRC_VIEWS:
                  ok_src = ok_set & (n_src_views == n_src)
                  n_src_results = average_per_batch_results(
                      per_batch_eval_results,
                      idx=torch.where(ok_src)[0],
                  )
                  results.append(
                      {
                          "subset": set_name,
                          "subsubset": f"n_src={int(n_src)}",
                          "metrics": n_src_results,
                      }
                  )
  
      aux_out = {"results": results}
      return flatten_nvs_results(results), aux_out
  
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 5 for calling a global function with example usage: summarize_nvs_eval_results(per_batch_eval_results, is_multisequence) and returns: flatten_nvs_results,  aux_out