code: def save_best_model(_rep, _fold, _run, model, stat_aggregates):
      all_scores = stat_aggregates["evaluations"]["oof_roc_auc_score"][
          "runs"
      ]
      # Get all scores by "run" that have been recorded.
      # NOTE: We need the "oof_" prefix in "oof_roc_auc_score" above to specify we want our
      #   out-of-fold scores as opposed to "holdout" scores
  
      current_score = all_scores[-1]
      # Get the last (most recent) score in the above `all_scores` list
  
      if current_score >= np.max(all_scores):
          # Check if our current score is greater than all previous scores
          # If you're measuring loss/error, change `np.max` to `np.min`
  
          print(
              f"NEW BEST:   {current_score}   @ R{_rep} / f{_fold} / r{_run}"
          )
          model.model.save_model(
              f"_saved_models/best/model_{_rep}_{_fold}_{_run}_{current_score}"
          )
  
file_path: hyperparameter_hunter/examples/advanced_examples/save_model_callback.py
imports: from hyperparameter_hunter import Environment, CVExperiment, lambda_callback
  from hyperparameter_hunter.utils.learning_utils import get_breast_cancer_data
  import numpy
  from os import listdir, makedirs
  from pprint import pprint
  from xgboost import XGBClassifier
label_desc: Use image node_id 3 for calling a global function with example usage: save_best_model(_rep, _fold, _run, model, stat_aggregates) without return types