class_docstr: Interface class to handle the execution of SMAC configurations.
  This interface defines how to interact with the SMBO loop.
  The complexity of running a configuration as well as handling the results is abstracted to the
  SMBO via an AbstractRunner.
  
  From SMBO perspective, launching a configuration follows a
  submit/collect scheme as follows:
  
  1. A run is launched via ``submit_run()``
  
     - ``submit_run`` internally calls ``run_wrapper()``, a method that contains common processing functions among
       different runners.
     - A class that implements AbstractRunner defines ``run()`` which is really the algorithm to
       translate a ``TrialInfo`` to a ``TrialValue``, i.e. a configuration to an actual result.
  2. A completed run is collected via ``iter_results()``, which iterates and consumes any finished runs, if any.
  3. This interface also offers the method ``wait()`` as a mechanism to make sure we have enough
     data in the next iteration to make a decision. For example, the intensifier might not be
     able to select the next challenger until more results are available.
  
  Parameters
  ----------
  scenario : Scenario
  required_arguments : list[str]
      A list of required arguments, which are passed to the target function.
class_docstr_tok: ["Interface","class","to","handle","the","execution","of","SMAC","configurations",".","This","interface","defines","how","to","interact","with","the","SMBO","loop",".","The","complexity","of","running","a","configuration","as","well","as","handling","the","results","is","abstracted","to","the","SMBO","via","an","AbstractRunner",".","From","SMBO","perspective",",","launching","a","configuration","follows","a","submit\/collect","scheme","as","follows",":","1",".","A","run","is","launched","via","``","submit_run","(",")","``","-","``","submit_run","``","internally","calls","``","run_wrapper","(",")","``",",","a","method","that","contains","common","processing","functions","among","different","runners",".","-","A","class","that","implements","AbstractRunner","defines","``","run","(",")","``","which","is","really","the","algorithm","to","translate","a","``","TrialInfo","``","to","a","``","TrialValue","``",",","i.e",".","a","configuration","to","an","actual","result",".","2",".","A","completed","run","is","collected","via","``","iter_results","(",")","``",",","which","iterates","and","consumes","any","finished","runs",",","if","any",".","3",".","This","interface","also","offers","the","method","``","wait","(",")","``","as","a","mechanism","to","make","sure","we","have","enough","data","in","the","next","iteration","to","make","a","decision",".","For","example",",","the","intensifier","might","not","be","able","to","select","the","next","challenger","until","more","results","are","available",".","Parameters","--","--","--","--","--","scenario",":","Scenario","required_arguments",":","list","[","str","]","A","list","of","required","arguments",",","which","are","passed","to","the","target","function","."]
docstr: Wrapper around run() to execute and check the execution of a given config.
  This function encapsulates common
  handling/processing, so that run() implementation is simplified.
  
  Parameters
  ----------
  trial_info : RunInfo
      Object that contains enough information to execute a configuration run in isolation.
  dask_data_to_scatter: dict[str, Any]
      When a user scatters data from their local process to the distributed network,
      this data is distributed in a round-robin fashion grouping by number of cores.
      Roughly speaking, we can keep this data in memory and then we do not have to (de-)serialize the data
      every time we would like to execute a target function with a big dataset.
      For example, when your target function has a big dataset shared across all the target function,
      this argument is very useful.
  
  Returns
  -------
  info : TrialInfo
      An object containing the configuration launched.
  value : TrialValue
      Contains information about the status/performance of config.
docstr_tok: ["Wrapper","around","run","(",")","to","execute","and","check","the","execution","of","a","given","config",".","This","function","encapsulates","common","handling\/processing",",","so","that","run","(",")","implementation","is","simplified",".","Parameters","--","--","--","--","--","trial_info",":","RunInfo","Object","that","contains","enough","information","to","execute","a","configuration","run","in","isolation",".","dask_data_to_scatter",":","dict","[","str",",","Any","]","When","a","user","scatters","data","from","their","local","process","to","the","distributed","network",",","this","data","is","distributed","in","a","round-robin","fashion","grouping","by","number","of","cores",".","Roughly","speaking",",","we","can","keep","this","data","in","memory","and","then","we","do","not","have","to","(","de-",")","serialize","the","data","every","time","we","would","like","to","execute","a","target","function","with","a","big","dataset",".","For","example",",","when","your","target","function","has","a","big","dataset","shared","across","all","the","target","function",",","this","argument","is","very","useful",".","Returns","--","--","--","-","info",":","TrialInfo","An","object","containing","the","configuration","launched",".","value",":","TrialValue","Contains","information","about","the","status\/performance","of","config","."]
code: def run_wrapper(
      self,
      trial_info: TrialInfo,
      **dask_data_to_scatter: dict[str, Any],
  ) -> tuple[TrialInfo, TrialValue]:
      """Wrapper around run() to execute and check the execution of a given config.
      This function encapsulates common
      handling/processing, so that run() implementation is simplified.
  
      Parameters
      ----------
      trial_info : RunInfo
          Object that contains enough information to execute a configuration run in isolation.
      dask_data_to_scatter: dict[str, Any]
          When a user scatters data from their local process to the distributed network,
          this data is distributed in a round-robin fashion grouping by number of cores.
          Roughly speaking, we can keep this data in memory and then we do not have to (de-)serialize the data
          every time we would like to execute a target function with a big dataset.
          For example, when your target function has a big dataset shared across all the target function,
          this argument is very useful.
  
      Returns
      -------
      info : TrialInfo
          An object containing the configuration launched.
      value : TrialValue
          Contains information about the status/performance of config.
      """
      start = time.time()
  
      try:
          status, cost, runtime, additional_info = self.run(
              config=trial_info.config,
              instance=trial_info.instance,
              budget=trial_info.budget,
              seed=trial_info.seed,
              **dask_data_to_scatter,
          )
      except Exception as e:
          status = StatusType.CRASHED
          cost = self._crash_cost
          runtime = time.time() - start
  
          # Add context information to the error message
          exception_traceback = traceback.format_exc()
          error_message = repr(e)
          additional_info = {
              "traceback": exception_traceback,
              "error": error_message,
          }
  
      end = time.time()
  
      # Catch NaN or inf
      if not np.all(np.isfinite(cost)):
          logger.warning(
              "Target function returned infinity or nothing at all. Result is treated as CRASHED"
              f" and cost is set to {self._crash_cost}."
          )
  
          if "traceback" in additional_info:
              logger.warning(
                  f"Traceback: {additional_info['traceback']}\n"
              )
  
          status = StatusType.CRASHED
  
      if status == StatusType.CRASHED:
          cost = self._crash_cost
  
      trial_value = TrialValue(
          status=status,
          cost=cost,
          time=runtime,
          additional_info=additional_info,
          starttime=start,
          endtime=end,
      )
  
      return trial_info, trial_value
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from typing import Any, Iterator
  import time
  import traceback
  import numpy
  from ConfigSpace import Configuration
  from smac.runhistory import StatusType, TrialInfo, TrialValue
  from smac.scenario import Scenario
  from smac.utils.logging import get_logger
label_desc: Use image node_id 2 for calling the AbstractRunner obj's underlying member method code with example usage: obj.run_wrapper(trial_info) and returns: trial_info,  trial_value