class_docstr: Create Resource to run jobs.
  
  :param connector: Connector to database
  :type connector: AbstractConnector
code: def early_stop_daemon_fun(self):
      while not self.early_stop_daemon_finished:
          # do not consider the early stopped jobs
          with self.stopped_jobs_lock:
              current_jobs = set(self.jobs) - self.stopped_jobs
  
          finished_interm_job_res = (
              self.connector.get_intermediate_results_experiment(
                  self.eid, "FINISHED"
              )
          )
          current_interm_job_res = (
              self.connector.get_intermediate_results_jobs(
                  list(current_jobs)
              )
          )
          interm_job_res = {
              **current_interm_job_res,
              **finished_interm_job_res,
          }
  
          best_fn = np.max if self.maximize else np.min
          comp_fn = (
              (lambda x, target: x >= target)
              if self.maximize
              else (lambda x, target: x <= target)
          )
  
          curve_fitting_threads = []
  
          for c_jid, c_interm_res in current_interm_job_res.items():
              if len(c_interm_res) < self.warmup:
                  continue
  
              if c_jid not in self.job_checked:
                  self.job_checked[c_jid] = []
  
              k = len(c_interm_res) // self.policy_steps
              if k < 1:
                  time.sleep(EARLY_STOPPING_SLEEP)
                  continue
  
              step = k * self.policy_steps
              if (
                  step in self.job_checked[c_jid]
              ):  # job already compared up until this step, waiting for next k multiple
                  time.sleep(EARLY_STOPPING_SLEEP)
                  continue
  
              comp_interm_job_res = {
                  jid: vals
                  for jid, vals in interm_job_res.items()
                  if len(vals) >= step and jid != c_jid
              }
              if len(comp_interm_job_res) < 1:  # too few jobs
                  time.sleep(EARLY_STOPPING_SLEEP)
                  continue
  
              if self.policy == "median":
                  avgs = [
                      np.average(vals[:step])
                      for vals in comp_interm_job_res.values()
                  ]
                  median = np.median(avgs)
                  best_val = np.average(c_interm_res[:step])
                  if not comp_fn(best_val, median):
                      self.stop_job(c_jid)
                      logger.info(
                          "Stopping job {} early (step {}): best value so far {:.4f} worse than median of averages {:.4f} for {} other jobs".format(
                              c_jid,
                              step,
                              best_val,
                              median,
                              len(comp_interm_job_res),
                          )
                      )
              elif self.policy == "bandit":
                  bandit_best_val = best_fn(
                      [
                          best_fn(vals[:step])
                          for vals in comp_interm_job_res.values()
                      ]
                  )
                  best_val = best_fn(c_interm_res[:step])
                  bandit_factor = (
                      self.bandit_factor
                      if (
                          (
                              self.maximize
                              and np.sign(bandit_best_val) == 1
                          )
                          or (
                              not self.maximize
                              and np.sign(bandit_best_val) == -1
                          )
                      )
                      else 2 - self.bandit_factor
                  )
                  if not comp_fn(
                      best_val, bandit_factor * bandit_best_val
                  ):
                      self.stop_job(c_jid)
                      logger.info(
                          "Stopping job {} early (step {}): best value so far {:.4f} worse than a factor {:.4f} of best overall value {:.4f} (={:.4f}) for {} other jobs".format(
                              c_jid,
                              step,
                              best_val,
                              bandit_factor,
                              bandit_best_val,
                              bandit_factor * bandit_best_val,
                              len(comp_interm_job_res),
                          )
                      )
              elif self.policy == "truncation":
                  best_vals = sorted(
                      [
                          (jid, best_fn(vals[:step]))
                          for jid, vals in (
                              list(comp_interm_job_res.items())
                              + [(c_jid, c_interm_res)]
                          )
                      ],
                      key=lambda t: t[1],
                      reverse=not self.maximize,
                  )
                  best_val_idx = (
                      next(
                          (
                              idx
                              for idx, (jid, val) in enumerate(
                                  best_vals
                              )
                              if jid == c_jid
                          )
                      )
                      + 1
                  )
                  perc = float(best_val_idx) / len(best_vals)
                  if perc <= self.truncation_percentage:
                      self.stop_job(c_jid)
                      logger.info(
                          "Stopping job {} early (step {}): best value so far {:.4f} is in the bottom {:.2f}% of {} jobs, which is lower than the {:.2f}% cutoff".format(
                              c_jid,
                              step,
                              best_vals[best_val_idx - 1][1],
                              100.0 * best_val_idx / len(best_vals),
                              len(best_vals),
                              100.0 * self.truncation_percentage,
                          )
                      )
              elif self.policy == "curve_fitting":
                  if (
                      len(finished_interm_job_res) < 1
                      or step <= CURVE_FITTING_MIN_ITS
                  ):
                      continue
                  interm_res = copy.deepcopy(c_interm_res)
                  best_val = best_fn(
                      [
                          best_fn(vals)
                          for vals in finished_interm_job_res.values()
                      ]
                  )
                  if not self.maximize:
                      interm_res *= -1
                      best_val *= -1
                  curve_fitting_threshold = (
                      self.curve_fitting_threshold
                      if np.sign(best_val) == 1
                      else 2 - self.curve_fitting_threshold
                  )
                  cf_thread = threading.Thread(
                      target=self.run_curve_fitting,
                      args=(
                          interm_res[:step],
                          c_jid,
                          step,
                          (lambda x, target: x >= target),
                          curve_fitting_threshold,
                          best_val,
                      ),
                  )
                  cf_thread.start()
                  curve_fitting_threads += [cf_thread]
  
              self.job_checked[c_jid] += [step]
  
          for thread in curve_fitting_threads:
              thread.join()
  
          time.sleep(EARLY_STOPPING_SLEEP)
  
imports: import abc
  import copy
  import importlib
  import logging
  import random
  import threading
  import time
  import numpy
  import math
  import warnings
  from ...utils import DEFAULT_AUPTIMIZER_PATH
  from .utils.curve_fitting import CurveModel
label_desc: Use image node_id 14 for calling the AbstractResourceManager obj's underlying member method code with example usage: obj.early_stop_daemon_fun() without return types