code: def save_model_config(
      model: Callable,
      base_path: Path,
      input_shape: Optional[tuple],
      local_path: Path = Path("."),
  ) -> Tuple[dict, Optional[dict]]:
      """
      Save a TensorFlow model to a config dictionary. When a model has a text embedding model contained within it,
      this is extracted and saved separately.
  
      Parameters
      ----------
      model
          The model to save.
      base_path
          Base filepath to save to (the location of the `config.toml` file).
      input_shape
          The input dimensions of the model (after the optional embedding has been applied).
      local_path
          A local (relative) filepath to append to base_path.
  
      Returns
      -------
      A tuple containing the model and embedding config dicts.
      """
      cfg_model: Optional[Dict[str, Any]] = None
      cfg_embed: Optional[Dict[str, Any]] = None
      if isinstance(model, UAE):
          if isinstance(
              model.encoder.layers[0], TransformerEmbedding
          ):  # if UAE contains embedding and encoder
              if input_shape is None:
                  raise ValueError(
                      "Cannot save combined embedding and model when `input_shape` is None."
                  )
  
              # embedding
              embed = model.encoder.layers[0]
              cfg_embed = save_embedding_config(
                  embed, base_path, local_path.joinpath("embedding")
              )
              # preprocessing encoder
              inputs = Input(shape=input_shape, dtype=tf.int64)
              model.encoder.call(inputs)
              shape_enc = (model.encoder.layers[0].output.shape[-1],)
              layers = [
                  InputLayer(input_shape=shape_enc)
              ] + model.encoder.layers[1:]
              model = tf.keras.Sequential(layers)
              _ = model(tf.zeros((1,) + shape_enc))
          else:  # If UAE is simply an encoder
              model = model.encoder
      elif isinstance(model, TransformerEmbedding):
          cfg_embed = save_embedding_config(
              model, base_path, local_path.joinpath("embedding")
          )
          model = None
      elif isinstance(model, HiddenOutput):
          model = model.model
      elif isinstance(
          model, tf.keras.Model
      ):  # Last as TransformerEmbedding and UAE are tf.keras.Model's
          model = model
      else:
          raise ValueError("Model not recognised, cannot save.")
  
      if model is not None:
          filepath = base_path.joinpath(local_path)
          save_model(model, filepath=filepath.joinpath("model"))
          cfg_model = {
              "flavour": Framework.TENSORFLOW.value,
              "src": local_path.joinpath("model"),
          }
      return cfg_model, cfg_embed
  
imports: import logging
  import os
  from functools import partial
  from pathlib import Path
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import dill
  import tensorflow
  from tensorflow.keras.layers import Input, InputLayer
  from alibi_detect.ad import AdversarialAE, ModelDistillation
  from alibi_detect.cd import ChiSquareDrift, ClassifierDrift, KSDrift, MMDDrift, TabularDrift
  from alibi_detect.cd.tensorflow import UAE, HiddenOutput
  from alibi_detect.cd.tensorflow.classifier import ClassifierDriftTF
  from alibi_detect.cd.tensorflow.mmd import MMDDriftTF
  from alibi_detect.models.tensorflow import TransformerEmbedding
  from alibi_detect.od import LLR, IForest, Mahalanobis, OutlierAE, OutlierAEGMM, OutlierProphet, OutlierSeq2Seq, OutlierVAE, OutlierVAEGMM, SpectralResidual
  from alibi_detect.utils._types import Literal
  from alibi_detect.utils.tensorflow.kernels import GaussianRBF
  from alibi_detect.utils.missing_optional_dependency import MissingDependency
  from alibi_detect.utils.frameworks import Framework
label_desc: Use image node_id 1 for calling a global function with example usage: save_model_config(model, base_path, input_shape, local_path) and returns: cfg_model,  cfg_embed