code: def get_stats_summary(
      stats_list: Union[List[GPUStats], List[CUDAStats]]
  ) -> Union[GPUStatsSummary, CUDAStatsSummary]:  # pragma: no cover
      r"""Creates a summary of collected runtime and memory statistics.
      Returns a :obj:`GPUStatsSummary` if list of :obj:`GPUStats` was passed,
      otherwise (list of :obj:`CUDAStats` was passed),
      returns a :obj:`CUDAStatsSummary`.
  
      Args:
          stats_list (Union[List[GPUStats], List[CUDAStats]]): A list of
              :obj:`GPUStats` or :obj:`CUDAStats` objects, as returned by
              :meth:`~torch_geometric.profile.profileit`.
      """
      # calculate common statistics
      kwargs = dict(
          time_mean=float(
              torch.tensor([s.time for s in stats_list]).mean()
          ),
          time_std=float(
              torch.tensor([s.time for s in stats_list]).std()
          ),
          max_allocated_gpu=max(
              [s.max_allocated_gpu for s in stats_list]
          ),
          max_reserved_gpu=max(
              [s.max_reserved_gpu for s in stats_list]
          ),
          max_active_gpu=max([s.max_active_gpu for s in stats_list]),
      )
  
      if all(isinstance(s, CUDAStats) for s in stats_list):
          return CUDAStatsSummary(
              **kwargs,
              min_nvidia_smi_free_cuda=min(
                  [s.nvidia_smi_free_cuda for s in stats_list]
              ),
              max_nvidia_smi_used_cuda=max(
                  [s.nvidia_smi_used_cuda for s in stats_list]
              ),
          )
      else:
          return GPUStatsSummary(**kwargs)
  
imports: import os
  import pathlib
  import time
  from contextlib import ContextDecorator, contextmanager
  from dataclasses import dataclass
  from typing import Any, List, Tuple, Union
  import torch
  from torch.autograd.profiler import EventList
  from torch.profiler import ProfilerActivity, profile
  from torch_geometric.profile.utils import byte_to_megabyte, get_gpu_memory_from_ipex, get_gpu_memory_from_nvidia_smi
label_desc: Use image node_id 2 for calling a global function with example usage: get_stats_summary(stats_list) and returns: CUDAStatsSummary, GPUStatsSummary