code: def apply_catboost_encoding(
      X: np.ndarray,
      catboost_encoder_map: Dict[int, CatBoostEncoder],
      Y: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      X = shape_into_2d(X)
  
      if not catboost_encoder_map:
          return X
  
      one_hot_features = []
  
      for column in range(X.shape[1]):
          if column in catboost_encoder_map:
              one_hot_features.append(
                  catboost_encoder_map[column]
                  .transform(X[:, column], Y)
                  .reshape(-1, 1)
              )
          else:
              one_hot_features.append(X[:, column].reshape(-1, 1))
  
      return np.hstack(one_hot_features).astype(float)
  
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 8 for calling a global function with example usage: apply_catboost_encoding(X, catboost_encoder_map, Y) and returns: np, X