class_docstr: Base class for all pipelines.
  
  [`DiffusionPipeline`] stores all components (models, schedulers, and processors) for diffusion pipelines and
  provides methods for loading, downloading and saving models. It also includes methods to:
  
      - move all PyTorch modules to the device of your choice
      - enable/disable the progress bar for the denoising iteration
  
  Class attributes:
  
      - **config_name** (`str`) -- The configuration filename that stores the class and module names of all the
        diffusion pipeline's components.
      - **_optional_components** (`List[str]`) -- List of all optional components that don't have to be passed to the
        pipeline to function (should be overridden by subclasses).
class_docstr_tok: ["Base","class","for","all","pipelines",".","[","`","DiffusionPipeline","`","]","stores","all","components","(","models",",","schedulers",",","and","processors",")","for","diffusion","pipelines","and","provides","methods","for","loading",",","downloading","and","saving","models",".","It","also","includes","methods","to",":","-","move","all","PyTorch","modules","to","the","device","of","your","choice","-","enable\/disable","the","progress","bar","for","the","denoising","iteration","Class","attributes",":","-","*","*","config_name","*","*","(","`","str","`",")","--","The","configuration","filename","that","stores","the","class","and","module","names","of","all","the","diffusion","pipeline","'s","components",".","-","*","*","_optional_components","*","*","(","`","List","[","str","]","`",")","--","List","of","all","optional","components","that","do","n't","have","to","be","passed","to","the","pipeline","to","function","(","should","be","overridden","by","subclasses",")","."]
docstr: Save all saveable variables of the pipeline to a directory. A pipeline variable can be saved and loaded if its
  class implements both a save and loading method. The pipeline is easily reloaded using the
  [`~DiffusionPipeline.from_pretrained`] class method.
  
  Arguments:
      save_directory (`str` or `os.PathLike`):
          Directory to save a pipeline to. Will be created if it doesn't exist.
      safe_serialization (`bool`, *optional*, defaults to `True`):
          Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`.
      variant (`str`, *optional*):
          If specified, weights are saved in the format `pytorch_model.<variant>.bin`.
      push_to_hub (`bool`, *optional*, defaults to `False`):
          Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
          repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
          namespace).
      kwargs (`Dict[str, Any]`, *optional*):
          Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
code: def save_pretrained(
      self,
      save_directory: Union[str, os.PathLike],
      safe_serialization: bool = True,
      variant: Optional[str] = None,
      push_to_hub: bool = False,
      **kwargs,
  ):
      """
      Save all saveable variables of the pipeline to a directory. A pipeline variable can be saved and loaded if its
      class implements both a save and loading method. The pipeline is easily reloaded using the
      [`~DiffusionPipeline.from_pretrained`] class method.
  
      Arguments:
          save_directory (`str` or `os.PathLike`):
              Directory to save a pipeline to. Will be created if it doesn't exist.
          safe_serialization (`bool`, *optional*, defaults to `True`):
              Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`.
          variant (`str`, *optional*):
              If specified, weights are saved in the format `pytorch_model.<variant>.bin`.
          push_to_hub (`bool`, *optional*, defaults to `False`):
              Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
              repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
              namespace).
          kwargs (`Dict[str, Any]`, *optional*):
              Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
      """
      model_index_dict = dict(self.config)
      model_index_dict.pop("_class_name", None)
      model_index_dict.pop("_diffusers_version", None)
      model_index_dict.pop("_module", None)
      model_index_dict.pop("_name_or_path", None)
  
      if push_to_hub:
          commit_message = kwargs.pop("commit_message", None)
          private = kwargs.pop("private", False)
          create_pr = kwargs.pop("create_pr", False)
          token = kwargs.pop("token", None)
          repo_id = kwargs.pop(
              "repo_id", save_directory.split(os.path.sep)[-1]
          )
          repo_id = create_repo(
              repo_id, exist_ok=True, private=private, token=token
          ).repo_id
  
      expected_modules, optional_kwargs = self._get_signature_keys(self)
  
      def is_saveable_module(name, value):
          if name not in expected_modules:
              return False
          if name in self._optional_components and value[0] is None:
              return False
          return True
  
      model_index_dict = {
          k: v
          for k, v in model_index_dict.items()
          if is_saveable_module(k, v)
      }
      for pipeline_component_name in model_index_dict.keys():
          sub_model = getattr(self, pipeline_component_name)
          model_cls = sub_model.__class__
  
          # Dynamo wraps the original model in a private class.
          # I didn't find a public API to get the original class.
          if is_compiled_module(sub_model):
              sub_model = sub_model._orig_mod
              model_cls = sub_model.__class__
  
          save_method_name = None
          # search for the model's base class in LOADABLE_CLASSES
          for library_name, library_classes in LOADABLE_CLASSES.items():
              if library_name in sys.modules:
                  library = importlib.import_module(library_name)
              else:
                  logger.info(
                      f"{library_name} is not installed. Cannot save {pipeline_component_name} as {library_classes} from {library_name}"
                  )
  
              for (
                  base_class,
                  save_load_methods,
              ) in library_classes.items():
                  class_candidate = getattr(library, base_class, None)
                  if class_candidate is not None and issubclass(
                      model_cls, class_candidate
                  ):
                      # if we found a suitable base class in LOADABLE_CLASSES then grab its save method
                      save_method_name = save_load_methods[0]
                      break
              if save_method_name is not None:
                  break
  
          if save_method_name is None:
              logger.warn(
                  f"self.{pipeline_component_name}={sub_model} of type {type(sub_model)} cannot be saved."
              )
              # make sure that unsaveable components are not tried to be loaded afterward
              self.register_to_config(
                  **{pipeline_component_name: (None, None)}
              )
              continue
  
          save_method = getattr(sub_model, save_method_name)
  
          # Call the save method with the argument safe_serialization only if it's supported
          save_method_signature = inspect.signature(save_method)
          save_method_accept_safe = (
              "safe_serialization" in save_method_signature.parameters
          )
          save_method_accept_variant = (
              "variant" in save_method_signature.parameters
          )
  
          save_kwargs = {}
          if save_method_accept_safe:
              save_kwargs["safe_serialization"] = safe_serialization
          if save_method_accept_variant:
              save_kwargs["variant"] = variant
  
          save_method(
              os.path.join(save_directory, pipeline_component_name),
              **save_kwargs,
          )
  
      # finally save the config
      self.save_config(save_directory)
  
      if push_to_hub:
          self._upload_folder(
              save_directory,
              repo_id,
              token=token,
              commit_message=commit_message,
              create_pr=create_pr,
          )
  
imports: import fnmatch
  import importlib
  import inspect
  import os
  import re
  import sys
  import warnings
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from huggingface_hub import ModelCard, create_repo, hf_hub_download, model_info, snapshot_download
  from packaging import version
  from requests.exceptions import HTTPError
  from tqdm.auto import tqdm
  import diffusers
  from ..None import __version__
  from ..configuration_utils import ConfigMixin
  from ..models.modeling_utils import _LOW_CPU_MEM_USAGE_DEFAULT
  from ..schedulers.scheduling_utils import SCHEDULER_CONFIG_NAME
  from ..utils import CONFIG_NAME, DEPRECATED_REVISION_ARGS, DIFFUSERS_CACHE, HF_HUB_OFFLINE, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME, BaseOutput, deprecate, get_class_from_dynamic_module, is_accelerate_available, is_accelerate_version, is_torch_version, is_transformers_available, logging, numpy_to_pil
  from ..utils.torch_utils import is_compiled_module
  from ..utils import FLAX_WEIGHTS_NAME, ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, PushToHubMixin
label_desc: Use image node_id 3 for calling the DiffusionPipeline obj's underlying member method code with example usage: obj.save_pretrained(save_directory, safe_serialization, variant, push_to_hub) and returns: True, False, False