class_docstr: This hook is for the extension of the SwAV loss proposed in paper
  https://arxiv.org/abs/2006.09882 by Caron et al. The loss combines
  the benefits of using the SwAV approach with the momentum encoder
  as used in MoCo.
class_docstr_tok: ["This","hook","is","for","the","extension","of","the","SwAV","loss","proposed","in","paper","https",":","\/\/arxiv.org\/abs\/2006.09882","by","Caron","et","al",".","The","loss","combines","the","benefits","of","using","the","SwAV","approach","with","the","momentum","encoder","as","used","in","MoCo","."]
docstr: Momentum update
  Each parameter becomes a weighted average of its old self and the
  newest encoder.
docstr_tok: ["Momentum","update","Each","parameter","becomes","a","weighted","average","of","its","old","self","and","the","newest","encoder","."]
code: def _update_momentum_network(self, task: tasks.ClassyTask) -> None:
      """
      Momentum update
      Each parameter becomes a weighted average of its old self and the
      newest encoder.
      """
  
      # Momentum update
      for param_q, param_k in zip(
          task.base_model.parameters(),
          task.loss.momentum_encoder.parameters(),
      ):
          param_k.data = (
              param_k.data * self.momentum
              + param_q.data * self.inv_momentum
          )
  
      for buff_q, buff_k in zip(
          task.base_model.named_buffers(),
          task.loss.momentum_encoder.named_buffers(),
      ):
          if "running_" not in buff_k[0]:
              continue
          buff_k[1].data.copy_(buff_q[1].data)
  
file_path: vissl/vissl/hooks/swav_momentum_hooks.py
imports: import logging
  from typing import List
  import torch
  from classy_vision import tasks
  from classy_vision.generic.distributed_util import init_distributed_data_parallel_model
  from classy_vision.hooks.classy_hook import ClassyHook
  from torch import nn
  from vissl.models import build_model
  from vissl.utils.env import get_machine_local_and_dist_rank
label_desc: Use image node_id 3 for calling the SwAVMomentumHook obj's underlying member method code with example usage: obj._update_momentum_network(task) without return types