class_docstr: Scheduler that decays by a cosine function.
docstr: max_lr_steps determines the cycle length of the cosine annealing.
  
  It indicates the number of steps from 1.0 multiplier to 0.0, which corresponds
  to going from cos(0) to cos(pi)
docstr_tok: ["max_lr_steps","determines","the","cycle","length","of","the","cosine","annealing",".","It","indicates","the","number","of","steps","from","1.0","multiplier","to","0.0",",","which","corresponds","to","going","from","cos","(","0",")","to","cos","(","pi",")"]
code: def __init__(
      self,
      optimizer,
      patience,
      decay,
      warmup_updates,
      warmup_rate,
      max_lr_steps,
  ):
      """
      max_lr_steps determines the cycle length of the cosine annealing.
  
      It indicates the number of steps from 1.0 multiplier to 0.0, which corresponds
      to going from cos(0) to cos(pi)
      """
      super().__init__(warmup_updates, warmup_rate)
      if max_lr_steps <= 0:
          raise ValueError(
              "--lr-scheduler cosine requires setting --max-train-steps"
          )
      assert self.warmup_updates >= 0
      self.max_lr_steps = max_lr_steps - self.warmup_updates
      self.scheduler = optim.lr_scheduler.LambdaLR(
          optimizer, self._cosine_lr
      )
  
imports: import math
  from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from abc import abstractmethod
  from torch import optim
  import numpy
  from parlai.core.exceptions import StopTrainException
  from parlai.utils.misc import warn_once
label_desc: Use image node_id 1 to create a new CosineLRScheduler object from inherited base classes: ParlAILRScheduler with example: obj = CosineLRScheduler(optimizer, patience, decay, warmup_updates, warmup_rate, max_lr_steps)