code: def cook_estimator(base_estimator, space=None, **kwargs):
      """Cook a default estimator
  
      For the special `base_estimator` called "DUMMY", the return value is None. This corresponds to
      sampling points at random, hence there is no need for an estimator
  
      Parameters
      ----------
      base_estimator: {SKLearn Regressor, "GP", "RF", "ET", "GBRT", "DUMMY"}, default="GP"
          If not string, should inherit from `sklearn.base.RegressorMixin`. In addition, the `predict`
          method should have an optional `return_std` argument, which returns `std(Y | x)`,
          along with `E[Y | x]`.
  
          If `base_estimator` is a string in {"GP", "RF", "ET", "GBRT", "DUMMY"}, a surrogate model
          corresponding to the relevant `X_minimize` function is created
      space: `hyperparameter_hunter.space.space_core.Space`
          Required only if the `base_estimator` is a Gaussian Process. Ignored otherwise
      **kwargs: Dict
          Extra parameters provided to the `base_estimator` at initialization time
  
      Returns
      -------
      SKLearn Regressor
          Regressor instance cooked up according to `base_estimator` and `kwargs`
      """
      #################### Validate `base_estimator` ####################
      str_estimators = ["GP", "ET", "RF", "GBRT", "DUMMY"]
      if isinstance(base_estimator, str):
          if base_estimator.upper() not in str_estimators:
              raise ValueError(
                  f"Expected `base_estimator` in {str_estimators}. Got {base_estimator}"
              )
          # Convert to upper after error check, so above error shows actual given `base_estimator`
          base_estimator = base_estimator.upper()
      elif not is_regressor(base_estimator):
          raise ValueError("`base_estimator` must be a regressor")
  
      #################### Get Cooking ####################
      if base_estimator == "GP":
          if space is not None:
              space = Space(space)
              # NOTE: Below `normalize_dimensions` is NOT an unnecessary duplicate of the call in
              #   `Optimizer` - `Optimizer` calls `cook_estimator` before its `dimensions` have been
              #   normalized, so `normalize_dimensions` must also be called here
              space = Space(normalize_dimensions(space.dimensions))
              n_dims = space.transformed_n_dims
              is_cat = space.is_categorical
          else:
              raise ValueError("Expected a `Space` instance, not None")
  
          cov_amplitude = ConstantKernel(1.0, (0.01, 1000.0))
          # Only special if *all* dimensions are `Categorical`
          if is_cat:
              other_kernel = HammingKernel(length_scale=np.ones(n_dims))
          else:
              other_kernel = Matern(
                  length_scale=np.ones(n_dims),
                  length_scale_bounds=[(0.01, 100)] * n_dims,
                  nu=2.5,
              )
  
          base_estimator = GaussianProcessRegressor(
              kernel=cov_amplitude * other_kernel,
              normalize_y=True,
              noise="gaussian",
              n_restarts_optimizer=2,
          )
      elif base_estimator == "RF":
          base_estimator = RandomForestRegressor(
              n_estimators=100, min_samples_leaf=3
          )
      elif base_estimator == "ET":
          base_estimator = ExtraTreesRegressor(
              n_estimators=100, min_samples_leaf=3
          )
      elif base_estimator == "GBRT":
          gbrt = GradientBoostingRegressor(
              n_estimators=30, loss="quantile"
          )
          base_estimator = GradientBoostingQuantileRegressor(
              base_estimator=gbrt
          )
      elif base_estimator == "DUMMY":
          return None
  
      base_estimator.set_params(**kwargs)
      return base_estimator
  
imports: from hyperparameter_hunter.settings import G
  from hyperparameter_hunter.space.space_core import Space, normalize_dimensions
  from joblib import Parallel, delayed
  from math import log
  from numbers import Number
  import numpy
  import sys
  import warnings
  from scipy.optimize import fmin_l_bfgs_b
  from sklearn.base import clone, is_regressor
  from sklearn.ensemble import GradientBoostingRegressor
  from sklearn.multioutput import MultiOutputRegressor
  from sklearn.utils import check_random_state
  from skopt.acquisition import _gaussian_acquisition, gaussian_acquisition_1D
  from skopt.learning import ExtraTreesRegressor, GaussianProcessRegressor, GradientBoostingQuantileRegressor, RandomForestRegressor
  from skopt.learning.gaussian_process.kernels import ConstantKernel, HammingKernel, Matern
  from skopt.utils import create_result, has_gradients
label_desc: Use image node_id 4 for calling a global function with example usage: cook_estimator(base_estimator, space) and returns: base_estimator, None