code: def test_he_preprocessor(dataset):
      """Test the heterogeneous preprocessor and inverse preprocessor."""
      # Unpack dataset.
      X = dataset["X_train"]
      feature_names = dataset["metadata"]["feature_names"]
      category_map = dataset["metadata"].get("category_map", dict())
  
      # Get heterogeneous preprocessor.
      preprocessor, inv_preprocessor = get_he_preprocessor(
          X=X, feature_names=feature_names, category_map=category_map
      )
  
      # Preprocess the dataset.
      X_ohe = preprocessor(X)
  
      # Check if the number of columns in the is the one expected.
      numerical_cols = [
          i for i in range(len(feature_names)) if i not in category_map
      ]
      total_num_cols = len(numerical_cols) + sum(
          [len(v) for v in category_map.values()]
      )
      assert total_num_cols == X_ohe.shape[1]
  
      # Test if the inverse preprocessor maps the ohe back to the original input.
      inv_X = inv_preprocessor(X_ohe)
      assert_allclose(X.astype(np.float32), inv_X.astype(np.float32))
  
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 1 for calling a global function with example usage: test_he_preprocessor(dataset) without return types