code: def test__get_data(
      mock_kernel_shap_explainer,
      data_dimension,
      data_type,
      group_settings,
      input_settings,
  ):
      """
      Tests the _get_data method of the wrapper.
      """
  
      # generate fake inputs for testing (b_ = bool var)
      b_group_names, b_groups, b_weights = group_settings
      use_groups = b_group_names or b_groups
      group_names, groups, weights, data = generate_test_data(
          data_dimension,
          *group_settings,
          **input_settings,
          data_type=data_type,
      )
      # the algorithm would take this step in fit before calling _get_data
      if not b_group_names and b_groups:
          group_names = [
              "group_{}".format(i) for i in range(len(groups))
          ]
  
      # initialise a KernelShap with a mock predictor
      explainer = mock_kernel_shap_explainer
      explainer.use_groups = use_groups
      explainer.summarise_background = False
  
      if data_type == "int":
          with pytest.raises(TypeError) as exc_info:
              background_data = explainer._get_data(
                  data, group_names, groups, weights
              )
              assert not background_data
              assert exc_info.type is TypeError
      else:
          background_data = explainer._get_data(
              data, group_names, groups, weights
          )
  
          # test behaviour when input is a shap_utils.DenseData object
          if data_type == "data":
              assert isinstance(background_data, shap_utils.Data)
              assert background_data.group_names is not None
              if weights is not None:
                  assert len(np.unique(background_data.weights)) == 1
  
          # test behaviour when provided data is numpy array
          if data_type == "array":
              if use_groups:
                  assert_almost_equal(
                      background_data.weights.sum(), 1.0
                  )
                  assert_groups(background_data, group_names, groups)
              else:
                  assert isinstance(background_data, np.ndarray)
  
          # test behaviour when provided data is sparse array
          if data_type == "sparse":
              if use_groups:
                  assert_allclose(background_data.data, data.toarray())
                  assert_groups(background_data, group_names, groups)
              else:
                  assert isinstance(
                      background_data, scipy.sparse.spmatrix
                  )
  
          # test behaviour when provided data is a pandas DataFrame
          if data_type == "frame":
              if use_groups:
                  expected_groups = data.columns
                  assert_groups(
                      background_data, expected_groups, groups
                  )
              else:
                  assert isinstance(background_data, pd.DataFrame)
  
          # test behaviour when provided data is a pandas Series
          if data_type == "series":
              if use_groups:
                  expected_groups = data.index
                  assert_groups(
                      background_data, expected_groups, groups
                  )
              else:
                  assert isinstance(background_data, pd.Series)
  
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 13 for calling a global function with example usage: test__get_data(mock_kernel_shap_explainer, data_dimension, data_type, group_settings, input_settings) without return types