class_docstr: Exponential Moving Average of Fairseq Models
  EMA keeps a copy of the exponentially decayed model params.
  The set of params should include both gradient-descent and
  non-gradient descent params, such as batch mean/var and buffers.
  This is a modified implementation of
  the open source code in https://github.com/zhawe01/fairseq-gec.git,
  and internal source code in
  fbcode/mobile-vision/projects/classification_pytorch/lib/utils/model_ema.py.
  
  Similar to TF EMA.
  https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage.
  EMA provides a averaged and smoothed set of model weights, and has been shown to
  improve vision models. EMA class does all necessary functions to update, reload,
  or init EMA methods.
  
  EMA object is initialized from an arbitrary model. By default, it is stored in
  the same device (unless device specified at initialization) and with the
  same precision as the model (unless ema_fp32 is True). ema_fp32 is recommended.
  This stores the EMA parameters in fp32 only for the EMA update step, and
  is used at the default precision otherwise.
  EMA is usually enabled using EMAConfig with store_ema=True. Some important
  parameters to configure EMA are
  1) ema_decay - The decay of EMA
  2) ema_update_freq - EMA is updated every this many model updates.
  3) ema_start_update - Start EMA update after this many model updates [default 0]
  
  Key methods:
  1) step - One update of EMA using new model
  2) restore - Update EMA from a state dict
  3) reverse - Load EMA into a model
  4) get_decay, _set_decay - Used to get or set the decay.  Note _set_decay is
  called from step.
  5) build_fp32_params - Used to initialize or update the fp32 copy of EMA params.
  Note this is enabled only when ema_fp32=True
class_docstr_tok: ["Exponential","Moving","Average","of","Fairseq","Models","EMA","keeps","a","copy","of","the","exponentially","decayed","model","params",".","The","set","of","params","should","include","both","gradient-descent","and","non-gradient","descent","params",",","such","as","batch","mean\/var","and","buffers",".","This","is","a","modified","implementation","of","the","open","source","code","in","https",":","\/\/github.com\/zhawe01\/fairseq-gec.git",",","and","internal","source","code","in","fbcode\/mobile-vision\/projects\/classification_pytorch\/lib\/utils\/model_ema.py",".","Similar","to","TF","EMA",".","https",":","\/\/www.tensorflow.org\/api_docs\/python\/tf\/train\/ExponentialMovingAverage",".","EMA","provides","a","averaged","and","smoothed","set","of","model","weights",",","and","has","been","shown","to","improve","vision","models",".","EMA","class","does","all","necessary","functions","to","update",",","reload",",","or","init","EMA","methods",".","EMA","object","is","initialized","from","an","arbitrary","model",".","By","default",",","it","is","stored","in","the","same","device","(","unless","device","specified","at","initialization",")","and","with","the","same","precision","as","the","model","(","unless","ema_fp32","is","True",")",".","ema_fp32","is","recommended",".","This","stores","the","EMA","parameters","in","fp32","only","for","the","EMA","update","step",",","and","is","used","at","the","default","precision","otherwise",".","EMA","is","usually","enabled","using","EMAConfig","with","store_ema=True",".","Some","important","parameters","to","configure","EMA","are","1",")","ema_decay","-","The","decay","of","EMA","2",")","ema_update_freq","-","EMA","is","updated","every","this","many","model","updates",".","3",")","ema_start_update","-","Start","EMA","update","after","this","many","model","updates","[","default","0","]","Key","methods",":","1",")","step","-","One","update","of","EMA","using","new","model","2",")","restore","-","Update","EMA","from","a","state","dict","3",")","reverse","-","Load","EMA","into","a","model","4",")","get_decay",",","_set_decay","-","Used","to","get","or","set","the","decay",".","Note","_set_decay","is","called","from","step",".","5",")","build_fp32_params","-","Used","to","initialize","or","update","the","fp32","copy","of","EMA","params",".","Note","this","is","enabled","only","when","ema_fp32=True"]
code: def get_decay(self):
      return self.decay
  
file_path: fairseq/fairseq/models/ema/ema.py
imports: import copy
  import logging
  import torch
  from fairseq import checkpoint_utils
label_desc: Use image node_id 6 for calling the EMA obj's underlying member method code with example usage: obj.get_decay() and returns: self