code: def generate_categorical_condition(
      X_ohe: np.ndarray,
      feature_names: List[str],
      category_map: Dict[int, List],
      immutable_features: List[str],
      conditional: bool = True,
  ) -> np.ndarray:
      """
      Generates categorical features conditional vector. For a categorical feature of cardinality `K`, we condition the
      subset of allowed feature through a binary mask of dimension `K`. When training the counterfactual generator,
      the mask values are sampled from `Bern(0.5)`. For immutable features, only the original input feature value is
      set to one in the binary mask. For example, the immutability of the ``'marital_status'`` having the current
      value ``'married'`` is encoded through the binary sequence [1, 0, 0], given an ordering of the possible feature
      values `[married, unmarried, divorced]`.
  
      Parameters
      ----------
      X_ohe
          One-hot encoding representation of the element(s) for which the conditional vector will be generated.
          The elements are required since some features can be immutable. In that case, the mask vector is the
          one-hot encoding itself for that particular feature.
      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.
      immutable_features
          List of immutable features.
      conditional
          Boolean flag to generate a conditional vector. If ``False`` the conditional vector does not impose any
          restrictions on the feature value.
  
      Returns
      -------
      Conditional vector for categorical feature.
      """
  
      C_cat = []  # define list of conditional vector for each feature
      cat_idx = 0  # categorical feature index
  
      # Split the one-hot representation into a list where each element corresponds to an feature.
      _, X_ohe_cat_split = split_ohe(X_ohe, category_map)
  
      # Create mask for each categorical column.
      for feature_id, feature_name in enumerate(feature_names):
          # Skip numerical features
          if feature_id not in category_map:
              continue
  
          # Initialize mask with the original value
          mask = X_ohe_cat_split[cat_idx].copy()
  
          # If the feature is not immutable, add noise to modify the mask
          if feature_name not in immutable_features:
              mask += (
                  np.random.rand(*mask.shape)
                  if conditional
                  else np.ones_like(mask)
              )
  
          # Construct binary mask
          mask = (mask > 0.5).astype(np.float32)
          C_cat.append(mask)
  
          # Move to the next categorical index
          cat_idx += 1
  
      return np.concatenate(C_cat, axis=1)
  
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 4 for calling a global function with example usage: generate_categorical_condition(X_ohe, feature_names, category_map, immutable_features, conditional) and returns: np