code: def __init__(
      self,
      task,
      sample_frequency_per_sec=2.0,
      report_frequency_sec=30.0,
      first_report_sec=None,
      wait_for_first_iteration_to_start_sec=180.0,
      max_wait_for_first_iteration_to_start_sec=1800.0,
      report_mem_used_per_process=True,
  ):
      super(ResourceMonitor, self).__init__(
          task=task, wait_period=sample_frequency_per_sec
      )
      self._task = task
      self._sample_frequency = sample_frequency_per_sec
      self._report_frequency = report_frequency_sec
      self._first_report_sec = first_report_sec or report_frequency_sec
      self.wait_for_first_iteration = (
          wait_for_first_iteration_to_start_sec
      )
      self.max_check_first_iteration = (
          max_wait_for_first_iteration_to_start_sec
      )
      self._num_readouts = 0
      self._readouts = {}
      self._previous_readouts = {}
      self._previous_readouts_ts = time()
      self._gpustat_fail = 0
      self._gpustat = gpustat
      self._active_gpus = None
      self._process_info = (
          psutil.Process() if report_mem_used_per_process else None
      )
      self._last_process_pool = {}
      self._last_process_id_list = []
      self._gpu_memory_per_process = True
  
      if not self._gpustat:
          self._task.get_logger().report_text(
              "ClearML Monitor: GPU monitoring is not available"
          )
      else:  # if running_remotely():
          # noinspection PyBroadException
          try:
              active_gpus = os.environ.get(
                  "NVIDIA_VISIBLE_DEVICES", ""
              ) or os.environ.get("CUDA_VISIBLE_DEVICES", "")
              if active_gpus:
                  self._active_gpus = [
                      g.strip() for g in active_gpus.split(",")
                  ]
          except Exception:
              pass
  
imports: import logging
  import os
  import platform
  import sys
  import warnings
  from time import time
  import psutil
  from pathlib2 import Path
  from typing import Text
  from .process.mp import BackgroundMonitor
  from ..backend_api import Session
  from ..binding.frameworks.tensorflow_bind import IsTensorboardInit
label_desc: Use image node_id 1 to create a new ResourceMonitor object from inherited base classes: BackgroundMonitor with example: obj = ResourceMonitor(task, sample_frequency_per_sec, report_frequency_sec, first_report_sec, wait_for_first_iteration_to_start_sec, max_wait_for_first_iteration_to_start_sec, report_mem_used_per_process)