code: def prepare_estimator_for_categoricals(
      estimator: BaseEstimator,
      categorical_indices: List[int],
      *,
      preparation_type: str,
  ):
      fit_params = {}
      if not categorical_indices:
          return estimator, fit_params
      if preparation_type.startswith("fit_params_"):
          fit_param_name = preparation_type[len("fit_params_") :]
          fit_params[fit_param_name] = categorical_indices
      elif preparation_type.startswith("params_"):
          param_name = preparation_type[len("params_") :]
          estimator.set_params(**{param_name: categorical_indices})
      elif preparation_type == "ordinal":
          estimator = SklearnPipeline(
              [
                  (
                      "encoder",
                      ColumnTransformer(
                          [
                              (
                                  "encoder",
                                  SklearnOrdinalEncoder(
                                      handle_unknown="use_encoded_value",
                                      unknown_value=-1,
                                  ),
                                  categorical_indices,
                              )
                          ],
                          remainder="passthrough",
                      ),
                  ),
                  ("estimator", estimator),
              ]
          )
      elif preparation_type == "one_hot":
          estimator = SklearnPipeline(
              [
                  (
                      "encoder",
                      ColumnTransformer(
                          [
                              (
                                  "encoder",
                                  SklearnOneHotEncoder(
                                      handle_unknown="ignore"
                                  ),
                                  categorical_indices,
                              )
                          ],
                          remainder="passthrough",
                      ),
                  ),
                  ("estimator", estimator),
              ]
          )
      elif preparation_type:
          raise ValueError(
              f"Unknown preparation_type {preparation_type}"
          )
      return estimator, fit_params
  
imports: from __future__ import annotations
  import warnings
  from time import time
  from typing import List, Optional
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, clone
  from sklearn.compose import ColumnTransformer
  from sklearn.dummy import DummyClassifier
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.experimental import enable_iterative_imputer
  from sklearn.impute import IterativeImputer
  from sklearn.impute import SimpleImputer
  from sklearn.impute._iterative import FLOAT_DTYPES, _check_inputs_dtype, _get_mask, _ImputerTriplet, _safe_indexing, is_scalar_nan, stats
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import OneHotEncoder
  from sklearn.preprocessing import OrdinalEncoder
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_estimator_for_categoricals(estimator, categorical_indices) and returns: estimator,  fit_params, estimator,  fit_params