class_docstr: Learning rate range test.
  
  The learning rate range test increases the learning rate in a pre-training run
  between two boundaries in a linear or exponential manner. It provides valuable
  information on how well the network can be trained over a range of learning rates
  and what is the optimal learning rate.
  
  Example (fastai approach):
  >>> lr_finder = LearningRateFinder(net, optimizer, criterion)
  >>> lr_finder.range_test(data_loader, end_lr=100, num_iter=100)
  >>> lr_finder.get_steepest_gradient()
  >>> lr_finder.plot() # to inspect the loss-learning rate graph
  
  Example (Leslie Smith's approach):
  >>> lr_finder = LearningRateFinder(net, optimizer, criterion)
  >>> lr_finder.range_test(train_loader, val_loader=val_loader, end_lr=1, num_iter=100, step_mode="linear")
  
  Gradient accumulation is supported; example:
  >>> train_data = ...    # prepared dataset
  >>> desired_bs, real_bs = 32, 4         # batch size
  >>> accumulation_steps = desired_bs // real_bs     # required steps for accumulation
  >>> data_loader = torch.utils.data.DataLoader(train_data, batch_size=real_bs, shuffle=True)
  >>> acc_lr_finder = LearningRateFinder(net, optimizer, criterion)
  >>> acc_lr_finder.range_test(data_loader, end_lr=10, num_iter=100, accumulation_steps=accumulation_steps)
  
  By default, image will be extracted from data loader with x["image"] and x[0], depending on whether
  batch data is a dictionary or not (and similar behaviour for extracting the label). If your data loader
  returns something other than this, pass a callable function to extract it, e.g.:
  >>> image_extractor = lambda x: x["input"]
  >>> label_extractor = lambda x: x[100]
  >>> lr_finder = LearningRateFinder(net, optimizer, criterion)
  >>> lr_finder.range_test(train_loader, val_loader, image_extractor, label_extractor)
  
  References:
  Modified from: https://github.com/davidtvs/pytorch-lr-finder.
  Cyclical Learning Rates for Training Neural Networks: https://arxiv.org/abs/1506.01186
class_docstr_tok: ["Learning","rate","range","test",".","The","learning","rate","range","test","increases","the","learning","rate","in","a","pre-training","run","between","two","boundaries","in","a","linear","or","exponential","manner",".","It","provides","valuable","information","on","how","well","the","network","can","be","trained","over","a","range","of","learning","rates","and","what","is","the","optimal","learning","rate",".","Example","(","fastai","approach",")",":",">",">",">","lr_finder","=","LearningRateFinder","(","net",",","optimizer",",","criterion",")",">",">",">","lr_finder.range_test","(","data_loader",",","end_lr=100",",","num_iter=100",")",">",">",">","lr_finder.get_steepest_gradient","(",")",">",">",">","lr_finder.plot","(",")","#","to","inspect","the","loss-learning","rate","graph","Example","(","Leslie","Smith","'s","approach",")",":",">",">",">","lr_finder","=","LearningRateFinder","(","net",",","optimizer",",","criterion",")",">",">",">","lr_finder.range_test","(","train_loader",",","val_loader=val_loader",",","end_lr=1",",","num_iter=100",",","step_mode=","''","linear","''",")","Gradient","accumulation","is","supported",";","example",":",">",">",">","train_data","=","...","#","prepared","dataset",">",">",">","desired_bs",",","real_bs","=","32",",","4","#","batch","size",">",">",">","accumulation_steps","=","desired_bs","\/\/","real_bs","#","required","steps","for","accumulation",">",">",">","data_loader","=","torch.utils.data.DataLoader","(","train_data",",","batch_size=real_bs",",","shuffle=True",")",">",">",">","acc_lr_finder","=","LearningRateFinder","(","net",",","optimizer",",","criterion",")",">",">",">","acc_lr_finder.range_test","(","data_loader",",","end_lr=10",",","num_iter=100",",","accumulation_steps=accumulation_steps",")","By","default",",","image","will","be","extracted","from","data","loader","with","x","[","``","image","''","]","and","x","[","0","]",",","depending","on","whether","batch","data","is","a","dictionary","or","not","(","and","similar","behaviour","for","extracting","the","label",")",".","If","your","data","loader","returns","something","other","than","this",",","pass","a","callable","function","to","extract","it",",","e.g",".",":",">",">",">","image_extractor","=","lambda","x",":","x","[","``","input","''","]",">",">",">","label_extractor","=","lambda","x",":","x","[","100","]",">",">",">","lr_finder","=","LearningRateFinder","(","net",",","optimizer",",","criterion",")",">",">",">","lr_finder.range_test","(","train_loader",",","val_loader",",","image_extractor",",","label_extractor",")","References",":","Modified","from",":","https",":","\/\/github.com\/davidtvs\/pytorch-lr-finder",".","Cyclical","Learning","Rates","for","Training","Neural","Networks",":","https",":","\/\/arxiv.org\/abs\/1506.01186"]
docstr: Set learning rate(s) for optimizer.
code: def _set_learning_rate(self, new_lrs: float | list) -> None:
      """Set learning rate(s) for optimizer."""
      if not isinstance(new_lrs, list):
          new_lrs = [new_lrs] * len(self.optimizer.param_groups)
      if len(new_lrs) != len(self.optimizer.param_groups):
          raise ValueError(
              "Length of `new_lrs` is not equal to the number of parameter groups "
              + "in the given optimizer"
          )
  
      for param_group, new_lr in zip(
          self.optimizer.param_groups, new_lrs
      ):
          param_group["lr"] = new_lr
  
imports: from __future__ import annotations
  import pickle
  import types
  import warnings
  from functools import partial
  from typing import TYPE_CHECKING, Any, Callable
  import numpy
  import torch
  import torch.nn
  from torch.optim import Optimizer
  from torch.serialization import DEFAULT_PROTOCOL
  from torch.utils.data import DataLoader
  from monai.networks.utils import eval_mode
  from monai.optimizers.lr_scheduler import ExponentialLR, LinearLR
  from monai.utils import StateCacher, copy_to_device, optional_import
label_desc: Use image node_id 4 for calling the LearningRateFinder obj's underlying member method code with example usage: obj._set_learning_rate(new_lrs) without return types