docstr: Grid points sanity checks.
  
  Parameters
  ----------
  grid_points
      See :py:meth:`alibi.explainers.partial_dependence.PartialDependenceBase.explain`.
  n_features
      Number of features in the dataset.
docstr_tok: ["Grid","points","sanity","checks",".","Parameters","--","--","--","--","--","grid_points","See",":","py",":","meth",":","`","alibi.explainers.partial_dependence.PartialDependenceBase.explain","`",".","n_features","Number","of","features","in","the","dataset","."]
code: def _grid_points_sanity_checks(
      self,
      grid_points: Optional[Dict[int, Union[List, np.ndarray]]],
      n_features: int,
  ):
      """
      Grid points sanity checks.
  
      Parameters
      ----------
      grid_points
          See :py:meth:`alibi.explainers.partial_dependence.PartialDependenceBase.explain`.
      n_features
          Number of features in the dataset.
      """
      if grid_points is None:
          return
  
      if not np.all(
          np.isin(list(grid_points.keys()), np.arange(n_features))
      ):
          raise ValueError(
              "The features provided in `grid_points` are not a subset of the dataset features."
          )
  
      for f in grid_points:
          if self._is_numerical(f):
              grid_points[f] = np.sort(
                  grid_points[f]
              )  # from this point onward, `grid_points[f]` is `np.ndarray`
  
          else:
              grid_points[f] = np.unique(
                  grid_points[f]
              )  # from this point onward, `grid_points[f]` is `np.ndarray`
              message = (
                  "The grid points provided for the categorical feature {} are invalid. "
                  "For categorical features, the grid points must be a subset of the features "
                  "values defined in `categorical_names`. Received an unknown value of '{}'."
              )
  
              # convert to label encoding if the grid is provided as strings
              if grid_points[f].dtype.type is np.str_:  # type: ignore[union-attr]
                  int_values = []
  
                  for str_val in grid_points[f]:
                      try:
                          # `self.categorical_names` cannot be empty because of the check in `self._is_numerical`
                          index = self.categorical_names[f].index(str_val)  # type: ignore[index]
                      except ValueError:
                          raise ValueError(message.format(f, str_val))
                      int_values.append(index)
                  grid_points[f] = np.array(int_values)
  
              # `self.categorical_names` cannot be empty because of the check in `self._is numerical`
              mask = np.isin(grid_points[f], np.arange(len(self.categorical_names[f])))  # type: ignore[index]
              if not np.all(mask):
                  index = np.where(not mask)[0][0]
                  raise ValueError(
                      message.format(f, grid_points[f][index])
                  )
  
imports: import copy
  import logging
  import math
  import numbers
  import sys
  from abc import ABC, abstractmethod
  from enum import Enum
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union, no_type_check
  import matplotlib.pyplot
  import numpy
  from scipy.stats.mstats import mquantiles
  from sklearn.base import BaseEstimator, is_classifier, is_regressor
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.ensemble._gb import BaseGradientBoosting
  from sklearn.ensemble._hist_gradient_boosting.gradient_boosting import BaseHistGradientBoosting
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.utils.extmath import cartesian
  from sklearn.utils.validation import check_is_fitted
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_PD, DEFAULT_META_PD
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.explainers.ale import get_quantiles
  from alibi.utils import _get_options_string
label_desc: Use image node_id 3 for calling the PartialDependenceBase obj's underlying member method code with example usage: obj._grid_points_sanity_checks(grid_points, n_features) without return types