code: def get_optimizer(
      config: OptimizerConfig,
  ) -> Tuple[
      Type[torch.optim.Optimizer], Dict[str, Any], Dict[str, Any]
  ]:
      """
      Get optimizer class, kwargs, and `zero_grad()` kwargs using the specified
      config settings.
  
      :param config: Optimizer config.
  
      :return: Tuple of Optimizer class, its kwargs dictionary, and the kwargs
               dictionary for calling that optimizer's `zero_grad()` method.
      """
      adam_impl = torch.optim.Adam
      sgd_impl = torch.optim.SGD
      # Built-in optimizers take the "set_to_none" argument. See:
      # https://pytorch.org/tutorials/recipes/recipes/tuning_guide.html
      zero_grad_kwargs = {"set_to_none": True}
  
      # Use Apex's fused optimizers if Apex is available and we aren't using
      # DeepSpeed, which includes its own optimizers.
      if config.running_on_gpu and not utils.using_deepspeed():
          try:
              from apex.optimizers import FusedAdam, FusedSGD
  
              adam_impl = FusedAdam
              sgd_impl = FusedSGD
              # Apex optimizers automatically set gradients to none instead of
              # zeroing and do not have a "set_to_none" argument. See:
              # https://nvidia.github.io/apex/optimizers.html
              zero_grad_kwargs = {}
              logging.info("Using NVIDIA Apex fused optimizers")
          except ImportError:
              logger.warning(
                  "Cannot import NVIDIA Apex optimizers (FusedAdam, FusedSGD). Consider installing Apex for "
                  "faster GPU training: https://github.com/NVIDIA/apex"
              )
  
      if config.name == C.OPTIMIZER_ADAM:
          return (
              adam_impl,
              {
                  "lr": config.lr,
                  "betas": config.betas,
                  "eps": config.eps,
                  "weight_decay": config.weight_decay,
              },
              zero_grad_kwargs,
          )
      elif config.name == C.OPTIMIZER_SGD:
          return (
              sgd_impl,
              {
                  "lr": config.lr,
                  "momentum": config.momentum,
                  "weight_decay": config.weight_decay,
              },
              zero_grad_kwargs,
          )
      raise ValueError(f"Unknown optimizer: {config.name}")
  
file_path: sockeye/sockeye/optimizers.py
imports: from dataclasses import dataclass
  import logging
  from typing import Any, Dict, Optional, Tuple, Type
  import torch
  from .None import config
  from .None import constants
  from .None import utils
label_desc: Use image node_id 1 for calling a global function with example usage: get_optimizer(config) and returns: adam_impl,  dict,  zero_grad_kwargs, sgd_impl,  dict,  zero_grad_kwargs