code: def update(self) -> dict[str, Any]:
      now = time()
      now_mono = monotonic()
      duration = (now_mono - self.last_time) or 0.001
      self.last_time = now_mono
  
      self.count += 1
  
      with self.proc.oneshot():
          result = {
              "cpu": self.proc.cpu_percent(),
              "memory": self.get_process_memory(),
              "time": now,
          }
  
      if self.monitor_net_io:
          net_ioc = psutil.net_io_counters()
          last = self._last_net_io_counters
          result["host_net_io.read_bps"] = (
              net_ioc.bytes_recv - last.bytes_recv
          ) / duration
          result["host_net_io.write_bps"] = (
              net_ioc.bytes_sent - last.bytes_sent
          ) / duration
          self._last_net_io_counters = net_ioc
  
      if self.monitor_disk_io:
          disk_ioc = psutil.disk_io_counters()
          assert disk_ioc is not None
          last_disk = self._last_disk_io_counters
          result["host_disk_io.read_bps"] = (
              disk_ioc.read_bytes - last_disk.read_bytes
          ) / duration
          result["host_disk_io.write_bps"] = (
              disk_ioc.write_bytes - last_disk.write_bytes
          ) / duration
          self._last_disk_io_counters = disk_ioc
  
      if self.monitor_host_cpu:
          host_cpu = psutil.cpu_times()
          last_cpu = self._last_host_cpu_counters
          for k in host_cpu._fields:
              delta = getattr(host_cpu, k) - getattr(last_cpu, k)
              # cpu_times() has a precision of 2 decimals; suppress noise
              result["host_cpu." + k] = round(delta / duration, 2)
          self._last_host_cpu_counters = host_cpu
  
      if self.monitor_gil_contention:
          self._last_gil_contention = self._gilknocker.contention_metric
          self._cumulative_gil_contention += self._last_gil_contention
          result["gil_contention"] = self._last_gil_contention
          self._gilknocker.reset_contention_metric()
  
      # Note: WINDOWS constant doesn't work with `mypy --platform win32`
      if sys.platform != "win32":
          result["num_fds"] = self.proc.num_fds()
  
      if self.gpu_name:
          gpu_metrics = nvml.real_time()
          result["gpu_utilization"] = gpu_metrics["utilization"]
          result["gpu_memory_used"] = gpu_metrics["memory-used"]
  
      for name, v in result.items():
          if name != "count":
              self.quantities[name].append(v)
  
      return result
  
file_path: distributed/distributed/system_monitor.py
imports: from __future__ import annotations
  import sys
  from collections import deque
  from typing import Any
  import psutil
  import dask.config
  from dask.typing import NoDefault, no_default
  from dask.utils import parse_timedelta
  from distributed.compatibility import WINDOWS
  from distributed.diagnostics import nvml
  from distributed.metrics import monotonic, time
label_desc: Use image node_id 4 for calling the SystemMonitor obj's underlying member method code with example usage: obj.update() and returns: result