docstr: Summarises the background data to n_background_samples in order to reduce the computational cost.
  
  Returns
  -------
  If the `categorical_names` argument to the constructor is specified, then an object of the same type as
  input containing only `n_background_samples` is returned. Otherwise, a `shap_utils.Data` containing an
  `np.ndarray` object of `n_background_samples` in the `data` field is returned.
code: def _summarise_background(
      self,
      background_data: Union[pd.DataFrame, np.ndarray],
      n_background_samples: int,
  ) -> Union[np.ndarray, pd.DataFrame, shap_utils.DenseData]:
      """
      Summarises the background data to n_background_samples in order to reduce the computational cost.
  
      Returns
      -------
      If the `categorical_names` argument to the constructor is specified, then an object of the same type as
      input containing only `n_background_samples` is returned. Otherwise, a `shap_utils.Data` containing an
      `np.ndarray` object of `n_background_samples` in the `data` field is returned.
  
      """
  
      self.summarise_background = True
  
      if self.categorical_names:
          return shap.sample(
              background_data, nsamples=n_background_samples
          )
      else:
          return shap.kmeans(background_data, n_background_samples)
  
imports: import copy
  import logging
  from functools import partial
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  import pandas
  import shap
  import shap.utils._legacy
  from scipy import sparse
  from scipy.special import expit
  from shap import KernelExplainer
  from alibi.api.defaults import DEFAULT_DATA_KERNEL_SHAP, DEFAULT_DATA_TREE_SHAP, DEFAULT_META_KERNEL_SHAP, DEFAULT_META_TREE_SHAP
  from alibi.api.interfaces import Explainer, Explanation, FitMixin
  from alibi.utils.wrappers import methdispatch
label_desc: Use image node_id 5 for calling the TreeShap obj's underlying member method code with example usage: obj._summarise_background(background_data, n_background_samples) and returns: shap, shap