docstr: Updates the SWA running averages for the given parameter group.
  
  Arguments:
      param_group (dict): Specifies for what parameter group SWA running
          averages should be updated
  
  Examples:
      >>> # automatic mode
      >>> base_opt = torch.optim.SGD([{'params': [x]},
      >>>             {'params': [y], 'lr': 1e-3}], lr=1e-2, momentum=0.9)
      >>> opt = torchcontrib.optim.SWA(base_opt)
      >>> for i in range(100):
      >>>     opt.zero_grad()
      >>>     loss_fn(model(input), target).backward()
      >>>     opt.step()
      >>>     if i > 10 and i % 5 == 0:
      >>>         # Update SWA for the second parameter group
      >>>         opt.update_swa_group(opt.param_groups[1])
      >>> opt.swap_swa_sgd()
docstr_tok: ["Updates","the","SWA","running","averages","for","the","given","parameter","group",".","Arguments",":","param_group","(","dict",")",":","Specifies","for","what","parameter","group","SWA","running","averages","should","be","updated","Examples",":",">",">",">","#","automatic","mode",">",">",">","base_opt","=","torch.optim.SGD","(","[","{","'params","'",":","[","x","]","}",",",">",">",">","{","'params","'",":","[","y","]",",","'lr","'",":","1e-3","}","]",",","lr=1e-2",",","momentum=0.9",")",">",">",">","opt","=","torchcontrib.optim.SWA","(","base_opt",")",">",">",">","for","i","in","range","(","100",")",":",">",">",">","opt.zero_grad","(",")",">",">",">","loss_fn","(","model","(","input",")",",","target",")",".backward","(",")",">",">",">","opt.step","(",")",">",">",">","if","i",">","10","and","i","%","5","==","0",":",">",">",">","#","Update","SWA","for","the","second","parameter","group",">",">",">","opt.update_swa_group","(","opt.param_groups","[","1","]",")",">",">",">","opt.swap_swa_sgd","(",")"]
code: def update_swa_group(self, group):
      r"""Updates the SWA running averages for the given parameter group.
  
      Arguments:
          param_group (dict): Specifies for what parameter group SWA running
              averages should be updated
  
      Examples:
          >>> # automatic mode
          >>> base_opt = torch.optim.SGD([{'params': [x]},
          >>>             {'params': [y], 'lr': 1e-3}], lr=1e-2, momentum=0.9)
          >>> opt = torchcontrib.optim.SWA(base_opt)
          >>> for i in range(100):
          >>>     opt.zero_grad()
          >>>     loss_fn(model(input), target).backward()
          >>>     opt.step()
          >>>     if i > 10 and i % 5 == 0:
          >>>         # Update SWA for the second parameter group
          >>>         opt.update_swa_group(opt.param_groups[1])
          >>> opt.swap_swa_sgd()
      """
      for p in group["params"]:
          param_state = self.state[p]
          if "swa_buffer" not in param_state:
              param_state["swa_buffer"] = torch.zeros_like(p.data)
          buf = param_state["swa_buffer"]
          virtual_decay = 1 / float(group["n_avg"] + 1)
          diff = (p.data - buf) * virtual_decay
          buf.add_(diff)
      group["n_avg"] += 1
  
imports: import warnings
  from collections import defaultdict
  from typing import Optional, Union
  import torch
  from pytext.config.component import create_optimizer
  from pytext.optimizer.lamb import Lamb
  from pytext.optimizer.madgrad import MADGRAD
  from pytext.optimizer.optimizers import Adagrad, Adam, AdamW, Optimizer, SGD
  from pytext.optimizer.radam import RAdam
  from torch.optim import Optimizer
label_desc: Use image node_id 4 for calling the StochasticWeightAveraging obj's underlying member method code with example usage: obj.update_swa_group(group) without return types