class_docstr: The Tuning objective for HPO.
docstr: Init the objective.
  
  :param searcher: an HPOSearcher object which does the actual work.
  :param model: a model instance or a creator function.
      Defaults to None.
  :param target_metric: str(optional): target 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 pruning: bool (optional): whether to enable pruning.
      Defaults to False.
  :param direction: direction for target metric, which is used when there is
      only one target metric. Dafaults to 'minimize'.
  :param directions: directions for target metrics, which is used when there
      are multi target metrics. Dafaults to None.
  :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.
  throw: ValueError: _description_
docstr_tok: ["Init","the","objective",".",":","param","searcher",":","an","HPOSearcher","object","which","does","the","actual","work",".",":","param","model",":","a","model","instance","or","a","creator","function",".","Defaults","to","None",".",":","param","target_metric",":","str","(","optional",")",":","target","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","pruning",":","bool","(","optional",")",":","whether","to","enable","pruning",".","Defaults","to","False",".",":","param","direction",":","direction","for","target","metric",",","which","is","used","when","there","is","only","one","target","metric",".","Dafaults","to","'minimize","'",".",":","param","directions",":","directions","for","target","metrics",",","which","is","used","when","there","are","multi","target","metrics",".","Dafaults","to","None",".",":","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",".","throw",":","ValueError",":","_description_"]
code: def __init__(
      self,
      searcher,
      model=None,
      target_metric=None,
      mode="best",
      pruning=False,
      direction="minimize",
      directions=None,
      acceleration=False,
      input_sample=None,
      **fit_kwargs,
  ):
      """
      Init the objective.
  
      :param searcher: an HPOSearcher object which does the actual work.
      :param model: a model instance or a creator function.
          Defaults to None.
      :param target_metric: str(optional): target 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 pruning: bool (optional): whether to enable pruning.
          Defaults to False.
      :param direction: direction for target metric, which is used when there is
          only one target metric. Dafaults to 'minimize'.
      :param directions: directions for target metrics, which is used when there
          are multi target metrics. Dafaults to None.
      :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.
      throw: ValueError: _description_
      """
      # TODO: how to expose mode parameter
      self.searcher = searcher
      self.model_ = model
      self.target_metric = target_metric
      self.mode = mode
      self.mo_hpo = (
          isinstance(target_metric, (list, tuple))
          and len(self.target_metric) > 1
      )
      # add automatic support for latency
      if self.mo_hpo and "latency" in self.target_metric:
          callbacks = self.searcher.trainer.callbacks or []
          callbacks.append(LatencyCallback())
          self.searcher.trainer.callbacks = callbacks
          self.acceleration = acceleration
          self.input_sample = input_sample
      else:
          self.acceleration = False
  
      if mode == "best":
          if self.mo_hpo:
              if self.target_metric[0] != "latency":
                  self.metric = self.target_metric[0]
                  self.direction = directions[0]
              else:
                  self.metric = self.target_metric[1]
                  self.direction = directions[1]
          else:
              self.metric = self.target_metric
              self.direction = direction
  
      self.pruning = pruning
      self.fit_kwargs = fit_kwargs
  
      (
          self.train_dataloaders,
          self.val_dataloaders,
          self.datamodule,
      ) = self._fix_data_args(self.model, **fit_kwargs)
  
imports: from collections import namedtuple
  from typing import Optional, Union
  import pytorch_lightning
  from pytorch_lightning.utilities.types import EVAL_DATALOADERS, TRAIN_DATALOADERS
  from pytorch_lightning.utilities import rank_zero_deprecation
  from pytorch_lightning.core.datamodule import LightningDataModule
  from bigdl.nano.pytorch import InferenceOptimizer
  from bigdl.nano.automl.hpo.backend import create_pl_pruning_callback
  from bigdl.nano.utils.common import invalidInputError
  from ._helper import LatencyCallback, _remove_metric_prefix, BestMetricCallback
  import inspect
  import copy
label_desc: Use image node_id 1 to create a new Objective object from inherited base classes: object with example: obj = Objective(searcher, model, target_metric, mode, pruning, direction, directions, acceleration, input_sample)