docstr: Base class for intermediate base optimization protocol classes
  
  There are two important methods for all :class:`BaseOptPro` descendants that should be
  invoked after initialization:
  
  1. :meth:`~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.forge_experiment`
  2. :meth:`~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.go`
  
  Parameters
  ----------
  target_metric: Tuple, default=("oof", <:attr:`environment.Environment.metrics`[0]>)
      Rarely necessary to explicitly provide this, as the default is usually sufficient. Path
      denoting the metric to be used to compare Experiment performance. The first value
      should be one of ["oof", "holdout", "in_fold"]. The second value should be the name of
      a metric being recorded according to :attr:`environment.Environment.metrics_params`.
      See the documentation for :func:`metrics.get_formatted_target_metric` for more info.
      Any values returned by, or given as the `target_metric` input to,
      :func:`~hyperparameter_hunter.metrics.get_formatted_target_metric` are acceptable
      values for :attr:`BaseOptPro.target_metric`
  iterations: Int, default=1
      Number of Experiments to conduct during optimization upon invoking :meth:`BaseOptPro.go`
  verbose: {0, 1, 2}, default=1
      Verbosity mode for console logging. 0: Silent. 1: Show only logs from the Optimization
      Protocol. 2: In addition to logs shown when verbose=1, also show the logs from
      individual Experiments
  read_experiments: Boolean, default=True
      If True, all Experiment records that fit in the current :attr:`space` and guidelines,
      and match :attr:`algorithm_name`, will be read in and used to fit any optimizers
  reporter_parameters: Dict, or None, default={}
      Additional parameters passed to :meth:`reporting.OptimizationReporter.__init__`. Note:
      Unless provided explicitly, the key "do_maximize" will be added by default to
      `reporter_params`, with a value inferred from the `direction` of :attr:`target_metric`
      in `G.Env.metrics`. In nearly all cases, the "do_maximize" key should be ignored,
      as there are very few reasons to explicitly include it
  warn_on_re_ask: Boolean, default=False
      If True, and the internal `optimizer` recommends a point that has already been evaluated
      on invocation of `ask`, a warning is logged before recommending a random point. Either
      way, a random point is used instead of already-evaluated recommendations. However,
      logging the fact that this has taken place can be useful to indicate that the optimizer
      may be stalling, especially if it repeatedly recommends the same point. In these cases,
      if the suggested point is not optimal, it can be helpful to switch a different OptPro
      (especially `DummyOptPro`), which will suggest points using different criteria
  
  Methods
  -------
  forge_experiment
      Define constraints on Experiments conducted by OptPro (like hyperparameter search space)
  go
      Start optimization
  
  Notes
  -----
  By default, 'script_backup' for Experiments is blacklisted when executed within
  :class:`BaseOptPro` since it would just repeatedly create copies of the same, unchanged
  file. So don't expect any script_backup files for Experiments executed by OptPros
docstr_tok: ["Base","class","for","intermediate","base","optimization","protocol","classes","There","are","two","important","methods","for","all",":","class",":","`","BaseOptPro","`","descendants","that","should","be","invoked","after","initialization",":","1.",":","meth",":","`","~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.forge_experiment","`","2.",":","meth",":","`","~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.go","`","Parameters","--","--","--","--","--","target_metric",":","Tuple",",","default=","(","``","oof","''",",","<",":","attr",":","`","environment.Environment.metrics","`","[","0","]",">",")","Rarely","necessary","to","explicitly","provide","this",",","as","the","default","is","usually","sufficient",".","Path","denoting","the","metric","to","be","used","to","compare","Experiment","performance",".","The","first","value","should","be","one","of","[","``","oof","''",",","``","holdout","''",",","``","in_fold","''","]",".","The","second","value","should","be","the","name","of","a","metric","being","recorded","according","to",":","attr",":","`","environment.Environment.metrics_params","`",".","See","the","documentation","for",":","func",":","`","metrics.get_formatted_target_metric","`","for","more","info",".","Any","values","returned","by",",","or","given","as","the","`","target_metric","`","input","to",",",":","func",":","`","~hyperparameter_hunter.metrics.get_formatted_target_metric","`","are","acceptable","values","for",":","attr",":","`","BaseOptPro.target_metric","`","iterations",":","Int",",","default=1","Number","of","Experiments","to","conduct","during","optimization","upon","invoking",":","meth",":","`","BaseOptPro.go","`","verbose",":","{","0",",","1",",","2","}",",","default=1","Verbosity","mode","for","console","logging",".","0",":","Silent",".","1",":","Show","only","logs","from","the","Optimization","Protocol",".","2",":","In","addition","to","logs","shown","when","verbose=1",",","also","show","the","logs","from","individual","Experiments","read_experiments",":","Boolean",",","default=True","If","True",",","all","Experiment","records","that","fit","in","the","current",":","attr",":","`","space","`","and","guidelines",",","and","match",":","attr",":","`","algorithm_name","`",",","will","be","read","in","and","used","to","fit","any","optimizers","reporter_parameters",":","Dict",",","or","None",",","default=","{","}","Additional","parameters","passed","to",":","meth",":","`","reporting.OptimizationReporter.__init__","`",".","Note",":","Unless","provided","explicitly",",","the","key","``","do_maximize","''","will","be","added","by","default","to","`","reporter_params","`",",","with","a","value","inferred","from","the","`","direction","`","of",":","attr",":","`","target_metric","`","in","`","G.Env.metrics","`",".","In","nearly","all","cases",",","the","``","do_maximize","''","key","should","be","ignored",",","as","there","are","very","few","reasons","to","explicitly","include","it","warn_on_re_ask",":","Boolean",",","default=False","If","True",",","and","the","internal","`","optimizer","`","recommends","a","point","that","has","already","been","evaluated","on","invocation","of","`","ask","`",",","a","warning","is","logged","before","recommending","a","random","point",".","Either","way",",","a","random","point","is","used","instead","of","already-evaluated","recommendations",".","However",",","logging","the","fact","that","this","has","taken","place","can","be","useful","to","indicate","that","the","optimizer","may","be","stalling",",","especially","if","it","repeatedly","recommends","the","same","point",".","In","these","cases",",","if","the","suggested","point","is","not","optimal",",","it","can","be","helpful","to","switch","a","different","OptPro","(","especially","`","DummyOptPro","`",")",",","which","will","suggest","points","using","different","criteria","Methods","--","--","--","-","forge_experiment","Define","constraints","on","Experiments","conducted","by","OptPro","(","like","hyperparameter","search","space",")","go","Start","optimization","Notes","--","--","-","By","default",",","'script_backup","'","for","Experiments","is","blacklisted","when","executed","within",":","class",":","`","BaseOptPro","`","since","it","would","just","repeatedly","create","copies","of","the","same",",","unchanged","file",".","So","do","n't","expect","any","script_backup","files","for","Experiments","executed","by","OptPros"]
code: def __init__(
      self,
      target_metric=None,
      iterations=1,
      verbose=1,
      read_experiments=True,
      reporter_parameters=None,
      warn_on_re_ask=False,
  ):
      """Base class for intermediate base optimization protocol classes
  
      There are two important methods for all :class:`BaseOptPro` descendants that should be
      invoked after initialization:
  
      1. :meth:`~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.forge_experiment`
      2. :meth:`~hyperparameter_hunter.optimization.protocol_core.BaseOptPro.go`
  
      Parameters
      ----------
      target_metric: Tuple, default=("oof", <:attr:`environment.Environment.metrics`[0]>)
          Rarely necessary to explicitly provide this, as the default is usually sufficient. Path
          denoting the metric to be used to compare Experiment performance. The first value
          should be one of ["oof", "holdout", "in_fold"]. The second value should be the name of
          a metric being recorded according to :attr:`environment.Environment.metrics_params`.
          See the documentation for :func:`metrics.get_formatted_target_metric` for more info.
          Any values returned by, or given as the `target_metric` input to,
          :func:`~hyperparameter_hunter.metrics.get_formatted_target_metric` are acceptable
          values for :attr:`BaseOptPro.target_metric`
      iterations: Int, default=1
          Number of Experiments to conduct during optimization upon invoking :meth:`BaseOptPro.go`
      verbose: {0, 1, 2}, default=1
          Verbosity mode for console logging. 0: Silent. 1: Show only logs from the Optimization
          Protocol. 2: In addition to logs shown when verbose=1, also show the logs from
          individual Experiments
      read_experiments: Boolean, default=True
          If True, all Experiment records that fit in the current :attr:`space` and guidelines,
          and match :attr:`algorithm_name`, will be read in and used to fit any optimizers
      reporter_parameters: Dict, or None, default={}
          Additional parameters passed to :meth:`reporting.OptimizationReporter.__init__`. Note:
          Unless provided explicitly, the key "do_maximize" will be added by default to
          `reporter_params`, with a value inferred from the `direction` of :attr:`target_metric`
          in `G.Env.metrics`. In nearly all cases, the "do_maximize" key should be ignored,
          as there are very few reasons to explicitly include it
      warn_on_re_ask: Boolean, default=False
          If True, and the internal `optimizer` recommends a point that has already been evaluated
          on invocation of `ask`, a warning is logged before recommending a random point. Either
          way, a random point is used instead of already-evaluated recommendations. However,
          logging the fact that this has taken place can be useful to indicate that the optimizer
          may be stalling, especially if it repeatedly recommends the same point. In these cases,
          if the suggested point is not optimal, it can be helpful to switch a different OptPro
          (especially `DummyOptPro`), which will suggest points using different criteria
  
      Methods
      -------
      forge_experiment
          Define constraints on Experiments conducted by OptPro (like hyperparameter search space)
      go
          Start optimization
  
      Notes
      -----
      By default, 'script_backup' for Experiments is blacklisted when executed within
      :class:`BaseOptPro` since it would just repeatedly create copies of the same, unchanged
      file. So don't expect any script_backup files for Experiments executed by OptPros
      """
      #################### Optimization Protocol Parameters ####################
      self.target_metric = target_metric
      self.iterations = iterations
      self.verbose = verbose
      self.read_experiments = read_experiments
      self.reporter_parameters = reporter_parameters or {}
      self.warn_on_re_ask = warn_on_re_ask
  
      #################### Experiment Guidelines ####################
      self.model_initializer = None
      self.model_init_params = None
      self.model_extra_params = None
      self.feature_engineer = None
      self.feature_selector = None
      self.notes = None
      self.do_raise_repeated = True
  
      #################### Search Parameters ####################
      self.dimensions = []
      self.search_bounds = dict()
  
      self.space = None
      self.similar_experiments = []
      self.best_experiment = None
      self.best_score = None
      self.successful_iterations = 0
      self.skipped_iterations = 0
      self.tested_keys = []
      self._search_space_size = None
  
      #################### Incumbent Hyperparameters ####################
      self.current_init_params = None
      self.current_extra_params = None
      self.current_feature_engineer = None
  
      #################### Identification Attributes ####################
      self.algorithm_name = None
      self.module_name = None
      self.current_experiment = None
      self.current_score = None
  
      #################### Keras-Specific Attributes ####################
      self.dummy_layers = []
      self.dummy_compile_params = dict()
  
      #################### Secret Sauce ####################
      self.init_iter_attrs = []
      self.extra_iter_attrs = []
      self.fe_iter_attrs = [
          lambda p, k, v: isinstance(v, FeatureEngineer)
      ]
  
      self.logger = None
      self._preparation_workflow()
      self.do_maximize = (
          G.Env.metrics[self.target_metric[-1]].direction == "max"
      )
  
imports: from hyperparameter_hunter import __version__
  from hyperparameter_hunter.algorithm_handlers import identify_algorithm, identify_algorithm_hyperparameters
  from hyperparameter_hunter.experiments import CVExperiment
  from hyperparameter_hunter.feature_engineering import FeatureEngineer
  from hyperparameter_hunter.i_o.exceptions import EnvironmentInactiveError, EnvironmentInvalidError, RepeatedExperimentError, DeprecatedWarning
  from hyperparameter_hunter.i_o.reporting import OptimizationReporter
  from hyperparameter_hunter.i_o.result_reader import finder_selector
  from hyperparameter_hunter.compat.keras_helper import reinitialize_callbacks
  from hyperparameter_hunter.compat.keras_optimization_helper import keras_prep_workflow, link_choice_ids
  from hyperparameter_hunter.metrics import get_formatted_target_metric
  from hyperparameter_hunter.optimization.backends.skopt.engine import Optimizer, cook_estimator
  from hyperparameter_hunter.settings import G, TEMP_MODULES_DIR_PATH
  from hyperparameter_hunter.space.dimensions import RejectedOptional
  from hyperparameter_hunter.space.space_core import Space
  from hyperparameter_hunter.utils.boltons_utils import get_path
  from hyperparameter_hunter.utils.general_utils import deep_restricted_update, subdict
  from hyperparameter_hunter.utils.optimization_utils import get_choice_dimensions, dimension_subset
  from hyperparameter_hunter.utils.version_utils import Deprecated
  from abc import ABCMeta, abstractmethod
  from datetime import datetime
  from inspect import currentframe, getframeinfo
  from os import walk, remove, rmdir
  from os.path import abspath
  from typing import Any, Dict
  from warnings import warn
  from skopt.callbacks import check_callback
  from skopt.utils import eval_callbacks
label_desc: Use image node_id 1 to create a new BaseOptPro object  with example: obj = BaseOptPro(target_metric, iterations, verbose, read_experiments, reporter_parameters, warn_on_re_ask)