code: def test_fit_tree(
      caplog,
      monkeypatch,
      mock_tree_shap_explainer,
      data_type,
      summarise_background,
      data_dimension,
  ):
      """
      Test fit method.
      """
  
      caplog.set_level(logging.WARNING)
      # don't test shap kmeans function
      monkeypatch.setattr(shap, "kmeans", KMeansMock())
      explainer = mock_tree_shap_explainer
      n_outs = explainer.predictor.out_dim
      n_instances = data_dimension[0]
      background_data = get_data(
          kind=data_type, n_rows=n_instances, n_cols=data_dimension[1]
      )
      n_background_samples = n_instances - np.random.randint(
          0, max(1, n_instances - 10)
      )
      records = caplog.records
  
      explainer.fit(
          background_data,
          summarise_background=summarise_background,
          n_background_samples=n_background_samples,
      )
  
      # check object properties are set
      assert explainer._explainer
      assert explainer._fitted
      assert explainer.expected_value
  
      # check features are set
      if data_type == "frame":
          assert isinstance(explainer.feature_names, list)
          assert (
              explainer.feature_names
              == background_data.columns.values.tolist()
          )
      else:
          assert not explainer.feature_names
  
      # check summarisation called properly
      if not summarise_background:
          assert not explainer.summarise_background
          assert not explainer.meta["params"]["summarise_background"]
  
          if data_type != "none":
              if n_instances > TREE_SHAP_BACKGROUND_WARNING_THRESHOLD:
                  assert_message_in_logs("slow", records)
      else:
          if data_type == "none":
              assert not explainer.summarise_background
              assert not explainer.meta["params"][
                  "summarise_background"
              ]
  
          else:
              if isinstance(summarise_background, str):
                  if (
                      n_instances
                      > TREE_SHAP_BACKGROUND_WARNING_THRESHOLD
                  ):
                      assert (
                          explainer.background_data.data.shape[0]
                          == TREE_SHAP_BACKGROUND_WARNING_THRESHOLD
                      )
                      assert explainer.meta["params"][
                          "summarise_background"
                      ]
                  else:
                      assert not explainer.summarise_background
                      assert not explainer.meta["params"][
                          "summarise_background"
                      ]
                      assert (
                          explainer.background_data is background_data
                      )
              else:
                  if n_instances > n_background_samples:
                      assert (
                          explainer.background_data.data.shape[0]
                          == n_background_samples
                      )
                      assert explainer.meta["params"][
                          "summarise_background"
                      ]
  
                  else:
                      assert not explainer.summarise_background
                      assert not explainer.meta["params"][
                          "summarise_background"
                      ]
                      assert (
                          explainer.background_data is background_data
                      )
  
      # scalar warnings are raised
      if n_outs == 1:
          assert_message_in_logs("scalar", records)
  
imports: import itertools
  import logging
  import unittest
  from copy import copy
  from itertools import chain
  from unittest.mock import MagicMock
  from typing import Any, List
  import catboost
  import pandas
  import pytest
  import scipy.sparse
  import sklearn
  import shap
  import numpy
  import pandas
  import shap.utils._legacy
  from numpy.testing import assert_allclose, assert_almost_equal
  from scipy.special import expit
  from alibi.api.defaults import DEFAULT_META_KERNEL_SHAP, DEFAULT_DATA_KERNEL_SHAP, DEFAULT_META_TREE_SHAP, DEFAULT_DATA_TREE_SHAP, KERNEL_SHAP_PARAMS, TREE_SHAP_PARAMS
  from alibi.explainers.shap_wrappers import sum_categories, rank_by_importance, KernelExplainerWrapper
  from alibi.explainers.shap_wrappers import KERNEL_SHAP_BACKGROUND_THRESHOLD, TREE_SHAP_BACKGROUND_WARNING_THRESHOLD
  from alibi.explainers.tests.utils import get_random_matrix
  from alibi.tests.utils import assert_message_in_logs, not_raises
  from alibi.utils import DistributedExplainer
label_desc: Use image node_id 25 for calling a global function with example usage: test_fit_tree(caplog, monkeypatch, mock_tree_shap_explainer, data_type, summarise_background, data_dimension) without return types