class_docstr: Create shadow variables and maintain exponential moving average for model parameters.
  
  Registered as a `MovingAverage` with name "exponential".
  
  # Parameters
  
  parameters : `Iterable[Tuple[str, Parameter]]`, required
      The parameters whose averages we'll be tracking. In a typical AllenNLP configuration
      file, this argument does not get an entry under the "moving_average", it gets passed
      in separately.
  decay : `float`, optional (default = `0.9999`)
      The decay rate that will be used if `num_updates` is not passed
      (and that will be used as an upper bound if `num_updates` is passed).
  numerator : `float`, optional (default = `1.0`)
      The numerator used to compute the decay rate if `num_updates` is passed.
  denominator : `float`, optional (default = `10.0`)
      The denominator used to compute the decay rate if `num_updates` is passed.
class_docstr_tok: ["Create","shadow","variables","and","maintain","exponential","moving","average","for","model","parameters",".","Registered","as","a","`","MovingAverage","`","with","name","``","exponential","''",".","#","Parameters","parameters",":","`","Iterable","[","Tuple","[","str",",","Parameter","]","]","`",",","required","The","parameters","whose","averages","we","'ll","be","tracking",".","In","a","typical","AllenNLP","configuration","file",",","this","argument","does","not","get","an","entry","under","the","``","moving_average","''",",","it","gets","passed","in","separately",".","decay",":","`","float","`",",","optional","(","default","=","`","0.9999","`",")","The","decay","rate","that","will","be","used","if","`","num_updates","`","is","not","passed","(","and","that","will","be","used","as","an","upper","bound","if","`","num_updates","`","is","passed",")",".","numerator",":","`","float","`",",","optional","(","default","=","`","1.0","`",")","The","numerator","used","to","compute","the","decay","rate","if","`","num_updates","`","is","passed",".","denominator",":","`","float","`",",","optional","(","default","=","`","10.0","`",")","The","denominator","used","to","compute","the","decay","rate","if","`","num_updates","`","is","passed","."]
docstr: Apply exponential moving average to `named_parameters` if specified,
  or we will apply this to all the trainable parameters of the model.
  
  The optional `num_updates` parameter allows one to tweak the decay rate
  dynamically. If passed, the actual decay rate used is:
  
      `min(decay, (numerator + num_updates) / (denominator + num_updates))`
  
  (This logic is based on the Tensorflow exponential moving average
   <https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage>)
docstr_tok: ["Apply","exponential","moving","average","to","`","named_parameters","`","if","specified",",","or","we","will","apply","this","to","all","the","trainable","parameters","of","the","model",".","The","optional","`","num_updates","`","parameter","allows","one","to","tweak","the","decay","rate","dynamically",".","If","passed",",","the","actual","decay","rate","used","is",":","`","min","(","decay",",","(","numerator","+","num_updates",")","\/","(","denominator","+","num_updates",")",")","`","(","This","logic","is","based","on","the","Tensorflow","exponential","moving","average","<","https",":","\/\/www.tensorflow.org\/api_docs\/python\/tf\/train\/ExponentialMovingAverage",">",")"]
code: def apply(self, num_updates: Optional[int] = None) -> None:
      """
      Apply exponential moving average to `named_parameters` if specified,
      or we will apply this to all the trainable parameters of the model.
  
      The optional `num_updates` parameter allows one to tweak the decay rate
      dynamically. If passed, the actual decay rate used is:
  
          `min(decay, (numerator + num_updates) / (denominator + num_updates))`
  
      (This logic is based on the Tensorflow exponential moving average
       <https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage>)
      """
      if num_updates is not None:
          decay = min(
              self._decay,
              (self._numerator + num_updates)
              / (self._denominator + num_updates),
          )
      else:
          decay = self._decay
  
      for name, parameter in self._parameters:
          self._shadows[name].mul_(decay).add_(
              (1 - decay) * parameter.data
          )
  
file_path: allennlp/allennlp/training/moving_average.py
imports: from typing import Iterable, Tuple, Optional, Any, Dict
  import torch
  from allennlp.common.registrable import Registrable
label_desc: Use image node_id 2 for calling the ExponentialMovingAverage obj's underlying member method code with example usage: obj.apply(num_updates) without return types