class_docstr: optimizer (Optimizer): Wrapped optimizer.
  first_cycle_steps (int): First cycle step size.
  cycle_mult(float): Cycle steps magnification. Default: -1.
  max_lr(float): First cycle's max learning rate. Default: 0.1.
  min_lr(float): Min learning rate. Default: 0.001.
  warmup_steps(int): Linear warmup step size. Default: 0.
  gamma(float): Decrease rate of max learning rate by cycle. Default: 1.
  last_epoch (int): The index of last epoch. Default: -1.
class_docstr_tok: ["optimizer","(","Optimizer",")",":","Wrapped","optimizer",".","first_cycle_steps","(","int",")",":","First","cycle","step","size",".","cycle_mult","(","float",")",":","Cycle","steps","magnification",".","Default",":","-1.","max_lr","(","float",")",":","First","cycle","'s","max","learning","rate",".","Default",":","0.1.","min_lr","(","float",")",":","Min","learning","rate",".","Default",":","0.001.","warmup_steps","(","int",")",":","Linear","warmup","step","size",".","Default",":","0.","gamma","(","float",")",":","Decrease","rate","of","max","learning","rate","by","cycle",".","Default",":","1.","last_epoch","(","int",")",":","The","index","of","last","epoch",".","Default",":","-1","."]
code: def step(self, epoch=None):
      if epoch is None:
          epoch = self.last_epoch + 1
          self.step_in_cycle = self.step_in_cycle + 1
          if self.step_in_cycle >= self.cur_cycle_steps:
              self.cycle += 1
              self.step_in_cycle = (
                  self.step_in_cycle - self.cur_cycle_steps
              )
              self.cur_cycle_steps = (
                  int(
                      (self.cur_cycle_steps - self.warmup_steps)
                      * self.cycle_mult
                  )
                  + self.warmup_steps
              )
      else:
          if epoch >= self.first_cycle_steps:
              if self.cycle_mult == 1.0:
                  self.step_in_cycle = epoch % self.first_cycle_steps
                  self.cycle = epoch // self.first_cycle_steps
              else:
                  n = int(
                      math.log(
                          (
                              epoch
                              / self.first_cycle_steps
                              * (self.cycle_mult - 1)
                              + 1
                          ),
                          self.cycle_mult,
                      )
                  )
                  self.cycle = n
                  self.step_in_cycle = epoch - int(
                      self.first_cycle_steps
                      * (self.cycle_mult**n - 1)
                      / (self.cycle_mult - 1)
                  )
                  self.cur_cycle_steps = (
                      self.first_cycle_steps * self.cycle_mult ** (n)
                  )
          else:
              self.cur_cycle_steps = self.first_cycle_steps
              self.step_in_cycle = epoch
  
      self.max_lr = self.base_max_lr * (self.gamma**self.cycle)
      self.last_epoch = math.floor(epoch)
      for param_group, lr in zip(
          self.optimizer.param_groups, self.get_lr()
      ):
          param_group["lr"] = lr
  
file_path: espnet/espnet2/schedulers/cosine_anneal_warmup_restart.py
imports: import math
  import torch
  from torch.optim.lr_scheduler import _LRScheduler
  from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler
label_desc: Use image node_id 4 for calling the CosineAnnealingWarmupRestarts obj's underlying member method code with example usage: obj.step(epoch) without return types