class_docstr: Learning Rate Scheduler Plugin.
  
  This plugin manages learning rate scheduling inside of a strategy using the
  PyTorch scheduler passed to the constructor. The step() method of the
  scheduler is called after each training epoch or iteration.
  
  Metric-based schedulers (like ReduceLROnPlateau) are supported as well.
class_docstr_tok: ["Learning","Rate","Scheduler","Plugin",".","This","plugin","manages","learning","rate","scheduling","inside","of","a","strategy","using","the","PyTorch","scheduler","passed","to","the","constructor",".","The","step","(",")","method","of","the","scheduler","is","called","after","each","training","epoch","or","iteration",".","Metric-based","schedulers","(","like","ReduceLROnPlateau",")","are","supported","as","well","."]
code: def _patch_lr_on_plateau(scheduler):
      # All PyTorch schedulers have the base_lrs field (needed to reset the
      # initial LRs before each experience) with the only exception being
      # ReduceLROnPlateau. This method will add that field to
      # ReduceLROnPlateau.
  
      if hasattr(scheduler, "base_lrs"):
          return
  
      # Initialize epoch and base learning rates
      for group in scheduler.optimizer.param_groups:
          group.setdefault("initial_lr", group["lr"])
  
      scheduler.base_lrs = list(
          map(
              lambda group_param: group_param["initial_lr"],
              scheduler.optimizer.param_groups,
          )
      )
  
imports: import warnings
  from typing import TYPE_CHECKING
  from typing_extensions import Literal
  from avalanche.evaluation.metrics import Mean
  from avalanche.training.plugins import SupervisedPlugin
  import inspect
label_desc: Use image node_id 11 for calling the LRSchedulerPlugin obj's underlying member method code with example usage: obj._patch_lr_on_plateau(scheduler) without return types