class_docstr: Assign LR based on a cyclical schedule that follows the cosine function.
  
  See https://arxiv.org/pdf/1608.03983.pdf for details.
  
  We also support a warmup phase where we linearly increase the learning rate
  from some initial learning rate (``--warmup-init-lr``) until the configured
  max learning rate (``--lr``).
  
  During warmup::
  
    lrs = torch.linspace(cfg.warmup_init_lr, cfg.lr, cfg.warmup_updates)
    lr = lrs[update_num]
  
  After warmup::
  
    lr = cfg.min_lr + 0.5*(cfg.lr - cfg.min_lr)*(1 + cos(t_curr / t_i))
  
  where ``t_curr`` is current percentage of updates within the current period
  range and ``t_i`` is the current period range, which is scaled by ``t_mul``
  after every iteration.
docstr: Update the learning rate at the end of the given epoch.
docstr_tok: ["Update","the","learning","rate","at","the","end","of","the","given","epoch","."]
code: def step(self, epoch, val_loss=None):
      """Update the learning rate at the end of the given epoch."""
      super().step(epoch, val_loss)
      # we don't change the learning rate at epoch boundaries
      return self.optimizer.get_lr()
  
file_path: fairseq/fairseq/optim/lr_scheduler/cosine_lr_scheduler.py
imports: import math
  from collections.abc import Collection
  from dataclasses import dataclass, field
  from typing import List
  from omegaconf import II
  from fairseq.dataclass import FairseqDataclass
  from fairseq.optim.lr_scheduler import FairseqLRScheduler, register_lr_scheduler
label_desc: Use image node_id 2 for calling the CosineLRSchedule obj's underlying member method code with example usage: obj.step(epoch, val_loss) and returns: self