code: def create_optimizer(
      model: LudwigModule,
      optimizer_config: "BaseOptimizerConfig",
      learning_rate: float,
  ) -> torch.optim.Optimizer:
      """Returns a ready-to-use torch optimizer instance based on the given optimizer config.
  
      :param model: Underlying Ludwig model
      :param learning_rate: Initial learning rate for the optimizer
      :param optimizer_config: Instance of `ludwig.modules.optimization_modules.BaseOptimizerConfig`.
      :return: Initialized instance of a torch optimizer.
      """
      # Make sure the optimizer is compatible with the available resources:
      if (optimizer_config.is_paged or optimizer_config.is_8bit) and (
          not torch.cuda.is_available()
          or torch.cuda.device_count() == 0
      ):
          raise ValueError(
              "Cannot use a paged or 8-bit optimizer on a non-GPU machine. "
              "Please use a different optimizer or run on a machine with a GPU."
          )
  
      optimizer_cls, optimizer_kwargs = get_optimizer_class_and_kwargs(
          optimizer_config, learning_rate
      )
      return optimizer_cls(model.parameters(), **optimizer_kwargs)
  
file_path: ludwig/ludwig/modules/optimization_modules.py
imports: from dataclasses import asdict
  from typing import Dict, Optional, Tuple, Type, TYPE_CHECKING
  import torch
  from ludwig.utils.misc_utils import get_from_registry
  from ludwig.utils.torch_utils import LudwigModule
label_desc: Use image node_id 3 for calling a global function with example usage: create_optimizer(model, optimizer_config, learning_rate) and returns: optimizer_cls