code: def test_exponential_moving_average_without_steps(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()
  
      param1.data *= 5  # now all 25s
      param2.data *= 10  # now all 100s
      moving_average.apply()
  
      # Get shadow variables
      moving_average.assign_average_value()
  
      np.testing.assert_array_almost_equal(
          param1, 1 * 0.9999**2 + 5 * 0.9999 * 0.0001 + 25 * 0.0001
      )
      np.testing.assert_array_almost_equal(
          param2, 1 * 0.9999**2 + 10 * 0.9999 * 0.0001 + 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 2 for calling the MovingAverageTest obj's underlying member method code with example usage: obj.test_exponential_moving_average_without_steps() without return types