code: def retrieve_matadata(
      validation_directory,
      metric,
      configuration_space,
      cutoff=0,
      only_best=True,
  ):
      if not only_best:
          raise NotImplementedError()
      if cutoff > 0:
          raise NotImplementedError()
  
      # Mapping from task id to a list of (config, score) tuples
      outputs = dict()
      configurations = dict()
      configurations_to_ids = dict()
  
      try:
          validation_trajectory_files = glob.glob(
              os.path.join(
                  validation_directory,
                  "*",
                  "*",
                  "validation_trajectory_*.json",
              )
          )
      except FileNotFoundError:
          return {}, {}
  
      for validation_trajectory_file in validation_trajectory_files:
          task_name = None
  
          with open(validation_trajectory_file) as fh:
              validation_trajectory = json.load(fh)
  
          best_value = np.inf
          best_configuration = None
          best_configuration_dir = None
  
          n_configs = 0
          n_better = 0
          n_broken = 0
  
          for entry in validation_trajectory:
              # There's no reason to keep the default configuration
              # (even if it's better) because it is run anyway
              if validation_trajectory[0][2] == entry[2]:
                  continue
  
              n_configs += 1
  
              config = entry[2]
              task_name = entry[-2]
              score = entry[-1].get(str(metric), np.inf)
  
              if (
                  np.isinf(score)
                  and np.isinf(best_value)
                  or score < best_value
              ):
                  n_better += 1
  
                  try:
                      for (
                          hp
                      ) in configuration_space.get_hyperparameters():
                          if hp.name not in config:
                              config[hp.name] = hp.default_value
  
                      best_configuration = Configuration(
                          configuration_space=configuration_space,
                          values=config,
                          allow_inactive_with_values=True,
                      )
                      best_configuration = (
                          deactivate_inactive_hyperparameters(
                              configuration=best_configuration,
                              configuration_space=configuration_space,
                          )
                      )
                      best_value = score
                      best_configuration_dir = (
                          validation_trajectory_file
                      )
                  except Exception as e:
                      print(e)
                      n_broken += 1
  
          if task_name is None:
              print(
                  "Could not find any configuration better than the default configuration!"
              )
              continue
  
          if best_configuration is None:
              print(
                  "Could not find a valid configuration; total %d, better %d, broken %d"
                  % (n_configs, n_better, n_broken)
              )
              continue
          elif best_configuration in configurations_to_ids:
              print("Found configuration in", best_configuration_dir)
              config_id = configurations_to_ids[best_configuration]
          else:
              print("Found configuration in", best_configuration_dir)
              config_id = len(configurations_to_ids)
              configurations_to_ids[config_id] = best_configuration
              configurations[config_id] = best_configuration
  
          # We could keep multiple configurations per task (and actually did so before), but
          # there is really no reason to already filter them here and only keep the best
          # (this is less confusing when looking at the raw data later on).
          if task_name not in outputs:
              outputs[task_name] = (config_id, best_value)
          else:
              if best_value < outputs[task_name][1]:
                  outputs[task_name] = (config_id, best_value)
  
      return outputs, configurations
  
file_path: auto-sklearn/scripts/02_retrieve_metadata.py
imports: from argparse import ArgumentParser
  import csv
  import glob
  import itertools
  import json
  import os
  import arff
  import numpy
  from ConfigSpace.configuration_space import Configuration
  from ConfigSpace.util import deactivate_inactive_hyperparameters
  from autosklearn.data.abstract_data_manager import AbstractDataManager
  from autosklearn.constants import *
  from autosklearn.metrics import CLASSIFICATION_METRICS, REGRESSION_METRICS
  from autosklearn.util import pipeline
label_desc: Use image node_id 1 for calling a global function with example usage: retrieve_matadata(validation_directory, metric, configuration_space, cutoff, only_best) and returns: outputs,  configurations, dict,  dict