class_docstr: Decay the LR by a factor every time the validation loss plateaus.
  Also comes with optional warmup phase, where we linearly increase
  the learning rate from some initial learning rate
  (``--warmup-init-lr``) until the configured learning rate
  (``--lr``). Thereafter the lr is adjusted according to original
  reduce_on_plateau scheme.
  
  During warmup::
  
    lrs = torch.linspace(
        cfg.warmup_init_lr, cfg.lr, cfg.warmup_updates
    )
    lr = lrs[update_num]
class_docstr_tok: ["Decay","the","LR","by","a","factor","every","time","the","validation","loss","plateaus",".","Also","comes","with","optional","warmup","phase",",","where","we","linearly","increase","the","learning","rate","from","some","initial","learning","rate","(","``","--","warmup-init-lr","``",")","until","the","configured","learning","rate","(","``","--","lr","``",")",".","Thereafter","the","lr","is","adjusted","according","to","original","reduce_on_plateau","scheme",".","During","warmup",":",":","lrs","=","torch.linspace","(","cfg.warmup_init_lr",",","cfg.lr",",","cfg.warmup_updates",")","lr","=","lrs","[","update_num","]"]
docstr: Update the learning rate after each update.
docstr_tok: ["Update","the","learning","rate","after","each","update","."]
code: def step_update(self, num_updates):
      """
      Update the learning rate after each update."""
      # if there is warmup
      if self.cfg.warmup_updates > 0:
          if num_updates <= self.cfg.warmup_updates:
              self.lr = (
                  self.cfg.warmup_init_lr + num_updates * self.lr_step
              )
              self.optimizer.set_lr(self.lr)
          else:
              if self.warmup_end is False:
                  self.warmup_end = True
      # else do nothing
      return self.optimizer.get_lr()
  
file_path: fairseq/fairseq/optim/lr_scheduler/reduce_lr_on_plateau.py
imports: from dataclasses import dataclass, field
  from typing import List
  import torch.optim.lr_scheduler
  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 5 for calling the ReduceLROnPlateauLRSchedule obj's underlying member method code with example usage: obj.step_update(num_updates) and returns: self