code: def _save_kernel_config(
      kernel: Callable, base_path: Path, local_path: Path = Path(".")
  ) -> dict:
      """Function to save kernel.
  
      If the kernel is stored in the artefact registry, the registry key (and kwargs) are written
      to config. If the kernel is a generic callable, it is pickled.
  
      Parameters
      ----------
      kernel
          The kernel to save.
      base_path
          Base directory to save in.
      local_path
          A local (relative) filepath to append to base_path.
  
      Returns
      -------
      The kernel config dictionary.
      """
      # if a DeepKernel
      if hasattr(kernel, "proj"):
          if hasattr(kernel, "get_config"):
              cfg_kernel = kernel.get_config()
          else:
              raise AttributeError(
                  "The detector's `kernel` must have a .get_config() method for it to be saved."
              )
          # Serialize the kernels (if needed)
          kernel_a = cfg_kernel.get("kernel_a")
          kernel_b = cfg_kernel.get("kernel_b")
          if not isinstance(kernel_a, str):
              cfg_kernel["kernel_a"] = _save_kernel_config(
                  cfg_kernel["kernel_a"], base_path, Path("kernel_a")
              )
          if not isinstance(kernel_b, str) and kernel_b is not None:
              cfg_kernel["kernel_b"] = _save_kernel_config(
                  cfg_kernel["kernel_b"], base_path, Path("kernel_b")
              )
  
      # If any other kernel, serialize the class to disk and get config
      else:
          if isinstance(kernel, type):  # if still a class
              kernel_class = kernel
              cfg_kernel = {}
          else:  # if an object
              kernel_class = kernel.__class__
              if hasattr(kernel, "get_config"):
                  cfg_kernel = kernel.get_config()
                  cfg_kernel["init_sigma_fn"], _ = _serialize_object(
                      cfg_kernel["init_sigma_fn"],
                      base_path,
                      local_path.joinpath("init_sigma_fn"),
                  )
              else:
                  raise AttributeError(
                      "The detector's `kernel` must have a .get_config() method for it to be saved."
                  )
          # Serialize the kernel class
          cfg_kernel["src"], _ = _serialize_object(
              kernel_class, base_path, local_path.joinpath("kernel")
          )
  
      return cfg_kernel
  
imports: import logging
  import os
  import shutil
  import warnings
  from functools import partial
  from pathlib import Path
  from typing import Callable, Optional, Tuple, Union, Any, Dict, TYPE_CHECKING
  import dill
  import numpy
  import toml
  from transformers import PreTrainedTokenizerBase
  from alibi_detect.saving._typing import VALID_DETECTORS
  from alibi_detect.saving.loading import _replace, validate_config, STATE_PATH
  from alibi_detect.saving.registry import registry
  from alibi_detect.utils._types import supported_models_all, supported_models_tf, supported_models_torch, supported_models_sklearn
  from alibi_detect.base import Detector, ConfigurableDetector, StatefulDetectorOnline
  from alibi_detect.saving._tensorflow import save_detector_legacy, save_model_config_tf, save_optimizer_config_tf
  from alibi_detect.saving._pytorch import save_model_config_pt, save_device_pt
  from alibi_detect.saving._sklearn import save_model_config_sk
label_desc: Use image node_id 11 for calling a global function with example usage: _save_kernel_config(kernel, base_path, local_path) and returns: cfg_kernel