code: def get_optimizer_class_and_kwargs(
      optimizer_config: "BaseOptimizerConfig", learning_rate: float
  ) -> Tuple[Type[torch.optim.Optimizer], Dict]:
      """Returns the optimizer class and kwargs for the optimizer.
  
      :return: Tuple of optimizer class and kwargs for the optimizer.
      """
      from ludwig.schema.optimizers import optimizer_registry
  
      # Get the corresponding torch optimizer class for the given config:
      optimizer_cls = get_from_registry(
          optimizer_config.type.lower(), optimizer_registry
      )[0]
  
      # Create a dict of parameters to be passed to torch (i.e. everything except `type`):
      cls_kwargs = {
          field: value
          for field, value in asdict(optimizer_config).items()
          if field != "type"
      }
      cls_kwargs["lr"] = learning_rate
  
      return optimizer_cls, cls_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 2 for calling a global function with example usage: get_optimizer_class_and_kwargs(optimizer_config, learning_rate) and returns: optimizer_cls,  cls_kwargs