docstr: Computes partial dependence for a feature or a tuple of features.
  
  Parameters
  ----------
  X, method, kind, percentiles, grid_resolution, grid_points
      See :py:meth:`alibi.explainers.partial_dependence.PartialDependenceBase.explain` method.
  features
      A feature or tuples of features for which to calculate the partial dependence.
  
  Returns
  -------
  A dictionary containing the feature(s) values, feature(s) deciles, average and/or individual values
  (i.e. partial dependence or individual conditional expectation) for the given (tuple of) feature(s))
docstr_tok: ["Computes","partial","dependence","for","a","feature","or","a","tuple","of","features",".","Parameters","--","--","--","--","--","X",",","method",",","kind",",","percentiles",",","grid_resolution",",","grid_points","See",":","py",":","meth",":","`","alibi.explainers.partial_dependence.PartialDependenceBase.explain","`","method",".","features","A","feature","or","tuples","of","features","for","which","to","calculate","the","partial","dependence",".","Returns","--","--","--","-","A","dictionary","containing","the","feature","(","s",")","values",",","feature","(","s",")","deciles",",","average","and\/or","individual","values","(","i.e",".","partial","dependence","or","individual","conditional","expectation",")","for","the","given","(","tuple","of",")","feature","(","s",")",")"]
code: def _partial_dependence(
      self,
      X: np.ndarray,
      features: Union[int, Tuple[int, int]],
      kind: Literal["average", "individual", "both"] = "average",
      percentiles: Tuple[float, float] = (0.05, 0.95),
      grid_resolution: int = 100,
      grid_points: Optional[Dict[int, Union[List, np.ndarray]]] = None,
  ) -> Dict[str, np.ndarray]:
      """
      Computes partial dependence for a feature or a tuple of features.
  
      Parameters
      ----------
      X, method, kind, percentiles, grid_resolution, grid_points
          See :py:meth:`alibi.explainers.partial_dependence.PartialDependenceBase.explain` method.
      features
          A feature or tuples of features for which to calculate the partial dependence.
  
      Returns
      -------
      A dictionary containing the feature(s) values, feature(s) deciles, average and/or individual values
      (i.e. partial dependence or individual conditional expectation) for the given (tuple of) feature(s))
      """
      if isinstance(features, numbers.Integral):
          features = (features,)
  
      if grid_points is None:
          grid_points = {}
  
      deciles, values, features_indices = (
          [],
          [],
          [],
      )
      for f in features:  # type: ignore[union-attr]
          # extract column. TODO _safe_indexing in the future to support more input types.
          X_f = X[:, f]
  
          # get deciles for the current feature if the feature is numerical
          deciles_f = (
              get_quantiles(X_f, num_quantiles=11)
              if self._is_numerical(f)
              else None
          )
  
          if f not in grid_points:
              # construct grid for feature `f`. Note that for categorical features we pass the
              # grid resolution to be infinity because otherwise we risk to apply `linspace` to
              # categorical values, which does not make sense.
              values_f = self._grid_from_X(
                  X=X_f.reshape(-1, 1),
                  percentiles=percentiles,
                  grid_resolution=grid_resolution if self._is_numerical(f) else np.inf,  # type: ignore[arg-type]
              )
          else:
              values_f = [grid_points[f]]
  
          features_indices.append(f)
          deciles.append(deciles_f)
          values += values_f
  
      # perform cartesian product between feature values. Covers also the case of a single feature.
      features_indices = np.array(features_indices, dtype=np.int32)  # type: ignore[assignment]
      grid = cartesian([v.reshape(-1) for v in values])
  
      # compute the PD and ICE - separate implementation for `PartialDependence` and `TreePartialDependence`
      averaged_predictions, predictions = self._compute_pd(
          grid=grid,
          features=features_indices,  # type: ignore[arg-type]
          X=X,
      )
  
      # reshape `averaged_predictions` to (n_outputs, n_values_feature_0, n_values_feature_1, ...)
      averaged_predictions = averaged_predictions.reshape(
          -1, *[val.shape[0] for val in values]
      )
  
      if predictions is not None:
          # reshape `predictions` to (n_outputs, n_instances, n_values_feature_0, n_values_feature_1, ...)
          predictions = predictions.reshape(
              -1, X.shape[0], *[val.shape[0] for val in values]
          )
  
      # define feature values (i.e. grid values) and the corresponding deciles. Note that the deciles
      # were computed on the raw (i.e. unprocessed) feature value as provided in the reference dataset `X`
      pd = {
          "values": values if len(values) > 1 else values[0],
          "deciles": deciles if len(deciles) > 1 else deciles[0],
      }
  
      if kind == Kind.AVERAGE:
          pd.update({"average": averaged_predictions})
      elif kind == Kind.INDIVIDUAL:
          pd.update({"individual": predictions})
      else:
          pd.update(
              {
                  "average": averaged_predictions,
                  "individual": predictions,
              }
          )
      return pd
  
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 5 for calling the PartialDependenceBase obj's underlying member method code with example usage: obj._partial_dependence(X, features, kind, percentiles, grid_resolution, grid_points) and returns: pd