code: def auto_fit_encoders(
      X: np.ndarray,
      Y: Optional[np.ndarray] = None,
      catboost_threshold: int = 7,
  ) -> Dict[int, Union[OneHotEncoder, CatBoostEncoder]]:
      if Y is None:
          return fit_one_hot_encoders(X)
  
      X = shape_into_2d(X)
  
      total_num_categories = 0
      for column in range(X.shape[1]):
          if is_categorical(X[:, column]):
              total_num_categories += len(np.unique(X[:, column]))
  
      if total_num_categories > catboost_threshold:
          return fit_catboost_encoders(X, Y)
      else:
          return fit_one_hot_encoders(X)
  
imports: import random
  from typing import Dict, Optional, Union
  import numpy
  from scipy.optimize import minimize
  from sklearn.preprocessing import OneHotEncoder
  from dowhy.gcm.util.catboost_encoder import CatBoostEncoder
label_desc: Use image node_id 3 for calling a global function with example usage: auto_fit_encoders(X, Y, catboost_threshold) and returns: fit_one_hot_encoders, fit_catboost_encoders, fit_one_hot_encoders