code: def _end_search(study, model_builder, use_trial_id=-1):
      """
      Put an end to tuning.
  
      Use the specified trial or best trial to init and compile the base model.
  
      :param study: the hpo study object.
      :param model_builder: the function to build the model.
      :param use_trial_id: int(optional) params of which trial to be used. Defaults to -1.
      :throw ValueError: if study is None.
      :return : the built model with best or specified trial hyperparams.
      """
      if study is None:
          trial = optuna.trial.FixedTrial({})
      elif use_trial_id == -1:
          trial = study.best_trial
      else:
          trial = study.trials[use_trial_id]
  
      _lazymodel = model_builder(trial)
      # TODO Next step: support retrive saved model instead of retrain from hparams
      return _lazymodel
  
file_path: BigDL/python/nano/src/bigdl/nano/automl/hpo/search.py
imports: import optuna
  from bigdl.nano.utils.common import invalidInputError
label_desc: Use image node_id 3 for calling a global function with example usage: _end_search(study, model_builder, use_trial_id) and returns: _lazymodel