code: def test_sklearn_categorical(
      rf_classifier, adult_data, features, params
  ):
      """Checks `alibi` pd black-box implementation against the `sklearn` implementation for categorical features."""
  
      rf, preprocessor = rf_classifier
      rf_pipeline = Pipeline(
          steps=[("preprocessor", preprocessor), ("predictor", rf)]
      )
  
      # subsample data for faster computation
      X_train = adult_data["X_train"][:100]
  
      # Behaviour depends on sklearn version, See https://github.com/SeldonIO/alibi/pull/940#issuecomment-1623783025
      sklearn_version = version.parse(sklearn.__version__)
      if sklearn_version >= version.parse("1.3.0"):
          categorical_names = adult_data["metadata"]["category_map"]
          categorical_names = list(categorical_names.keys())
          params.update(categorical_features=categorical_names)
      else:
          params.update(grid_resolution=np.inf)
  
      # compute `sklearn` explanation
      exp_sklearn = partial_dependence(
          X=X_train, estimator=rf_pipeline, features=features, **params
      )
  
      # update intentionally grid_resolution to check that alibi behaves correctly for categorical features
      params.update(grid_resolution=100)
  
      # compute alibi explanation
      exp_alibi = get_alibi_pd_explanation(
          predictor=rf_pipeline.predict_proba,
          feature_names=adult_data["metadata"]["feature_names"],
          categorical_names=adult_data["metadata"]["category_map"],
          X=X_train,
          features=features,
          kind=params["kind"],
          percentiles=params["percentiles"],
          grid_resolution=params["grid_resolution"],
      )
  
      # compare explanations
      assert np.allclose(
          exp_alibi.data["pd_values"][0][1], exp_sklearn["average"]
      )
      assert_feature_values_equal(
          exp_alibi=exp_alibi, exp_sklearn=exp_sklearn
      )
  
imports: import re
  import sys
  from copy import deepcopy
  from typing import Dict, List, Optional, Tuple, Union
  from packaging import version
  import matplotlib.pyplot
  import numpy
  import pandas
  import pytest
  from pytest_lazyfixture import lazy_fixture
  from sklearn.base import BaseEstimator
  from sklearn.datasets import make_classification
  from sklearn.ensemble import GradientBoostingClassifier
  from sklearn.exceptions import NotFittedError
  from sklearn.inspection import partial_dependence
  from sklearn.model_selection import train_test_split
  from sklearn.multioutput import MultiOutputClassifier
  from sklearn.pipeline import Pipeline
  from sklearn.utils import Bunch, shuffle
  import sklearn
  from alibi.api.defaults import DEFAULT_DATA_PD, DEFAULT_META_PD
  from alibi.api.interfaces import Explanation
  from alibi.explainers import PartialDependence, TreePartialDependence, plot_pd
  from alibi.explainers.partial_dependence import _plot_one_pd_cat, _plot_one_pd_num, _plot_two_pd_cat_cat, _plot_two_pd_num_cat, _plot_two_pd_num_num, _process_pd_ice, _sample_ice
label_desc: Use image node_id 17 for calling a global function with example usage: test_sklearn_categorical(rf_classifier, adult_data, features, params) without return types