code: def _load_model_config(cfg: dict) -> Callable:
      """
      Loads supported models from a model config dict.
  
      Parameters
      ----------
      cfg
          Model config dict. (see pydantic model schemas).
  
      Returns
      -------
      The loaded model.
      """
  
      # Load model
      flavour = cfg["flavour"]
      src = cfg["src"]
      custom_obj = cfg["custom_objects"]
      layer = cfg["layer"]
      src = Path(src)
      if not src.is_dir():
          raise FileNotFoundError(
              "The `src` field is not a recognised directory. It should be a directory containing "
              "a compatible model."
          )
  
      if flavour == Framework.TENSORFLOW:
          model = load_model_tf(
              src, custom_objects=custom_obj, layer=layer
          )
      elif flavour == Framework.PYTORCH:
          model = load_model_pt(src, layer=layer)
      elif flavour == Framework.SKLEARN:
          model = load_model_sk(src)
  
      return model
  
imports: import logging
  import os
  from functools import partial
  from importlib import import_module
  from pathlib import Path
  from typing import Any, Callable, Optional, Union, Type, TYPE_CHECKING
  import dill
  import numpy
  import toml
  from transformers import AutoTokenizer
  from alibi_detect.saving.registry import registry
  from alibi_detect.saving._tensorflow import load_detector_legacy, load_embedding_tf, load_kernel_config_tf, load_model_tf, load_optimizer_tf, prep_model_and_emb_tf, get_tf_dtype
  from alibi_detect.saving._pytorch import load_embedding_pt, load_kernel_config_pt, load_model_pt, load_optimizer_pt, prep_model_and_emb_pt, get_pt_dtype
  from alibi_detect.saving._keops import load_kernel_config_ke
  from alibi_detect.saving._sklearn import load_model_sk
  from alibi_detect.saving.validate import validate_config
  from alibi_detect.base import Detector, ConfigurableDetector, StatefulDetectorOnline
  from alibi_detect.utils.frameworks import has_tensorflow, has_pytorch, Framework
  from alibi_detect.saving.schemas import supported_models_tf, supported_models_torch
  from alibi_detect.utils.missing_optional_dependency import import_optional
label_desc: Use image node_id 6 for calling a global function with example usage: _load_model_config(cfg) and returns: model