code: def test_grid_points_error(adult_data, use_int):
      """Checks if the `_grid_points_sanity_checks` throw an error when the `grid_points` for a categorical feature
      are not a subset of the feature values provided in `categorical_names`.
      """
      feature_names = adult_data["metadata"]["feature_names"]
      categorical_names = adult_data["metadata"]["category_map"]
      X_train = adult_data["X_train"]
  
      # construct random `grid_points` by choosing random values between min and max for each numerical feature,
      # and sampling at random from the categorical names for each categorical feature.
      grid_points = {}
      for i in range(len(feature_names)):
          if i in categorical_names:
              size = np.random.randint(
                  low=1, high=len(categorical_names[i])
              )
              categorical_values = (
                  np.arange(len(categorical_names[i]))
                  if use_int
                  else categorical_names[i]
              )
              grid_points[i] = np.random.choice(
                  categorical_values, size=size, replace=False
              )
  
              # append a wrong value
              grid_points[i] = np.append(
                  grid_points[i],
                  len(categorical_values) if use_int else "[UNK]",
              )
  
      # define explainer
      explainer = PartialDependence(
          predictor=lambda x: np.zeros(x.shape[0]),
          feature_names=feature_names,
          categorical_names=categorical_names,
      )
  
      # compute explanation for every feature using the `grid_points`
      with pytest.raises(ValueError):
          explainer._grid_points_sanity_checks(
              grid_points, n_features=X_train.shape[1]
          )
  
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 12 for calling a global function with example usage: test_grid_points_error(adult_data, use_int) without return types