class_docstr: Reduce the learning rate according to a cosine function
  
  Calculate the new learning rate by::
  
     final_lr + (start_lr - final_lr) * (1+cos(pi * nup/max_nup))/2
     if nup < max_nup, 0 otherwise.
  
  Parameters
  ----------
      max_update: int
          maximum number of updates before the decay reaches 0
      base_lr: float
          base learning rate
      final_lr: float
          final learning rate after all steps
      warmup_steps: int
          number of warmup steps used before this scheduler starts decay
      warmup_begin_lr: float
          if using warmup, the learning rate from which it starts warming up
      warmup_mode: string
          warmup can be done in two modes.
          'linear' mode gradually increases lr with each step in equal increments
          'constant' mode keeps lr at warmup_begin_lr for warmup_steps
code: def __init__(
      self,
      max_update,
      base_lr=0.01,
      final_lr=0,
      warmup_steps=0,
      warmup_begin_lr=0,
      warmup_mode="linear",
  ):
      super(CosineScheduler, self).__init__(
          base_lr, warmup_steps, warmup_begin_lr, warmup_mode
      )
      assert isinstance(max_update, int)
      if max_update < 1:
          raise ValueError(
              "maximum number of updates must be strictly positive"
          )
      self.base_lr_orig = base_lr
      self.max_update = max_update
      self.final_lr = final_lr
      self.max_steps = self.max_update - self.warmup_steps
  
imports: import logging
  from math import cos, pi
label_desc: Use image node_id 1 to create a new CosineScheduler object from inherited base classes: LRScheduler with example: obj = CosineScheduler(max_update, base_lr, final_lr, warmup_steps, warmup_begin_lr, warmup_mode)