class_docstr: Exponential Moving Average of models weights
class_docstr_tok: ["Exponential","Moving","Average","of","models","weights"]
code: def step(self, parameters: Iterable[torch.nn.Parameter]):
      if isinstance(parameters, torch.nn.Module):
          deprecation_message = (
              "Passing a `torch.nn.Module` to `ExponentialMovingAverage.step` is deprecated. "
              "Please pass the parameters of the module instead."
          )
          deprecate(
              "passing a `torch.nn.Module` to `ExponentialMovingAverage.step`",
              "1.0.0",
              deprecation_message,
              standard_warn=False,
          )
          parameters = parameters.parameters()
  
      parameters = list(parameters)
  
      self.optimization_step += 1
  
      # Compute the decay factor for the exponential moving average.
      decay = self.get_decay(self.optimization_step)
      self.cur_decay_value = decay
      one_minus_decay = 1 - decay
  
      context_manager = contextlib.nullcontext
      if (
          is_transformers_available()
          and transformers.deepspeed.is_deepspeed_zero3_enabled()
      ):
          import deepspeed
  
      for s_param, param in zip(self.shadow_params, parameters):
          if (
              is_transformers_available()
              and transformers.deepspeed.is_deepspeed_zero3_enabled()
          ):
              context_manager = deepspeed.zero.GatheredParameters(
                  param, modifier_rank=None
              )
  
          with context_manager():
              if param.requires_grad:
                  s_param.sub_(one_minus_decay * (s_param - param))
              else:
                  s_param.copy_(param)
  
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 5 for calling the EMAModel obj's underlying member method code with example usage: obj.step(parameters) without return types