code: def _set_dtypes(cfg: dict):
      """
      Converts str's in the config dictionary to dtypes e.g. 'np.float32' is converted to np.float32.
  
      Parameters
      ----------
      cfg
          The config dictionary.
      """
      # TODO - we could explore a custom pydantic generic type for this (similar to how we handle NDArray)
      for key in FIELDS_TO_DTYPE:
          val = _get_nested_value(cfg, key)
          if val is not None:
              lib, dtype, *_ = val.split(".")
              # val[0] = np if val[0] == 'np' else tf if val[0] == 'tf' else torch if val[0] == 'torch' else None
              # TODO - add above back in once optional deps are handled properly
              if lib is None:
                  raise ValueError(
                      "`dtype` must be in format np.<dtype>, tf.<dtype> or torch.<dtype>."
                  )
              {
                  "tf": lambda: _set_nested_value(
                      cfg, key, get_tf_dtype(dtype)
                  ),
                  "torch": lambda: _set_nested_value(
                      cfg, key, get_pt_dtype(dtype)
                  ),
                  "np": lambda: _set_nested_value(
                      cfg, key, getattr(np, dtype)
                  ),
              }[lib]()
  
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 12 for calling a global function with example usage: _set_dtypes(cfg) without return types