code: def __init__(self, name, device, opts):
      threading.Thread.__init__(self)
      self.name = name
      self.device = device
      self.opts = opts
  
      self.daemon = True
      self.run_flag = threading.Event()
      self.data = defaultdict(int)
  
      try:
          self.cuda_mem_get_info()
          torch.cuda.memory_stats(self.device)
      except Exception as e:  # AMD or whatever
          print(
              f"Warning: caught exception '{e}', memory monitor disabled"
          )
          self.disabled = True
  
file_path: stable-diffusion-webui/modules/memmon.py
imports: import threading
  import time
  from collections import defaultdict
  import torch
label_desc: Use image node_id 1 to create a new MemUsageMonitor object from inherited base classes: threading with example: obj = MemUsageMonitor(name, device, opts)