class_docstr: Anneals the learning rate in each parameter group to a fixed value.
  This learning rate scheduler is meant to be used with Stochastic Weight 
  Averaging (SWA) method (see `torch.optim.swa_utils.AveragedModel`).
  Arguments:
      optimizer (torch.optim.Optimizer): wrapped optimizer
      swa_lrs (float or list): the learning rate value for all param groups
          together or separately for each group.
      annealing_epochs (int): number of epochs in the annealing phase 
          (default: 10)
      annealing_strategy (str): "cos" or "linear"; specifies the annealing 
          strategy: "cos" for cosine annealing, "linear" for linear annealing
          (default: "cos")
      last_epoch (int): the index of the last epoch (default: 'cos')
  The :class:`SWALR` scheduler is can be used together with other
  schedulers to switch to a constant learning rate late in the training 
  as in the example below.
  Example:
      >>> loader, optimizer, model = ...
      >>> lr_lambda = lambda epoch: 0.9
      >>> scheduler = torch.optim.lr_scheduler.MultiplicativeLR(optimizer, 
      >>>        lr_lambda=lr_lambda)
      >>> swa_scheduler = torch.optim.swa_utils.SWALR(optimizer, 
      >>>        anneal_strategy="linear", anneal_epochs=20, swa_lr=0.05)
      >>> swa_start = 160
      >>> for i in range(300):
      >>>      for input, target in loader:
      >>>          optimizer.zero_grad()
      >>>          loss_fn(model(input), target).backward()
      >>>          optimizer.step()
      >>>      if i > swa_start:
      >>>          swa_scheduler.step()
      >>>      else:
      >>>          scheduler.step()
  .. _Averaging Weights Leads to Wider Optima and Better Generalization:
      https://arxiv.org/abs/1803.05407
class_docstr_tok: ["Anneals","the","learning","rate","in","each","parameter","group","to","a","fixed","value",".","This","learning","rate","scheduler","is","meant","to","be","used","with","Stochastic","Weight","Averaging","(","SWA",")","method","(","see","`","torch.optim.swa_utils.AveragedModel","`",")",".","Arguments",":","optimizer","(","torch.optim.Optimizer",")",":","wrapped","optimizer","swa_lrs","(","float","or","list",")",":","the","learning","rate","value","for","all","param","groups","together","or","separately","for","each","group",".","annealing_epochs","(","int",")",":","number","of","epochs","in","the","annealing","phase","(","default",":","10",")","annealing_strategy","(","str",")",":","``","cos","''","or","``","linear","''",";","specifies","the","annealing","strategy",":","``","cos","''","for","cosine","annealing",",","``","linear","''","for","linear","annealing","(","default",":","``","cos","''",")","last_epoch","(","int",")",":","the","index","of","the","last","epoch","(","default",":","'cos","'",")","The",":","class",":","`","SWALR","`","scheduler","is","can","be","used","together","with","other","schedulers","to","switch","to","a","constant","learning","rate","late","in","the","training","as","in","the","example","below",".","Example",":",">",">",">","loader",",","optimizer",",","model","=","...",">",">",">","lr_lambda","=","lambda","epoch",":","0.9",">",">",">","scheduler","=","torch.optim.lr_scheduler.MultiplicativeLR","(","optimizer",",",">",">",">","lr_lambda=lr_lambda",")",">",">",">","swa_scheduler","=","torch.optim.swa_utils.SWALR","(","optimizer",",",">",">",">","anneal_strategy=","''","linear","''",",","anneal_epochs=20",",","swa_lr=0.05",")",">",">",">","swa_start","=","160",">",">",">","for","i","in","range","(","300",")",":",">",">",">","for","input",",","target","in","loader",":",">",">",">","optimizer.zero_grad","(",")",">",">",">","loss_fn","(","model","(","input",")",",","target",")",".backward","(",")",">",">",">","optimizer.step","(",")",">",">",">","if","i",">","swa_start",":",">",">",">","swa_scheduler.step","(",")",">",">",">","else",":",">",">",">","scheduler.step","(",")","..","_Averaging","Weights","Leads","to","Wider","Optima","and","Better","Generalization",":","https",":","\/\/arxiv.org\/abs\/1803.05407"]
code: def get_lr(self):
      if not self._get_lr_called_within_step:
          warnings.warn(
              "To get the last learning rate computed by the scheduler, "
              "please use `get_last_lr()`.",
              UserWarning,
          )
      step = self._step_count - 1
      prev_t = max(0, min(1, (step - 1) / self.anneal_epochs))
      prev_alpha = self.anneal_func(prev_t)
      prev_lrs = [
          self._get_initial_lr(group["lr"], group["swa_lr"], prev_alpha)
          for group in self.optimizer.param_groups
      ]
      t = max(0, min(1, step / self.anneal_epochs))
      alpha = self.anneal_func(t)
      return [
          group["swa_lr"] * alpha + lr * (1 - alpha)
          for group, lr in zip(self.optimizer.param_groups, prev_lrs)
      ]
  
imports: import copy
  import warnings
  import math
  from copy import deepcopy
  import torch
  from torch.nn import Module
  from torch.optim.lr_scheduler import _LRScheduler
  from domainbed.ur_networks import URResNet
label_desc: Use image node_id 6 for calling the SWALR obj's underlying member method code with example usage: obj.get_lr() and returns: unknown