class_docstr: The Tuning objective for HPO.
docstr: Init the objective.
  
  :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: pruning: bool (optional): whether to enable pruning.
      Defaults to False.
  :param: backend: the HPO backend
  :param: report_method: a function to decide which score to report
      from the result of all epochs if there's more than one epoch
  throw: ValueError: _description_
docstr_tok: ["Init","the","objective",".",":","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",":","pruning",":","bool","(","optional",")",":","whether","to","enable","pruning",".","Defaults","to","False",".",":","param",":","backend",":","the","HPO","backend",":","param",":","report_method",":","a","function","to","decide","which","score","to","report","from","the","result","of","all","epochs","if","there","'s","more","than","one","epoch","throw",":","ValueError",":","_description_"]
code: def __init__(
      self,
      model=None,
      target_metric=None,
      pruning=False,
      backend=None,
      report_method=None,
      **kwargs,
  ):
      """
      Init the objective.
  
      :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: pruning: bool (optional): whether to enable pruning.
          Defaults to False.
      :param: backend: the HPO backend
      :param: report_method: a function to decide which score to report
          from the result of all epochs if there's more than one epoch
      throw: ValueError: _description_
      """
      if not _is_creator(model) and not isinstance(
          model, tf.keras.Model
      ):
          invalidInputError(
              False,
              "You should either pass a Tensorflo Keras model, or "
              "a model_creator to the Tuning objective.",
          )
  
      self.model_ = model
      self.target_metric_ = target_metric
      self.pruning = pruning
      self.backend = backend
      self.kwargs = kwargs
  
      if report_method is None:
          report_method = max
      self.report_method = report_method
  
file_path: BigDL/python/nano/src/bigdl/nano/automl/tf/objective.py
imports: from selectors import EpollSelector
  from tensorflow.keras.backend import clear_session
  from tensorflow.keras.models import clone_model
  import tensorflow
  import inspect
  import copy
  from bigdl.nano.automl.hpo.backend import create_tfkeras_pruning_callback
  from bigdl.nano.utils.common import invalidInputError
label_desc: Use image node_id 1 to create a new Objective object from inherited base classes: object with example: obj = Objective(model, target_metric, pruning, backend, report_method)