class_docstr: :class:`LARS` [LARC in apex] is a pytorch implementation of both the scaling and clipping variants of LARS,
  in which the ratio between gradient and parameter magnitudes is used to calculate an adaptive
  local learning rate for each individual parameter. The algorithm is designed to improve
  convergence of large batch training.
  
  See https://arxiv.org/abs/1708.03888 for calculation of the local learning rate.
  
  In practice it modifies the gradients of parameters as a proxy for modifying the learning rate
  of the parameters. This design allows it to be used as a wrapper around any torch.optim Optimizer.
  
  ```
  model = ...
  optim = torch.optim.Adam(model.parameters(), lr=...)
  optim = LARS(optim)
  ```
  
  Args:
      optimizer: Pytorch optimizer to wrap and modify learning rate for.
      trust_coefficient: Trust coefficient for calculating the lr. See https://arxiv.org/abs/1708.03888
      clip: Decides between clipping or scaling mode of LARC [LARS + clip].
            If `clip=True` the learning rate is set to `min(optimizer_lr, local_lr)` for each parameter.
            If `clip=False` the learning rate is set to `local_lr*optimizer_lr`.
      eps: epsilon kludge to help with numerical stability while calculating adaptive_lr
class_docstr_tok: [":","class",":","`","LARS","`","[","LARC","in","apex","]","is","a","pytorch","implementation","of","both","the","scaling","and","clipping","variants","of","LARS",",","in","which","the","ratio","between","gradient","and","parameter","magnitudes","is","used","to","calculate","an","adaptive","local","learning","rate","for","each","individual","parameter",".","The","algorithm","is","designed","to","improve","convergence","of","large","batch","training",".","See","https",":","\/\/arxiv.org\/abs\/1708.03888","for","calculation","of","the","local","learning","rate",".","In","practice","it","modifies","the","gradients","of","parameters","as","a","proxy","for","modifying","the","learning","rate","of","the","parameters",".","This","design","allows","it","to","be","used","as","a","wrapper","around","any","torch.optim","Optimizer",".","``","`","model","=","...","optim","=","torch.optim.Adam","(","model.parameters","(",")",",","lr=","...",")","optim","=","LARS","(","optim",")","``","`","Args",":","optimizer",":","Pytorch","optimizer","to","wrap","and","modify","learning","rate","for",".","trust_coefficient",":","Trust","coefficient","for","calculating","the","lr",".","See","https",":","\/\/arxiv.org\/abs\/1708.03888","clip",":","Decides","between","clipping","or","scaling","mode","of","LARC","[","LARS","+","clip","]",".","If","`","clip=True","`","the","learning","rate","is","set","to","`","min","(","optimizer_lr",",","local_lr",")","`","for","each","parameter",".","If","`","clip=False","`","the","learning","rate","is","set","to","`","local_lr","*","optimizer_lr","`",".","eps",":","epsilon","kludge","to","help","with","numerical","stability","while","calculating","adaptive_lr"]
code: def __init__(
      self, optimizer, trust_coefficient=0.02, clip=False, eps=1e-8
  ):
      self.param_groups = optimizer.param_groups
      self.optim = optimizer
      self.trust_coefficient = trust_coefficient
      self.eps = eps
      self.clip = clip
  
file_path: bert-ultrafast/training/cramming/backend/optimizers/optimizer_modifiers.py
imports: import torch
label_desc: Use image node_id 1 to create a new LARS object from inherited base classes: MetaOptimizer with example: obj = LARS(optimizer, trust_coefficient, clip, eps)