code: def test_interaction_num_cat(
      rf_classifier, pd_pdv_explainers, features, adult_data
  ):
      """Test the computation of the feature interaction for a numerical and a categorical feature."""
      X_train = adult_data["X_train"][:100]
      category_map = adult_data["metadata"]["category_map"]
      pd_explainer, pdv_explainer = pd_pdv_explainers
  
      # compute feature interaction using the `PartialDependenceVariance` explainer
      pdv_exp = pdv_explainer.explain(
          X=X_train,
          method="interaction",
          features=features,
          grid_resolution=20,
      )
      pdv_ft_inter = pdv_exp.data["feature_interaction"][0]
  
      # compute manually the feature interaction using the `PartialDependence` explainer
      pd_exp = pd_explainer.explain(
          X=X_train, features=features, grid_resolution=20
      )
      pd_ft_inter = []
  
      for fts, pd_vals in zip(features, pd_exp.data["pd_values"]):
          first_ft, second_ft = fts
  
          if second_ft in category_map:
              cond_imp1 = (
                  np.max(pd_vals[0], axis=-1)
                  - np.min(pd_vals[0], axis=-1)
              ) / 4
              imp1 = np.std(cond_imp1, ddof=1, axis=-1)
  
              cond_imp2 = np.std(pd_vals[0].T, ddof=1, axis=-1)
              imp2 = (
                  np.max(cond_imp2, axis=-1)
                  - np.min(cond_imp2, axis=-1)
              ) / 4
  
              pd_ft_inter.append(np.mean([imp1, imp2]))
          else:
              cond_imp1 = np.std(pd_vals[0], ddof=1, axis=-1)
              imp1 = (
                  np.max(cond_imp1, axis=-1)
                  - np.min(cond_imp1, axis=-1)
              ) / 4
  
              cond_imp2 = (
                  np.max(pd_vals[0].T, axis=-1)
                  - np.min(pd_vals[0].T, axis=-1)
              ) / 4
              imp2 = np.std(cond_imp2, ddof=1, axis=-1)
  
              pd_ft_inter.append(np.mean([imp1, imp2]))
  
      pd_ft_inter = np.array(pd_ft_inter)
      np.testing.assert_allclose(pdv_ft_inter, pd_ft_inter)
  
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 14 for calling a global function with example usage: test_interaction_num_cat(rf_classifier, pd_pdv_explainers, features, adult_data) without return types