code: def load_optimizer(
      cfg: dict,
  ) -> Union[
      Type["tf.keras.optimizers.Optimizer"],
      "tf.keras.optimizers.Optimizer",
  ]:
      """
      Loads a TensorFlow optimzier from a optimizer config dict.
  
      Parameters
      ----------
      cfg
          The optimizer config dict.
  
      Returns
      -------
      The loaded optimizer, either as an instantiated object (if `cfg` is a tensorflow optimizer config dict), otherwise \
      as an uninstantiated class.
      """
      class_name = cfg.get("class_name")
      tf_config = cfg.get("config")
      if tf_config is not None:  # cfg is a tensorflow config dict
          return tf.keras.optimizers.deserialize(cfg)
      else:
          try:
              return getattr(
                  import_module("tensorflow.keras.optimizers"),
                  class_name,
              )
          except AttributeError:
              raise ValueError(
                  f"{class_name} is not a recognised optimizer in `tensorflow.keras.optimizers`."
              )
  
imports: import logging
  import os
  from importlib import import_module
  import warnings
  from functools import partial
  from pathlib import Path
  from typing import Callable, Dict, List, Optional, Tuple, Union, Type
  import dill
  import tensorflow
  from tensorflow_probability.python.distributions.distribution import Distribution
  from transformers import AutoTokenizer
  from alibi_detect.ad import AdversarialAE, ModelDistillation
  from alibi_detect.ad.adversarialae import DenseHidden
  from alibi_detect.cd import ChiSquareDrift, ClassifierDrift, KSDrift, MMDDrift, TabularDrift
  from alibi_detect.cd.tensorflow import UAE, HiddenOutput
  from alibi_detect.cd.tensorflow.preprocess import _Encoder
  from alibi_detect.models.tensorflow import PixelCNN, TransformerEmbedding
  from alibi_detect.models.tensorflow.autoencoder import AE, AEGMM, VAE, VAEGMM, DecoderLSTM, EncoderLSTM, Seq2Seq
  from alibi_detect.od import LLR, IForest, Mahalanobis, OutlierAE, OutlierAEGMM, OutlierProphet, OutlierSeq2Seq, OutlierVAE, OutlierVAEGMM, SpectralResidual
  from alibi_detect.od.llr import build_model
  from alibi_detect.utils.tensorflow.kernels import DeepKernel
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.version import __version__
  from alibi_detect.base import Detector
  from alibi_detect.saving._typing import VALID_DETECTORS
label_desc: Use image node_id 4 for calling a global function with example usage: load_optimizer(cfg) and returns: tf, getattr