class_docstr: Uses Tree SHAP algorithms to explain the output of ensemble tree models.
  
  Tree SHAP is a fast and exact method to estimate SHAP values for tree models and ensembles of trees,
  under several different possible assumptions about feature dependence. It depends on fast C++
  implementations either inside an external model package or in the local compiled C extension.
class_docstr_tok: ["Uses","Tree","SHAP","algorithms","to","explain","the","output","of","ensemble","tree","models",".","Tree","SHAP","is","a","fast","and","exact","method","to","estimate","SHAP","values","for","tree","models","and","ensembles","of","trees",",","under","several","different","possible","assumptions","about","feature","dependence",".","It","depends","on","fast","C++","implementations","either","inside","an","external","model","package","or","in","the","local","compiled","C","extension","."]
code: def _validate_inputs(self, X, y, tree_limit, check_additivity):
      # see if we have a default tree_limit in place.
      if tree_limit is None:
          tree_limit = (
              -1
              if self.model.tree_limit is None
              else self.model.tree_limit
          )
  
      if tree_limit < 0 or tree_limit > self.model.values.shape[0]:
          tree_limit = self.model.values.shape[0]
      # convert dataframes
      if isinstance(X, (pd.Series, pd.DataFrame)):
          X = X.values
      flat_output = False
      if len(X.shape) == 1:
          flat_output = True
          X = X.reshape(1, X.shape[0])
      if X.dtype != self.model.input_dtype:
          X = X.astype(self.model.input_dtype)
      X_missing = np.isnan(X, dtype=bool)
      assert isinstance(X, np.ndarray), "Unknown instance type: " + str(
          type(X)
      )
      assert (
          len(X.shape) == 2
      ), "Passed input data matrix X must have 1 or 2 dimensions!"
  
      if self.model.model_output == "log_loss":
          if y is None:
              emsg = (
                  'Both samples and labels must be provided when model_output = "log_loss" '
                  "(i.e. `explainer.shap_values(X, y)`)!"
              )
              raise ExplainerError(emsg)
          if X.shape[0] != len(y):
              emsg = (
                  f"The number of labels ({len(y)}) does not match the number of samples "
                  f"to explain ({X.shape[0]})!"
              )
              raise DimensionError(emsg)
  
      if self.feature_perturbation == "tree_path_dependent":
          if not self.model.fully_defined_weighting:
              emsg = (
                  "The background dataset you provided does "
                  "not cover all the leaves in the model, "
                  "so TreeExplainer cannot run with the "
                  'feature_perturbation="tree_path_dependent" option! '
                  "Try providing a larger background "
                  "dataset, no background dataset, or using "
                  'feature_perturbation="interventional".'
              )
              raise ExplainerError(emsg)
  
      if check_additivity and self.model.model_type == "pyspark":
          warnings.warn(
              "check_additivity requires us to run predictions which is not supported with "
              "spark, "
              "ignoring."
              " Set check_additivity=False to remove this warning"
          )
          check_additivity = False
  
      return X, y, X_missing, flat_output, tree_limit, check_additivity
  
imports: import json
  import os
  import struct
  import time
  import warnings
  import numpy
  import pandas
  import scipy.sparse
  import scipy.special
  from packaging import version
  from ..None import maskers
  from .._explanation import Explanation
  from ..utils import assert_import, record_import_error, safe_isinstance
  from ..utils._exceptions import DimensionError, ExplainerError, InvalidFeaturePerturbationError, InvalidMaskerError, InvalidModelError
  from ..utils._legacy import DenseData
  from ._explainer import Explainer
label_desc: Use image node_id 4 for calling the TreeExplainer obj's underlying member method code with example usage: obj._validate_inputs(X, y, tree_limit, check_additivity) and returns: X,  y,  X_missing,  flat_output,  tree_limit,  check_additivity