code: def test_exponential_moving_average_num_updates(self):
      param1 = torch.ones(5, 3)
      param2 = torch.ones(2)
      moving_average = ExponentialMovingAverage(
          [("param1", param1), ("param2", param2)], decay=0.9999
      )
  
      param1.data *= 5  # now all 5s
      param2.data *= 10  # now all 10s
      moving_average.apply(num_updates=100)  # 101 / 110 ~ 0.92 < 0.9999
  
      param1.data *= 5  # now all 25s
      param2.data *= 10  # now all 100s
      moving_average.apply(
          num_updates=1_000_000
      )  # 1_000_001 / 1_000_010 ~ .999991 > .9999
  
      # Get shadow variables
      moving_average.assign_average_value()
  
      np.testing.assert_array_almost_equal(
          param1,
          1 * (101 / 110) * 0.9999
          + 5 * (9 / 110) * 0.9999
          + 25 * 0.0001,
      )
  
      np.testing.assert_array_almost_equal(
          param2,
          1 * (101 / 110) * 0.9999
          + 10 * (9 / 110) * 0.9999
          + 100 * 0.0001,
      )
  
      # Restore original variables
      moving_average.restore()
      np.testing.assert_array_almost_equal(param1, 25)
      np.testing.assert_array_almost_equal(param2, 100)
  
file_path: allennlp/tests/training/moving_average_test.py
imports: from typing import Dict
  import torch
  import numpy
  from allennlp.common.params import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.models.model import Model
  from allennlp.training.moving_average import MovingAverage, ExponentialMovingAverage
label_desc: Use image node_id 3 for calling the MovingAverageTest obj's underlying member method code with example usage: obj.test_exponential_moving_average_num_updates() without return types