class_docstr: A wrapper around `shap.KernelExplainer` that supports:
  
      - fixing the seed when instantiating the KernelExplainer in a separate process.
  
      - passing a batch index to the explainer so that a parallel explainer pool can return batches in         arbitrary order.
class_docstr_tok: ["A","wrapper","around","`","shap.KernelExplainer","`","that","supports",":","-","fixing","the","seed","when","instantiating","the","KernelExplainer","in","a","separate","process",".","-","passing","a","batch","index","to","the","explainer","so","that","a","parallel","explainer","pool","can","return","batches","in","arbitrary","order","."]
docstr: Wrapper around `shap.KernelExplainer.shap_values` that allows calling the method with a tuple containing a
  batch index and a batch of instances.
  
  Parameters
  ----------
  X
      When called from a distributed context, it is a tuple containing a batch index and a batch to be explained.
      Otherwise, it is an array of instances to be explained.
  **kwargs
      `shap.KernelExplainer.shap_values` kwarg values.
code: def get_explanation(
      self, X: Union[Tuple[int, np.ndarray], np.ndarray], **kwargs
  ) -> Union[
      Tuple[int, np.ndarray],
      Tuple[int, List[np.ndarray]],
      np.ndarray,
      List[np.ndarray],
  ]:
      """
      Wrapper around `shap.KernelExplainer.shap_values` that allows calling the method with a tuple containing a
      batch index and a batch of instances.
  
      Parameters
      ----------
      X
          When called from a distributed context, it is a tuple containing a batch index and a batch to be explained.
          Otherwise, it is an array of instances to be explained.
      **kwargs
          `shap.KernelExplainer.shap_values` kwarg values.
      """
  
      # handle call from distributed context
      if isinstance(X, tuple):
          batch_idx, batch = X
          shap_values = super().shap_values(batch, **kwargs)
          return batch_idx, shap_values
      else:
          shap_values = super().shap_values(X, **kwargs)
          return shap_values
  
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 2 for calling the KernelExplainerWrapper obj's underlying member method code with example usage: obj.get_explanation(X) and returns: batch_idx,  shap_values, shap_values