code: def test_get_categorical_condition(dataset):
      """Test the training categorical conditional generator."""
  
      # Unpack dataset
      X = dataset["X_train"]
      feature_names = dataset["metadata"]["feature_names"]
      category_map = dataset["metadata"].get("category_map", {})
  
      # Get heterogeneous preprocessor
      preprocessor, _ = get_he_preprocessor(
          X=X, feature_names=feature_names, category_map=category_map
      )
  
      # Generate set of immutable features
      categorical_cols = [feature_names[i] for i in category_map]
  
      if len(category_map):
          immutable_features = np.random.choice(
              categorical_cols,
              size=np.random.randint(low=0, high=len(categorical_cols)),
          )
      else:
          immutable_features = []
  
      # Generate conditional vector
      C = get_categorical_conditional_vector(
          X=X,
          condition={},
          preprocessor=preprocessor,
          feature_names=feature_names,
          category_map=category_map,
          immutable_features=immutable_features,
      )
  
      if category_map:
          for i, fn in zip(range(len(C)), categorical_cols):
              # Check immutable features.
              if fn in immutable_features:
                  assert np.all(np.sum(C[i], axis=1) == 1)
              else:
                  # Check that the masks contain the original value
                  assert np.all(
                      C[i][
                          np.arange(X.shape[0]),
                          X[:, feature_names.index(fn)],
                      ]
                      == 1
                  )
  
      else:
          assert len(C) == 0
  
imports: from typing import Union, List
  import pytest
  from pytest_lazyfixture import lazy_fixture
  import numpy
  from numpy.testing import assert_allclose
  import tensorflow
  import tensorflow.keras
  from alibi.explainers import CounterfactualRLTabular
  from alibi.explainers.backends.cfrl_base import get_hard_distribution
  from alibi.explainers.backends.cfrl_tabular import get_he_preprocessor, split_ohe, get_numerical_conditional_vector, get_categorical_conditional_vector, get_statistics, get_conditional_vector, sample
label_desc: Use image node_id 4 for calling a global function with example usage: test_get_categorical_condition(dataset) without return types