code: def get_per_process_cpu_info() -> List[Dict[str, Any]]:
      processes = get_processes_running_python_tests()
      per_process_info = []
      for p in processes:
          info = {
              "pid": p.pid,
              "cmd": " ".join(p.cmdline()),
              "cpu_percent": p.cpu_percent(),
              "rss_memory": p.memory_info().rss,
          }
  
          # https://psutil.readthedocs.io/en/latest/index.html?highlight=memory_full_info
          # requires higher user privileges and could throw AccessDenied error, i.e. mac
          try:
              memory_full_info = p.memory_full_info()
  
              info["uss_memory"] = memory_full_info.uss
              if "pss" in memory_full_info:
                  # only availiable in linux
                  info["pss_memory"] = memory_full_info.pss
  
          except psutil.AccessDenied as e:
              # It's ok to skip this
              pass
  
          per_process_info.append(info)
      return per_process_info
  
file_path: pytorch/tools/stats/monitor.py
imports: import datetime
  import json
  import signal
  import sys
  import time
  from typing import Any, Dict, List
  import psutil
  import pynvml
label_desc: Use image node_id 2 for calling a global function with example usage: get_per_process_cpu_info() and returns: per_process_info