code: def test_importance_cat(
      rf_classifier, pd_pdv_explainers, features, adult_data
  ):
      """Test the computation of the feature importance for a categorical feature."""
      X_train = adult_data["X_train"][:100]
      pd_explainer, pdv_explainer = pd_pdv_explainers
  
      # compute feature importance using the `PartialDependenceVariance` explainer
      pdv_exp = pdv_explainer.explain(X=X_train, features=features)
      pdv_ft_imp = pdv_exp.data["feature_importance"][0]
  
      # compute manually the feature importance using the `PartialDependence` explainer
      pd_exp = pd_explainer.explain(X=X_train, features=features)
      pd_ft_imp = np.array(
          [
              (np.max(pd[0], axis=-1) - np.min(pd[0], axis=-1)) / 4
              for pd in pd_exp.data["pd_values"]
          ]
      )
      np.testing.assert_allclose(pdv_ft_imp, pd_ft_imp)
  
imports: import re
  from copy import deepcopy
  import matplotlib.pyplot
  import numpy
  import pandas
  import pytest
  from pytest_lazyfixture import lazy_fixture
  from sklearn.ensemble import GradientBoostingRegressor
  from sklearn.linear_model import LinearRegression
  from alibi.api.defaults import DEFAULT_DATA_PDVARIANCE, DEFAULT_META_PDVARIANCE
  from alibi.api.interfaces import Explanation
  from alibi.explainers import PartialDependence, PartialDependenceVariance, TreePartialDependence
  from alibi.explainers.pd_variance import _plot_feature_importance, _plot_feature_interaction, _plot_hbar, plot_pd_variance
label_desc: Use image node_id 11 for calling a global function with example usage: test_importance_cat(rf_classifier, pd_pdv_explainers, features, adult_data) without return types