class_docstr: For a given model, this class computes the exponential moving average of weights
  
  Args:
      model (torch.nn.Module): Model
      ema_momentum (Optional[float]): Momentum value shows the contribution of weights at current iteration. Default: 0.0005
      device (Optional[str]): Device (CPU or GPU) on which model resides. Default: cpu
code: def update_parameters(self, model):
      # correct a mismatch in state dict keys
      has_module = hasattr(model, "module") and not self.ema_has_module
      with torch.no_grad():
          msd = model.state_dict()
          for k, ema_v in self.ema_model.state_dict().items():
              if has_module:
                  # .module is added if we use DistributedDataParallel or DataParallel wrappers around model
                  k = "module." + k
              model_v = msd[k].detach()
              if self.device:
                  model_v = model_v.to(device=self.device)
              ema_v.copy_(
                  (ema_v * (1.0 - self.momentum))
                  + (self.momentum * model_v)
              )
  
file_path: ml-cvnets/cvnets/misc/averaging_utils.py
imports: import argparse
  from copy import deepcopy
  from typing import Optional
  import torch
  from torch import nn
label_desc: Use image node_id 2 for calling the EMA obj's underlying member method code with example usage: obj.update_parameters(model) without return types