class_docstr: An abstract HPOptimizer using for `advisor` package.
  See https://github.com/tobegit3hub/advisor for more information
  
  Attributes
  ----------
  method : .suggestion.AbstractSuggestionAlgorithm
      The algorithm class in `suggestion`
  max_evals : int
      The max rounds of evaluating HPs
  
  Methods
  -------
  optimize
      Optimize the HP by the method within give model and HP space
class_docstr_tok: ["An","abstract","HPOptimizer","using","for","`","advisor","`","package",".","See","https",":","\/\/github.com\/tobegit3hub\/advisor","for","more","information","Attributes","--","--","--","--","--","method",":",".suggestion.AbstractSuggestionAlgorithm","The","algorithm","class","in","`","suggestion","`","max_evals",":","int","The","max","rounds","of","evaluating","HPs","Methods","--","--","--","-","optimize","Optimize","the","HP","by","the","method","within","give","model","and","HP","space"]
docstr: See .base.BaseHPOptimizer.optimize
docstr_tok: ["See",".base.BaseHPOptimizer.optimize"]
code: def optimize(
      self, trainer, dataset, time_limit=None, memory_limit=None
  ):
      """
      See .base.BaseHPOptimizer.optimize
      """
      self.trials = []
      if self.method == None:
          return
  
      self.feval_name = trainer.get_feval(
          return_major=True
      ).get_eval_name()
      self.is_higher_better = trainer.get_feval(
          return_major=True
      ).is_higher_better()
      space = trainer.combined_hyper_parameter_space()
      # space = (
      #     trainer.hyper_parameter_space + trainer.get_model().hyper_parameter_space
      # )
      current_space = self._encode_para(space)
      self._setUp(current_space)
  
      start_time = time.time()
  
      def fn(x):
          current_trainer = trainer.duplicate_from_hyper_parameter(x)
          current_trainer.train(dataset)
          loss, self.is_higher_better = current_trainer.get_valid_score(
              dataset
          )
          if self.is_higher_better:
              loss = -loss
          return current_trainer, loss
  
      best_id = None
      best_trainer = None
  
      print("HPO Search Phase:\n")
      for i in trange(self.max_evals):
          if time.time() - start_time > time_limit:
              self.logger.info(
                  "Time out of limit, Epoch: {}".format(str(i))
              )
              break
          new_trials = self.method.get_new_suggestions(
              self.study, trials=self.trials, number=1
          )
  
          new_trial = new_trials[0]
          new_parameter_values_json = json.loads(
              new_trial.parameter_values
          )
          decoded_json, trial_para = self._decode_para(
              new_parameter_values_json
          )
          current_trainer, perf = fn(decoded_json)
          new_trial.parameter_values = json.dumps(trial_para)
          new_trial.status = "Completed"
          new_trial.objective_value = perf
          if not best_id or perf < self.trials[best_id].objective_value:
              best_id = len(self.trials)
              best_trainer = current_trainer
          else:
              del current_trainer
          self.trials.append(new_trial)
          self._print_info(decoded_json, perf)
  
      if len(self.trials) == 0:
          raise TimeTooLimitedError(
              "Given time is too limited to finish one round in HPO."
          )
  
      best_perf = self.trials[best_id].objective_value
      decoded_json, _ = self._decode_para(
          json.loads(self.trials[best_id].parameter_values)
      )
      self.logger.info("Best Parameter:")
      self._print_info(decoded_json, best_perf)
  
      return best_trainer, decoded_json
  
file_path: AutoGL/autogl/module/hpo/advisorbase.py
imports: import time
  import json
  import math
  from tqdm import trange
  from .suggestion.models import Study
  from .base import BaseHPOptimizer, TimeTooLimitedError
  from .suggestion.algorithm.random_search import RandomSearchAlgorithm
  from .suggestion.algorithm.mocmaes import MocmaesAlgorithm
label_desc: Use image node_id 7 for calling the AdvisorBaseHPOptimizer obj's underlying member method code with example usage: obj.optimize(trainer, dataset, time_limit, memory_limit) and returns: best_trainer,  decoded_json, current_trainer,  loss