code: def _serialize_object(
      obj: Callable, base_path: Path, local_path: Path = Path(".")
  ) -> Tuple[str, dict]:
      """
      Serializes a python object. If the object is in the object registry, the registry str is returned. If not,
      the object is saved to dill, and if wrapped in a functools.partial, the kwargs are returned.
  
      Parameters
      ----------
      obj
          The object to serialize.
      base_path
          Base directory to save in.
      local_path
          A local (relative) filepath to append to base_path.
  
      Returns
      -------
      Tuple containing a string referencing the save filepath and a dict of kwargs.
      """
      # If a functools.partial, unpick function and kwargs
      if isinstance(obj, partial):
          kwargs = obj.keywords
          obj = obj.func
      else:
          kwargs = {}
  
      # If object has been registered, save registry string
      keys = [k for k, v in registry.get_all().items() if obj == v]
      registry_str = keys[0] if len(keys) == 1 else None
      if registry_str is not None:  # alibi-detect registered object
          src = "@" + registry_str
  
      # Otherwise, save as dill
      else:
          # create folder to save object in
          filepath = base_path.joinpath(local_path)
          if not filepath.parent.is_dir():
              logger.warning(
                  "Directory {} does not exist and is now created.".format(
                      filepath.parent
                  )
              )
              filepath.parent.mkdir(parents=True, exist_ok=True)
          logger.info(
              "Saving object to {}.".format(
                  filepath.with_suffix(".dill")
              )
          )
          with open(filepath.with_suffix(".dill"), "wb") as f:
              dill.dump(obj, f)
          src = str(local_path.with_suffix(".dill"))
  
      return src, kwargs
  
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 6 for calling a global function with example usage: _serialize_object(obj, base_path, local_path) and returns: src,  kwargs