code: def get_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]],
      stats: Dict[int, Dict[str, float]],
      ranges: Optional[Dict[str, List[float]]] = None,
      immutable_features: Optional[List[str]] = None,
      diverse=False,
  ) -> np.ndarray:
      """
      Generates a conditional vector. The condition is expressed a a delta change of the feature.
  
      For numerical features, if the ``'Age'`` feature is allowed to increase up to 10 more years, the delta change is
      [0, 10].  If the ``'Hours per week'`` is allowed to decrease down to -5 and increases up to +10, then the
      delta change is [-5, +10]. Note that the interval must go include 0.
  
      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.
      stats
          Dictionary of statistic of the training data. Contains the minimum and maximum value of each numerical
          feature in the training set. Each key is an index of the column and each value is another dictionary
          containing ``'min'`` and ``'max'`` keys.
      ranges
          Dictionary of ranges for numerical feature. Each value is a list containing two elements, first one
          negative and the second one positive.
      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
      -------
      Conditional vector.
      """
      if ranges is None:
          ranges = dict()
  
      if immutable_features is None:
          immutable_features = list()
  
      # Reshape the vector.
      X = X.reshape(1, -1) if len(X.shape) == 1 else X
  
      # Check that the second dimension matches the number of features.
      if X.shape[1] != len(feature_names):
          raise ValueError(
              f"Unexpected number of features. The expected number "
              f"is {len(feature_names)}, but the input has {X.shape[1]} features."
          )
  
      # Get list of numerical conditional vectors.
      C_num = get_numerical_conditional_vector(
          X=X,
          condition=condition,
          preprocessor=preprocessor,
          feature_names=feature_names,
          category_map=category_map,
          stats=stats,
          ranges=ranges,
          immutable_features=immutable_features,
          diverse=diverse,
      )
  
      # Get list of categorical conditional vectors.
      C_cat = get_categorical_conditional_vector(
          X=X,
          condition=condition,
          preprocessor=preprocessor,
          feature_names=feature_names,
          category_map=category_map,
          immutable_features=immutable_features,
          diverse=diverse,
      )
  
      # concat all conditioning
      return np.concatenate(C_num + 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 13 for calling a global function with example usage: get_conditional_vector(X, condition, preprocessor, feature_names, category_map, stats, ranges, immutable_features, diverse) and returns: np