code: def get_scheduler(
      name: Union[str, SchedulerType],
      optimizer: Optimizer,
      num_warmup_steps: Optional[int] = None,
      num_training_steps: Optional[int] = None,
  ):
      """
      Unified API to get any scheduler from its name.
  
      Args:
          name (:obj:`str` or `:obj:`SchedulerType`):
              The name of the scheduler to use.
          optimizer (:obj:`torch.optim.Optimizer`):
              The optimizer that will be used during training.
          num_warmup_steps (:obj:`int`, `optional`):
              The number of warmup steps to do. This is not required by all schedulers (hence the argument being
              optional), the function will raise an error if it's unset and the scheduler type requires it.
          num_training_steps (:obj:`int`, `optional`):
              The number of training steps to do. This is not required by all schedulers (hence the argument being
              optional), the function will raise an error if it's unset and the scheduler type requires it.
      """
      name = SchedulerType(name)
      schedule_func = TYPE_TO_SCHEDULER_FUNCTION[name]
      if name == SchedulerType.CONSTANT:
          return schedule_func(optimizer)
  
      # All other schedulers require `num_warmup_steps`
      if num_warmup_steps is None:
          raise ValueError(
              f"{name} requires `num_warmup_steps`, please provide that argument."
          )
  
      if name == SchedulerType.CONSTANT_WITH_WARMUP:
          return schedule_func(
              optimizer, num_warmup_steps=num_warmup_steps
          )
  
      # All other schedulers require `num_training_steps`
      if num_training_steps is None:
          raise ValueError(
              f"{name} requires `num_training_steps`, please provide that argument."
          )
  
      return schedule_func(
          optimizer,
          num_warmup_steps=num_warmup_steps,
          num_training_steps=num_training_steps,
      )
  
file_path: towhee/towhee/trainer/optimization/optimization.py
imports: import math
  from typing import Optional, Union
  from torch.optim import Optimizer
  from torch.optim.lr_scheduler import LambdaLR
  from towhee.trainer.utils.trainer_utils import SchedulerType
label_desc: Use image node_id 7 for calling a global function with example usage: get_scheduler(name, optimizer, num_warmup_steps, num_training_steps) and returns: schedule_func, schedule_func, schedule_func