code: def track_process(self, p: psutil.Process):
      with p.oneshot():
          key = None
          if p.pid in self.pids:
              key = self.pids[p.pid]
              if self.processes[key].name != p.name():
                  key = None
  
          if key is None:
              key = len(self.processes)
              self.processes.append(ProcessInfo(key, p.pid, p.name()))
              self.pids[p.pid] = key
  
          proc = self.processes[key]
          proc.active = True
  
          if not self.processes[key].is_tracked and self._should_track(
              key
          ):
              self._start_tracking(key)
  
              self.data.update(
                  {
                      f"process.{key}.name": p.name(),
                      f"process.{key}.pid": p.pid,
                      f"process.{key}.ppid": p.ppid(),
                      f"process.{key}.create_time": p.create_time(),
                  }
              )
  
              try:
                  self.data.update(
                      {
                          f"process.{key}.exe": p.exe(),
                      }
                  )
              except (psutil.AccessDenied, psutil.ZombieProcess):
                  pass
  
              try:
                  self.data.update(
                      {
                          f"process.{key}.cmdline": "\n".join(
                              p.cmdline()
                          ),
                      }
                  )
              except (psutil.AccessDenied, psutil.ZombieProcess):
                  pass
  
          try:
              res = p.memory_info()
              proc.rss = res.rss
  
              if proc.is_tracked:
                  self.data.update(
                      {
                          f"process.{key}.rss": res.rss,
                          f"process.{key}.vms": res.vms,
                      }
                  )
          except (psutil.AccessDenied, psutil.ZombieProcess):
              pass
  
          try:
              res = p.cpu_times()
              proc.cpu_user = res.user
  
              if proc.is_tracked:
                  self.data.update(
                      {
                          f"process.{key}.user": res.user,
                          f"process.{key}.system": res.system,
                      }
                  )
                  if hasattr(res, "iowait"):
                      self.data.update(
                          {
                              f"process.{key}.iowait": res.iowait,
                          }
                      )
          except (psutil.AccessDenied, psutil.ZombieProcess):
              pass
  
          try:
              res = p.cpu_percent()
  
              proc.cpu_percent = res
              proc.n_cpu_percent += 1
  
              if proc.is_tracked:
                  self.data.update(
                      {
                          f"process.{key}.cpu": res,
                      }
                  )
          except (psutil.AccessDenied, psutil.ZombieProcess):
              pass
  
          try:
              res = p.num_threads()
              if proc.is_tracked:
                  self.data.update(
                      {
                          f"process.{key}.threads": res,
                      }
                  )
          except (psutil.AccessDenied, psutil.ZombieProcess):
              pass
  
file_path: labml/client/labml/internal/computer/monitor/process.py
imports: from typing import Dict, List
  import psutil
label_desc: Use image node_id 7 for calling the ProcessMonitor obj's underlying member method code with example usage: obj.track_process(p) without return types