class_docstr: Changes the param value after every epoch based on a `cosine schedule <https:
  //arxiv.org/pdf/1608.03983.pdf>`_. The schedule is updated after every train
  step by default.
  
  Can be used for cosine learning rate with warm restarts. For restarts, we calculate
  what will be the maximum learning rate after every restart. There are 3 options:
      - Option 1: LR after every restart is same as original max LR
      - Option 2: LR after every restart decays with a fixed LR multiplier
      - Option 3: LR after every restart is adaptively calculated such that the resulting
                  max LR matches the original cosine wave LR.
  
  Args:
      wave_type: half | full
      lr_multiplier: float value -> LR after every restart decays with a fixed LR multiplier
      is_adaptive: True -> if after every restart, maximum LR is adaptively calculated such
                  that the resulting max LR matches the original cosine wave LR.
      update_interval: step | epoch -> if the LR should be updated after every training
                       iteration or after training epoch
  
  Example:
  
      .. code-block:: python
  
        start_value: 0.1
        end_value: 0.0001
        restart_interval_length: 0.5  # for 1 restart
        wave_type: half
        lr_multiplier: 1.0  # for using a decayed max LR value at every restart
        use_adaptive_decay: False
docstr: Instantiates a CosineWarmRestartScheduler from a configuration.
  
  Args:
      config: A configuration for a CosineWarmRestartScheduler.
          See :func:`__init__` for parameters expected in the config.
  
  Returns:
      A CosineWarmRestartScheduler instance.
docstr_tok: ["Instantiates","a","CosineWarmRestartScheduler","from","a","configuration",".","Args",":","config",":","A","configuration","for","a","CosineWarmRestartScheduler",".","See",":","func",":","`","__init__","`","for","parameters","expected","in","the","config",".","Returns",":","A","CosineWarmRestartScheduler","instance","."]
code: def from_config(
      cls, config: Dict[str, Any]
  ) -> "CosineWarmRestartScheduler":
      """
      Instantiates a CosineWarmRestartScheduler from a configuration.
  
      Args:
          config: A configuration for a CosineWarmRestartScheduler.
              See :func:`__init__` for parameters expected in the config.
  
      Returns:
          A CosineWarmRestartScheduler instance.
      """
      assert (
          "start_value" in config and "end_value" in config
      ), "CosineWarmRestartScheduler requires a start_value and a end_value"
      assert (
          "restart_interval_length" in config and "wave_type" in config
      ), "CosineWarmRestartScheduler requires restart_interval_length and wave_type"
  
      return cls(
          start_value=config["start_value"],
          end_value=config["end_value"],
          restart_interval_length=config["restart_interval_length"],
          wave_type=config.get("wave_type", CosineWaveTypes.half),
          lr_multiplier=config.get("lr_multiplier", 1.0),
          is_adaptive=config.get("is_adaptive", False),
          update_interval=UpdateInterval.from_config(
              config, UpdateInterval.STEP
          ),
      )
  
file_path: vissl/vissl/optimizers/param_scheduler/cosine_warm_restart_scheduler.py
imports: import bisect
  import math
  from enum import Enum
  from typing import Any, Dict
  import numpy
  from classy_vision.optim.param_scheduler import ClassyParamScheduler, register_param_scheduler, UpdateInterval
label_desc: Use image node_id 4 for calling the CosineWarmRestartScheduler obj's underlying member method code with example usage: obj.from_config(cls, config) and returns: cls