code: def best_models(
      nb_models,
      model,
      data,
      algo,
      max_evals,
      trials,
      functions=None,
      keep_temp=False,
  ):
      base_minimizer(
          model=model,
          data=data,
          functions=functions,
          algo=algo,
          max_evals=max_evals,
          trials=trials,
          stack=4,
          keep_temp=keep_temp,
      )
      if len(trials) < nb_models:
          nb_models = len(trials)
      scores = [trial.get("result").get("loss") for trial in trials]
      cut_off = sorted(scores, reverse=True)[nb_models - 1]
      model_list = [
          trial.get("result").get("model")
          for trial in trials
          if trial.get("result").get("loss") >= cut_off
      ]
      return model_list
  
imports: import inspect
  import os
  import re
  import sys
  import nbformat
  import numpy
  from hyperopt import fmin
  from nbconvert import PythonExporter
  from .ensemble import VotingModel
  from .utils import remove_imports, remove_all_comments, extract_imports, temp_string, write_temp_files, determine_indent, with_line_numbers, unpack_hyperopt_vals, eval_hyperopt_space, find_signature_end
label_desc: Use image node_id 4 for calling a global function with example usage: best_models(nb_models, model, data, algo, max_evals, trials, functions, keep_temp) and returns: model_list