code: def get_categorical_conditional_vector(
      X: np.ndarray,
      condition: Dict[str, List[Union[float, str]]],
      preprocessor: Callable[[np.ndarray], np.ndarray],
      feature_names: List[str],
      category_map: Dict[int, List[str]],
      immutable_features: Optional[List[str]] = None,
      diverse=False,
  ) -> List[np.ndarray]:
      """
      Generates a conditional vector. The condition is expressed a a delta change of the feature.
      For categorical feature, if the ``'Occupation'`` can change to ``'Blue-Collar'`` or ``'White-Collar'``, the delta
      change is ``['Blue-Collar', 'White-Collar']``. Note that the original value is optional as it is
      included by default.
  
      Parameters
      ----------
      X
          Instances for which to generate the conditional vector in the original input format.
      condition
          Dictionary of conditions per feature. For numerical features it expects a range that contains the original
          value. For categorical features it expects a list of feature values per features that includes the original
          value.
      preprocessor
          Data preprocessor. The preprocessor should standardize the numerical values and convert categorical ones
          into one-hot encoding representation. By convention, numerical features should be first, followed by the
          rest of categorical ones.
      feature_names
          List of feature names. This should be provided by the dataset.
      category_map
          Dictionary of category mapping. The keys are column indexes and the values are lists containing the
          possible feature values.  This should be provided by the dataset.
      immutable_features
          List of immutable features.
      diverse
          Whether to generate a diverse set of conditional vectors. A diverse set of conditional vector can generate
          a diverse set of counterfactuals for a given input instance.
  
      Returns
      -------
      List of conditional vectors for each categorical feature.
      """
      if immutable_features is None:
          immutable_features = list()
  
      # Define conditional vector buffer
      C = []
  
      # extract categorical features
      cat_features_ids = [
          id for id in range(X.shape[1]) if id in category_map
      ]
      cat_feature_names = [feature_names[id] for id in cat_features_ids]
  
      # Extract list of categorical one-hot encoded columns
      X_ohe = preprocessor(X)
      _, X_ohe_cat_split = split_ohe(X_ohe, category_map)
  
      # For each categorical feature add the masking vector
      for i, (feature_id, feature_name) in enumerate(
          zip(cat_features_ids, cat_feature_names)
      ):
          mask = np.zeros_like(X_ohe_cat_split[i])
  
          if feature_name not in immutable_features:
              if feature_name in condition:
                  indexes = [
                      category_map[feature_id].index(str(feature_value))
                      for feature_value in condition[feature_name]
                  ]  # conversion to str because of mypy (can be also float)
                  mask[:, indexes] = 1
              else:
                  # Allow any value
                  mask[:] = 1
  
          if diverse:
              # Note that by masking random entries we still have a feasible counterfactual
              mask *= np.random.randint(low=0, high=2, size=mask.shape)
  
          # Ensure that the original value is a possibility
          mask = ((mask + X_ohe_cat_split[i]) > 0).astype(int)
  
          # Append feature conditioning
          C.append(mask)
      return C
  
imports: from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  from scipy.special import softmax
  from sklearn.compose import ColumnTransformer
  from sklearn.preprocessing import OneHotEncoder, StandardScaler
label_desc: Use image node_id 12 for calling a global function with example usage: get_categorical_conditional_vector(X, condition, preprocessor, feature_names, category_map, immutable_features, diverse) and returns: C