class_docstr: Exponential Moving Average of models weights
class_docstr_tok: ["Exponential","Moving","Average","of","models","weights"]
code: def save_pretrained(self, path):
      if self.model_cls is None:
          raise ValueError(
              "`save_pretrained` can only be used if `model_cls` was defined at __init__."
          )
  
      if self.model_config is None:
          raise ValueError(
              "`save_pretrained` can only be used if `model_config` was defined at __init__."
          )
  
      model = self.model_cls.from_config(self.model_config)
      state_dict = self.state_dict()
      state_dict.pop("shadow_params", None)
  
      model.register_to_config(**state_dict)
      self.copy_to(model.parameters())
      model.save_pretrained(path)
  
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 3 for calling the EMAModel obj's underlying member method code with example usage: obj.save_pretrained(path) without return types