code: def collect_system_stats(device: torch.device) -> Dict[str, Any]:
      system_stats: Dict[str, Any] = {}
      cpu_stats = get_psutil_cpu_stats()
  
      # pyre-ignore
      system_stats.update(cpu_stats)
  
      if torch.cuda.is_available():
          try:
              gpu_stats = get_nvidia_smi_gpu_stats(device)
  
              # pyre-ignore
              system_stats.update(gpu_stats)
              system_stats.update(torch.cuda.memory_stats())
          except FileNotFoundError:
              logger.warning(
                  "Unable to find nvidia-smi. Skipping GPU stats collection."
              )
  
      return system_stats
  
imports: import logging
  import os
  import shutil
  import subprocess
  from collections import defaultdict
  from dataclasses import fields, is_dataclass
  from typing import Any, Dict, Mapping, TypeVar
  import torch
  from torchtnt.utils.version import is_torch_version_geq_1_12
  from typing_extensions import Protocol, runtime_checkable, TypedDict
label_desc: Use image node_id 7 for calling a global function with example usage: collect_system_stats(device) and returns: system_stats