class_docstr: Exponential Moving Average of models weights
class_docstr_tok: ["Exponential","Moving","Average","of","models","weights"]
docstr: Args:
  Restore the parameters stored with the `store` method. Useful to validate the model with EMA parameters without:
  affecting the original optimization process. Store the parameters before the `copy_to()` method. After
  validation (or model saving), use this to restore the former parameters.
      parameters: Iterable of `torch.nn.Parameter`; the parameters to be
          updated with the stored parameters. If `None`, the parameters with which this
          `ExponentialMovingAverage` was initialized will be used.
docstr_tok: ["Args",":","Restore","the","parameters","stored","with","the","`","store","`","method",".","Useful","to","validate","the","model","with","EMA","parameters","without",":","affecting","the","original","optimization","process",".","Store","the","parameters","before","the","`","copy_to","(",")","`","method",".","After","validation","(","or","model","saving",")",",","use","this","to","restore","the","former","parameters",".","parameters",":","Iterable","of","`","torch.nn.Parameter","`",";","the","parameters","to","be","updated","with","the","stored","parameters",".","If","`","None","`",",","the","parameters","with","which","this","`","ExponentialMovingAverage","`","was","initialized","will","be","used","."]
code: def restore(self, parameters: Iterable[torch.nn.Parameter]) -> None:
      r"""
      Args:
      Restore the parameters stored with the `store` method. Useful to validate the model with EMA parameters without:
      affecting the original optimization process. Store the parameters before the `copy_to()` method. After
      validation (or model saving), use this to restore the former parameters.
          parameters: Iterable of `torch.nn.Parameter`; the parameters to be
              updated with the stored parameters. If `None`, the parameters with which this
              `ExponentialMovingAverage` was initialized will be used.
      """
      if self.temp_stored_params is None:
          raise RuntimeError(
              "This ExponentialMovingAverage has no `store()`ed weights "
              "to `restore()`"
          )
      for c_param, param in zip(self.temp_stored_params, parameters):
          param.data.copy_(c_param.data)
  
      # Better memory-wise.
      self.temp_stored_params = None
  
imports: import contextlib
  import copy
  import random
  from typing import Any, Dict, Iterable, List, Optional, Union
  import numpy
  import torch
  from torchvision import transforms
  from .models import UNet2DConditionModel
  from .utils import convert_state_dict_to_diffusers, convert_state_dict_to_peft, deprecate, is_peft_available, is_transformers_available
label_desc: Use image node_id 10 for calling the EMAModel obj's underlying member method code with example usage: obj.restore(parameters) without return types