code: def save_model_config(
      model: Callable, base_path: Path, local_path: Path = Path(".")
  ) -> Tuple[dict, Optional[dict]]:
      """
      Save a PyTorch 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).
      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):
          layers = list(model.encoder.children())
          if isinstance(
              layers[0], TransformerEmbedding
          ):  # if UAE contains embedding and encoder
              # embedding
              embed = layers[0]
              cfg_embed = save_embedding_config(
                  embed, base_path, local_path.joinpath("embedding")
              )
              # preprocessing encoder
              model = layers[1]
          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, nn.Module
      ):  # Last as TransformerEmbedding and UAE are nn.Module'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)
          cfg_model = {
              "flavour": Framework.PYTORCH.value,
              "src": local_path.joinpath("model"),
          }
      return cfg_model, cfg_embed
  
file_path: alibi-detect/alibi_detect/saving/_pytorch/saving.py
imports: import os
  import logging
  from pathlib import Path
  from typing import Any, Callable, Dict, Optional, Tuple, Union
  import dill
  import torch
  import torch.nn
  from alibi_detect.cd.pytorch import UAE, HiddenOutput
  from alibi_detect.models.pytorch import TransformerEmbedding
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 for calling a global function with example usage: save_model_config(model, base_path, local_path) and returns: cfg_model,  cfg_embed