class_docstr: Hyper Parameter Searcher. A Tuner-like class.
class_docstr_tok: ["Hyper","Parameter","Searcher",".","A","Tuner-like","class","."]
docstr: Run HPO Searcher. It will be called in Trainer.search().
  
  :param model: The model to be searched. It should be an automodel.
  :param resume: whether to resume the previous or start a new one,
      defaults to False.
  :param target_metric: the object metric to optimize,
      defaults to None.
  :param mode: use last epoch's result as trial's score or use best epoch's.
      defaults to 'best', you can change it to 'last'.
  :param acceleration: Whether to automatically consider the model after
      inference acceleration in the search process. It will only take
      effect if target_metric contains "latency". Default value is False.
  :param input_sample: A set of inputs for trace, defaults to None if you have
      trace before or model is a LightningModule with any dataloader attached.
  :param return: the model with study meta info attached.
docstr_tok: ["Run","HPO","Searcher",".","It","will","be","called","in","Trainer.search","(",")",".",":","param","model",":","The","model","to","be","searched",".","It","should","be","an","automodel",".",":","param","resume",":","whether","to","resume","the","previous","or","start","a","new","one",",","defaults","to","False",".",":","param","target_metric",":","the","object","metric","to","optimize",",","defaults","to","None",".",":","param","mode",":","use","last","epoch","'s","result","as","trial","'s","score","or","use","best","epoch","'s",".","defaults","to","'best","'",",","you","can","change","it","to","'last","'",".",":","param","acceleration",":","Whether","to","automatically","consider","the","model","after","inference","acceleration","in","the","search","process",".","It","will","only","take","effect","if","target_metric","contains","``","latency","''",".","Default","value","is","False",".",":","param","input_sample",":","A","set","of","inputs","for","trace",",","defaults","to","None","if","you","have","trace","before","or","model","is","a","LightningModule","with","any","dataloader","attached",".",":","param","return",":","the","model","with","study","meta","info","attached","."]
code: def search(
      self,
      model,
      resume=False,
      target_metric=None,
      mode="best",
      n_parallels=1,
      acceleration=False,
      input_sample=None,
      **kwargs,
  ):
      """
      Run HPO Searcher. It will be called in Trainer.search().
  
      :param model: The model to be searched. It should be an automodel.
      :param resume: whether to resume the previous or start a new one,
          defaults to False.
      :param target_metric: the object metric to optimize,
          defaults to None.
      :param mode: use last epoch's result as trial's score or use best epoch's.
          defaults to 'best', you can change it to 'last'.
      :param acceleration: Whether to automatically consider the model after
          inference acceleration in the search process. It will only take
          effect if target_metric contains "latency". Default value is False.
      :param input_sample: A set of inputs for trace, defaults to None if you have
          trace before or model is a LightningModule with any dataloader attached.
      :param return: the model with study meta info attached.
      """
      search_kwargs = kwargs or {}
      self.target_metric = target_metric
  
      _validate_args(
          search_kwargs,
          self.target_metric,
          legal_keys=[
              HPOSearcher.FIT_KEYS,
              HPOSearcher.EXTRA_FIT_KEYS,
              HPOSearcher.TUNE_CREATE_KEYS,
              HPOSearcher.TUNE_RUN_KEYS,
          ],
      )
  
      _sampler_kwargs = model._lazyobj.sampler_kwargs
      user_sampler_kwargs = kwargs.get("sampler_kwargs", {})
      _sampler_kwargs.update(user_sampler_kwargs)
      if "sampler" in kwargs and kwargs["sampler"] in [
          SamplerType.Grid
      ]:
          search_kwargs["sampler_kwargs"] = _sampler_kwargs
          # Following condition will be met when user state non-catagory problem
          invalidInputError(
              len(model._lazyobj.kwspaces_) <= len(_sampler_kwargs),
              "Only `space.Categorical` is supported for `SamplerType.Grid` "
              "sampler. Please try replace other space to `space.Categorical` "
              "or use another SamplerType.",
          )
  
      (
          self.create_kwargs,
          self.run_kwargs,
          self.fit_kwargs,
      ) = _prepare_args(
          search_kwargs,
          HPOSearcher.TUNE_CREATE_KEYS,
          HPOSearcher.TUNE_RUN_KEYS,
          HPOSearcher.FIT_KEYS,
          self.backend,
      )
  
      # create study
      if self.study is None:
          self.study = _create_study(
              resume, self.create_kwargs, self.backend
          )
  
      if self.objective is None:
          self._create_objective(
              model,
              self.target_metric,
              mode,
              self.create_kwargs,
              acceleration,
              input_sample,
              self.fit_kwargs,
          )
  
      if n_parallels and n_parallels > 1:
          invalidInputError(
              self.create_kwargs.get("storage", "").strip() != "",
              "parallel search is not supported"
              " when in-mem storage is used (n_parallels must be 1)",
          )
  
          self._run_search_n_procs(n_procs=n_parallels)
      else:
          self._run_search()
  
      # it is not possible to know the best trial before runing search,
      # so just apply the best trial at end of each search.
      # a single best trial cannot be retrieved from a multi-objective study.
      if not self.objective.mo_hpo:
          self._lazymodel = _end_search(
              study=self.study,
              model_builder=model._model_build,
              use_trial_id=-1,
          )
          return self._lazymodel
      else:
          return self.study.best_trials
  
imports: from typing import Any
  import pytorch_lightning
  import copy
  import math
  from pytorch_lightning.trainer.states import TrainerFn, TrainerStatus
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.automl.hpo.backend import create_hpo_backend, SamplerType
  from .objective import Objective
  from ._helper import ResetCallback, CustomEvaluationLoop
  from bigdl.nano.automl.utils.parallel import run_parallel
  from bigdl.nano.automl.hpo.search import _search_summary, _end_search, _create_study, _validate_args, _prepare_args
label_desc: Use image node_id 5 for calling the HPOSearcher obj's underlying member method code with example usage: obj.search(model, resume, target_metric, mode, n_parallels, acceleration, input_sample) and returns: self, self