code: def get_hyperparameter_searcher(
      hyperparameter_grid,
      model,
      cv=None,
      hyperparameter_budget=None,
      n_jobs=1,
      verbose=1,
      **kwargs,
  ) -> RandomizedSearchCV:
      """Returns RandomizedSearchCV object for hyperparameter tuning via cross validation
  
      `sklearn.model_selection.RandomizedSearchCV` runs a full grid search if
      ``hyperparameter_budget`` is sufficient to exhaust the full
      ``hyperparameter_grid``, otherwise it samples uniformly at random from the space.
  
      Parameters
      ----------
      hyperparameter_grid : `dict` or `list` [`dict`]
          Dictionary with parameters names (string) as keys and distributions
          or lists of parameters to try. Distributions must provide a ``rvs``
          method for sampling (such as those from scipy.stats.distributions).
          Lists of parameters are sampled uniformly.
  
          May also be a list of such dictionaries to avoid undesired combinations of parameters.
          Passed as ``param_distributions`` to `sklearn.model_selection.RandomizedSearchCV`,
          see docs for more info.
      model: estimator object
          A object of that type is instantiated for each grid point. This is assumed to implement
          the scikit-learn estimator interface.
      cv: `int`, cross-validation generator, iterable, or None, default None
          Determines the cross-validation splitting strategy.
          See `sklearn.model_selection.RandomizedSearchCV`.
      hyperparameter_budget: `int` or None, default None
          max number of hyperparameter sets to try within the hyperparameter_grid search space
          If None, uses defaults:
  
              * exhaustive grid search if all values are constant
              * 10 if any value is a distribution to sample from
  
      n_jobs : `int` or None, default 1
          Number of jobs to run in parallel
          (the maximum number of concurrently running workers).
          ``-1`` uses all CPUs. ``-2`` uses all CPUs but one.
          ``None`` is treated as 1 unless in a `joblib.Parallel` backend context
          that specifies otherwise.
      verbose : `int`, default 1
          Verbosity level during CV.
  
          * if > 0, prints number of fits
          * if > 1, prints fit parameters, total score + fit time
          * if > 2, prints train/test scores
      kwargs : additional parameters
          Keyword arguments to pass to `~greykite.framework.pipeline.utils.get_scoring_and_refit`.
          Accepts the following parameters:
  
              - ``"score_func"``
              - ``"score_func_greater_is_better"``
              - ``"cv_report_metrics"``
              - ``"agg_periods"``
              - ``"agg_func"``
              - ``"relative_error_tolerance"``
  
      Returns
      -------
      grid_search : `sklearn.model_selection.RandomizedSearchCV`
          Object that can run randomized search on hyper parameters.
      """
      if hyperparameter_budget is None:
          # sets reasonable defaults when hyperparameter_budget is not provided
          try:
              # exhaustive search if explicit values are provided
              hyperparameter_budget = len(
                  ParameterGrid(hyperparameter_grid)
              )
              log_message(
                  f"Setting hyperparameter_budget to {hyperparameter_budget} for full grid search.",
                  LoggingLevelEnum.DEBUG,
              )
          except TypeError:  # parameter value is not iterable
              # sets budget to 10 if distribution for randomized search is provided
              hyperparameter_budget = 10
              log_message(
                  f"Setting hyperparameter_budget to {hyperparameter_budget} to sample from"
                  f" provided distributions (and lists).",
                  LoggingLevelEnum.WARNING,
              )
  
      scoring, refit = get_scoring_and_refit(**kwargs)
  
      # note: RandomizedSearchCV operates like GridSearchCV when hyperparameter_grid contains no distributions
      grid_search = RandomizedSearchCV(
          estimator=model,
          param_distributions=hyperparameter_grid,  # a fixed list or distribution to sample from
          n_iter=hyperparameter_budget,  # samples uniformly, up to hyperparameter_budget
          scoring=scoring,  # model evaluation criteria (note: if None, uses the score function of the estimator)
          n_jobs=n_jobs,  # parallelism
          refit=refit,  # selects the best model
          cv=cv,
          verbose=verbose,
          pre_dispatch="2*n_jobs",  # controls memory consumption
          return_train_score=True,  # NB: could be False for speedup
      )
      return grid_search
  
imports: import math
  from functools import partial
  import pandas
  from sklearn.base import clone
  from sklearn.model_selection import ParameterGrid
  from sklearn.model_selection import RandomizedSearchCV
  from sklearn.pipeline import Pipeline
  from greykite.common import constants
  from greykite.common.constants import FRACTION_OUTSIDE_TOLERANCE
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.evaluation import add_finite_filter_to_scorer
  from greykite.common.evaluation import add_preaggregation_to_scorer
  from greykite.common.evaluation import fraction_outside_tolerance
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import get_integer
  from greykite.common.python_utils import unique_elements_in_list
  from greykite.common.time_properties_forecast import get_default_horizon_from_period
  from greykite.framework.constants import CUSTOM_SCORE_FUNC_NAME
  from greykite.framework.constants import CV_REPORT_METRICS_ALL
  from greykite.framework.constants import FRACTION_OUTSIDE_TOLERANCE_NAME
  from greykite.framework.output.univariate_forecast import UnivariateForecast
  from greykite.sklearn.estimator.simple_silverkite_estimator import SimpleSilverkiteEstimator
  from greykite.sklearn.sklearn_scorer import make_scorer_df
  from greykite.sklearn.transform.column_selector import ColumnSelector
  from greykite.sklearn.transform.difference_based_outlier_transformer import DifferenceBasedOutlierTransformer
  from greykite.sklearn.transform.drop_degenerate_transformer import DropDegenerateTransformer
  from greykite.sklearn.transform.dtype_column_selector import DtypeColumnSelector
  from greykite.sklearn.transform.normalize_transformer import NormalizeTransformer
  from greykite.sklearn.transform.null_transformer import NullTransformer
  from greykite.sklearn.transform.pandas_feature_union import PandasFeatureUnion
label_desc: Use image node_id 6 for calling a global function with example usage: get_hyperparameter_searcher(hyperparameter_grid, model, cv, hyperparameter_budget, n_jobs, verbose) and returns: grid_search