class_docstr: Optimizer that computes a moving average of the variables.
  
  Empirically it has been found that using the moving average of the trained
  parameters of a deep network is better than using its trained parameters
  directly. This optimizer allows you to compute this moving average and swap
  the variables at save time so that any code outside of the training loop
  will use by default the average values instead of the original ones.
  
  Example of usage:
  
  ```python
  opt = tf.keras.optimizers.SGD(learning_rate)
  opt = tfa.optimizers.MovingAverage(opt)
  
  ```
class_docstr_tok: ["Optimizer","that","computes","a","moving","average","of","the","variables",".","Empirically","it","has","been","found","that","using","the","moving","average","of","the","trained","parameters","of","a","deep","network","is","better","than","using","its","trained","parameters","directly",".","This","optimizer","allows","you","to","compute","this","moving","average","and","swap","the","variables","at","save","time","so","that","any","code","outside","of","the","training","loop","will","use","by","default","the","average","values","instead","of","the","original","ones",".","Example","of","usage",":","``","`","python","opt","=","tf.keras.optimizers.SGD","(","learning_rate",")","opt","=","tfa.optimizers.MovingAverage","(","opt",")","``","`"]
docstr: Creates shadow variables for the given model weights.
docstr_tok: ["Creates","shadow","variables","for","the","given","model","weights","."]
code: def shadow_copy(self, model_weights):
      """Creates shadow variables for the given model weights."""
      for var in model_weights:
          self.add_slot(var, "average", initializer="zeros")
      self._average_weights = [
          self.get_slot(var, "average") for var in model_weights
      ]
      self._model_weights = model_weights
  
file_path: addons/tensorflow_addons/optimizers/moving_average.py
imports: import tensorflow
  from tensorflow_addons.optimizers import AveragedOptimizerWrapper
  from tensorflow_addons.utils import types
  from typing import Union
  from typeguard import typechecked
label_desc: Use image node_id 7 for calling the MovingAverage obj's underlying member method code with example usage: obj.shadow_copy(model_weights) without return types