<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def minimize(model, data, algo, max_evals, trials, functions=None, rseed=1337, notebook_name=None, verbose=True, eval_space=False, return_space=False, keep_temp=False):
 """ Minimize a keras model for given data and implicit hyperparameters. Parameters model: A function defining a keras model with hyperas templates, which returns a valid hyperopt results dictionary, e.g. return {'loss': -acc, 'status': STATUS_OK} data: A parameter-less function that defines and return all data needed in the above model definition. algo: A hyperopt algorithm, like tpe.suggest or rand.suggest max_evals: Maximum number of optimization runs trials: A hyperopt trials object, used to store intermediate results for all optimization runs rseed: Integer random seed for experiments notebook_name: If running from an ipython notebook, provide filename (not path) verbose: Print verbose output eval_space: Evaluate the best run in the search space such that 'choice's contain actually meaningful values instead of mere indices return_space: Return the hyperopt search space object (e.g. for further processing) as last return value keep_temp: Keep temp_model.py file on the filesystem Returns ------- If `return_space` is False: A pair consisting of the results dictionary of the best run and the corresponding keras model. If `return_space` is True: The pair of best result and corresponding keras model, and the hyperopt search space """

    best_run, space = base_minimizer(model=model,
                                     data=data,
                                     functions=functions,
                                     algo=algo,
                                     max_evals=max_evals,
                                     trials=trials,
                                     rseed=rseed,
                                     full_model_string=None,
                                     notebook_name=notebook_name,
                                     verbose=verbose,
                                     keep_temp=keep_temp)

    best_model = None
    for trial in trials:
        vals = trial.get('misc').get('vals')
        # unpack the values from lists without overwriting the mutable dict within 'trial'
        unpacked_vals = unpack_hyperopt_vals(vals)
        # identify the best_run (comes with unpacked values from the hyperopt function `base.Trials.argmin`)
        if unpacked_vals == best_run and 'model' in trial.get('result').keys():
            best_model = trial.get('result').get('model')

    if eval_space is True:
        # evaluate the search space
        best_run = eval_hyperopt_space(space, best_run)

    if return_space is True:
        # return the space as well
        return best_run, best_model, space
    else:
        # the default case for backwards compatibility with expanded return arguments
        return best_run, best_model