code: def test__summarise_background_tree(
      mock_tree_shap_explainer,
      data_dimension,
      data_type,
      categorical_names,
  ):
      """
      Test background data summarisation.
      """
  
      explainer = mock_tree_shap_explainer
      n_instances = data_dimension[0]
      background_data = get_data(
          kind=data_type, n_rows=n_instances, n_cols=data_dimension[1]
      )
      explainer.categorical_names = categorical_names
      n_background_samples = max(1, n_instances - 15)
  
      summary_data = explainer._summarise_background(
          background_data, n_background_samples
      )
      assert explainer.summarise_background
      if n_background_samples > n_instances:
          if categorical_names:
              assert type(background_data) == type(
                  summary_data
              )  # noqa: E721
          else:
              assert isinstance(summary_data, shap_utils.Data)
              assert summary_data.data.shape == background_data.shape
      else:
          if categorical_names:
              assert summary_data.shape[0] == n_background_samples
              assert type(background_data) == type(
                  summary_data
              )  # noqa: E721
          else:
              assert summary_data.data.shape[0] == n_background_samples
              assert isinstance(summary_data, shap_utils.Data)
  
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 24 for calling a global function with example usage: test__summarise_background_tree(mock_tree_shap_explainer, data_dimension, data_type, categorical_names) without return types