class_docstr: Add an initial warmup stage to another scheduler.
class_docstr_tok: ["Add","an","initial","warmup","stage","to","another","scheduler","."]
docstr: Args:
      scheduler: warmup will be added at the beginning of this scheduler
      warmup_factor: the factor w.r.t the initial value of ``scheduler``, e.g. 0.001
      warmup_length: the relative length (in [0, 1]) of warmup steps w.r.t the entire
          training, e.g. 0.01
      warmup_method: one of "linear" or "constant"
      rescale_interval: whether we will rescale the interval of the scheduler after
          warmup
docstr_tok: ["Args",":","scheduler",":","warmup","will","be","added","at","the","beginning","of","this","scheduler","warmup_factor",":","the","factor","w.r.t","the","initial","value","of","``","scheduler","``",",","e.g",".","0.001","warmup_length",":","the","relative","length","(","in","[","0",",","1","]",")","of","warmup","steps","w.r.t","the","entire","training",",","e.g",".","0.01","warmup_method",":","one","of","``","linear","''","or","``","constant","''","rescale_interval",":","whether","we","will","rescale","the","interval","of","the","scheduler","after","warmup"]
code: def __init__(
      self,
      scheduler: ParamScheduler,
      warmup_factor: float,
      warmup_length: float,
      warmup_method: str = "linear",
      rescale_interval: bool = False,
  ):
      """
      Args:
          scheduler: warmup will be added at the beginning of this scheduler
          warmup_factor: the factor w.r.t the initial value of ``scheduler``, e.g. 0.001
          warmup_length: the relative length (in [0, 1]) of warmup steps w.r.t the entire
              training, e.g. 0.01
          warmup_method: one of "linear" or "constant"
          rescale_interval: whether we will rescale the interval of the scheduler after
              warmup
      """
      # the value to reach when warmup ends
      end_value = (
          scheduler(0.0)
          if rescale_interval
          else scheduler(warmup_length)
      )
      start_value = warmup_factor * scheduler(0.0)
      if warmup_method == "constant":
          warmup = ConstantParamScheduler(start_value)
      elif warmup_method == "linear":
          warmup = LinearParamScheduler(start_value, end_value)
      else:
          raise ValueError(
              "Unknown warmup method: {}".format(warmup_method)
          )
      super().__init__(
          [warmup, scheduler],
          interval_scaling=[
              "rescaled",
              "rescaled" if rescale_interval else "fixed",
          ],
          lengths=[warmup_length, 1 - warmup_length],
      )
  
imports: import logging
  import math
  from bisect import bisect_right
  from typing import List
  import torch
  from fvcore.common.param_scheduler import CompositeParamScheduler, ConstantParamScheduler, LinearParamScheduler, ParamScheduler
label_desc: Use image node_id 1 to create a new WarmupParamScheduler object from inherited base classes: CompositeParamScheduler with example: obj = WarmupParamScheduler(scheduler, warmup_factor, warmup_length, warmup_method, rescale_interval)