code: def load_optimizer(cfg: dict) -> Type[torch.optim.Optimizer]:
      """
      Imports a PyTorch torch.optim.Optimizer class from an optimizer config dict.
  
      Parameters
      ----------
      cfg
          The optimizer config dict.
  
      Returns
      -------
      The loaded optimizer class.
      """
      class_name = cfg.get("class_name")
      try:
          return getattr(import_module("torch.optim"), class_name)
      except AttributeError:
          raise ValueError(
              f"{class_name} is not a recognised optimizer in `torch.optim`."
          )
  
file_path: alibi-detect/alibi_detect/saving/_pytorch/loading.py
imports: import logging
  import os
  from importlib import import_module
  from pathlib import Path
  from typing import Callable, Optional, Union, Type
  import dill
  import torch
  import torch.nn
  from alibi_detect.cd.pytorch import UAE, HiddenOutput
  from alibi_detect.cd.pytorch.preprocess import _Encoder
  from alibi_detect.models.pytorch import TransformerEmbedding
  from alibi_detect.utils.pytorch.kernels import DeepKernel
label_desc: Use image node_id 4 for calling a global function with example usage: load_optimizer(cfg) and returns: getattr