code: def shap_values(self, X, **kwargs):
          
  
          phi = None
          if self.mimic_model_type == "xgboost":
              if not str(type(X)).endswith("xgboost.core.DMatrix'>"):
                  X = xgboost.DMatrix(X)
              phi = self.trees.predict(X, pred_contribs=True)
  
          if phi is not None:
              if len(phi.shape) == 3:
                  return [phi[:, i, :] for i in range(phi.shape[1])]
              else:
                  return phi
docs: Estimate the SHAP values for a set of samples.
  
          Parameters
          ----------
          X : numpy.array or pandas.DataFrame
              A matrix of samples (# samples x # features) on which to explain the model's output.
  
          Returns
          -------
          For a models with a single output this returns a matrix of SHAP values
          (# samples x # features + 1). The last column is the base value of the model, which is
          the expected value of the model applied to the background dataset. This causes each row to
          sum to the model output for that sample. For models with vector outputs this returns a list
          of such matrices, one for each output.