class_docstr: In the case of a crash, this class searches
  for the best individual model.
  
  Such model is returned as an ensemble of a single
  object, to comply with the expected interface of an
  AbstractEnsemble.
  
  Do not use by yourself!
class_docstr_tok: ["In","the","case","of","a","crash",",","this","class","searches","for","the","best","individual","model",".","Such","model","is","returned","as","an","ensemble","of","a","single","object",",","to","comply","with","the","expected","interface","of","an","AbstractEnsemble",".","Do","not","use","by","yourself","!"]
docstr: Parses the run history, to identify the best performing model
  
  Populates the identifiers attribute, which is used by the backend to access
  the actual model.
docstr_tok: ["Parses","the","run","history",",","to","identify","the","best","performing","model","Populates","the","identifiers","attribute",",","which","is","used","by","the","backend","to","access","the","actual","model","."]
code: def get_identifiers_from_run_history(
      self,
  ) -> list[tuple[int, int, float]]:
      """Parses the run history, to identify the best performing model
  
      Populates the identifiers attribute, which is used by the backend to access
      the actual model.
      """
      best_model_identifier = []
      best_model_score = self.metrics[0]._worst_possible_result
  
      for run_key in self.run_history.data.keys():
          run_value = self.run_history.data[run_key]
          print(run_key, run_value)
          if len(self.metrics) == 1:
              cost = run_value.cost
          else:
              cost = run_value.cost[0]
          score = self.metrics[0]._optimum - (
              self.metrics[0]._sign * cost
          )
  
          if (
              score > best_model_score and self.metrics[0]._sign > 0
          ) or (score < best_model_score and self.metrics[0]._sign < 0):
              # Make sure that the individual best model actually exists
              model_dir = self.backend.get_numrun_directory(
                  self.seed,
                  run_value.additional_info["num_run"],
                  run_key.budget,
              )
              model_file_name = self.backend.get_model_filename(
                  self.seed,
                  run_value.additional_info["num_run"],
                  run_key.budget,
              )
              file_path = os.path.join(model_dir, model_file_name)
              if not os.path.exists(file_path):
                  continue
  
              best_model_identifier = [
                  (
                      self.seed,
                      run_value.additional_info["num_run"],
                      run_key.budget,
                  )
              ]
              best_model_score = score
  
      if not best_model_identifier:
          raise ValueError(
              "No valid model found in run history. This means smac was not able to"
              " fit a valid model. Please check the log file for errors."
          )
  
      self.best_model_score_ = best_model_score
  
      return best_model_identifier
  
imports: from __future__ import annotations
  from typing import Sequence
  import os
  import numpy
  from smac.runhistory.runhistory import RunHistory
  from autosklearn.automl_common.common.utils.backend import Backend
  from autosklearn.data.validation import SUPPORTED_FEAT_TYPES
  from autosklearn.ensemble_building.run import Run
  from autosklearn.ensembles.abstract_ensemble import AbstractEnsemble
  from autosklearn.metrics import Scorer, calculate_losses
  from autosklearn.pipeline.base import BasePipeline
label_desc: Use image node_id 2 for calling the SingleBestFromRunhistory obj's underlying member method code with example usage: obj.get_identifiers_from_run_history() and returns: best_model_identifier