code: def test_fit_kernel(
      caplog,
      monkeypatch,
      mock_kernel_shap_explainer,
      data_type,
      summarise_background,
      data_dimension,
      group_settings,
      input_settings,
  ):
      """
      This is an integration test where we check that the _check_inputs, _get_data and _summarise_background
      methods work well together.
      """
  
      caplog.set_level(logging.INFO)
  
      # generate grouping inputs for testing (b_ = bool var)
      b_group_names, b_groups, b_weights = group_settings
      n_samples, n_features = data_dimension
      n_background_examples = n_samples - 10
      group_names, groups, weights, data = generate_test_data(
          data_dimension,
          *group_settings,
          correct=True,
          data_type=data_type,
      )
  
      # modify the number of weights so that defaults are set automatically
      if not input_settings["correct"]:
          weights = weights[:-3]
      # ensure we pass the right number of weights otherwise
      else:
          if b_weights:
              if summarise_background == "auto":
                  weights = weights[:KERNEL_SHAP_BACKGROUND_THRESHOLD]
              elif summarise_background:
                  weights = weights[:n_background_examples]
  
      explainer = mock_kernel_shap_explainer
      # replace kmeans with a mock object so we don't run actual kmeans a zillion times
      monkeypatch.setattr(shap, "kmeans", KMeansMock())
      # check weights are not set
      explainer.fit(
          data,
          summarise_background=summarise_background,
          n_background_samples=n_background_examples,
          group_names=group_names,
          groups=groups,
          weights=weights,
      )
      records = caplog.records
      explainer = mock_kernel_shap_explainer
  
      n_outs = explainer.predictor.out_dim
      if n_outs == 1:
          msg = "Predictor returned a scalar value"
          assert_message_in_logs(msg, records)
  
      if not input_settings["correct"]:
          # this only tests the case where the data is summarise
          if data_type not in ["data", "series"]:
              assert explainer.ignore_weights
  
          # uniform weights should be set by default
          if explainer.use_groups:
              assert (
                  len(np.unique(explainer.background_data.weights)) == 1
              )
          else:
              if data_type != "sparse":
                  assert len(explainer.background_data.weights) != len(
                      weights
                  )
  
      else:
          if summarise_background or isinstance(
              summarise_background, str
          ):
              if data_type == "data" or data_type == "series":
                  msg_end = "No summarisation will take place!"
                  assert_message_in_logs(msg_end, records)
              else:
                  if explainer.use_groups:
                      background_data = explainer.background_data
                      assert isinstance(
                          background_data, shap_utils.Data
                      )
  
                      # check properties of background data are correct
                      if b_group_names:
                          background_data.group_names == group_names
                      if b_groups:
                          assert background_data.groups == groups
                      if b_groups and not b_group_names:
                          if data_type not in ["frame", "series"]:
                              assert (
                                  "group"
                                  in background_data.group_names[0]
                              )
                          else:
                              assert (
                                  "feature"
                                  in background_data.group_names[0]
                              )
                      if b_weights:
                          assert (
                              len(np.unique(background_data.weights))
                              != 1
                          )
  
                      background_data = background_data.data
                  else:
                      if data_type == "sparse":
                          background_data = explainer.background_data
                          assert isinstance(background_data, type(data))
                      else:
                          assert isinstance(
                              explainer.background_data, shap_utils.Data
                          )
                          background_data = (
                              explainer.background_data.data
                          )
  
                  # check dimensions are reduced
                  if isinstance(summarise_background, str):
                      if n_samples > KERNEL_SHAP_BACKGROUND_THRESHOLD:
                          assert (
                              background_data.shape[0]
                              == KERNEL_SHAP_BACKGROUND_THRESHOLD
                          )
                      else:
                          assert (
                              background_data.shape[0] == data.shape[0]
                          )
                  elif summarise_background:
                      assert (
                          background_data.shape[0]
                          == n_background_examples
                      )
          else:
              background_data = explainer.background_data
              if not explainer.use_groups and data_type != "data":
                  assert background_data.shape == data.shape
              else:
                  assert isinstance(background_data, shap_utils.Data)
                  if b_groups and not b_group_names:
                      # use columns/index for feat names for frame/series
                      # we don't check shap.commmon.Data objects
                      if data_type not in ["frame", "series", "data"]:
                          assert (
                              "group" in background_data.group_names[0]
                          )
                      else:
                          assert (
                              "feature"
                              in background_data.group_names[0]
                          )
  
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 18 for calling a global function with example usage: test_fit_kernel(caplog, monkeypatch, mock_kernel_shap_explainer, data_type, summarise_background, data_dimension, group_settings, input_settings) without return types