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: Performs Pipeline dtype and/or device conversion. A torch.dtype and torch.device are inferred from the
  arguments of `self.to(*args, **kwargs).`
  
  <Tip>
  
      If the pipeline already has the correct torch.dtype and torch.device, then it is returned as is. Otherwise,
      the returned pipeline is a copy of self with the desired torch.dtype and torch.device.
  
  </Tip>
  
  
  Here are the ways to call `to`:
  
  - `to(dtype, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the specified
    [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
  - `to(device, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the specified
    [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)
  - `to(device=None, dtype=None, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the
    specified [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device) and
    [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
  
  Arguments:
      dtype (`torch.dtype`, *optional*):
          Returns a pipeline with the specified
          [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
      device (`torch.Device`, *optional*):
          Returns a pipeline with the specified
          [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)
      silence_dtype_warnings (`str`, *optional*, defaults to `False`):
          Whether to omit warnings if the target `dtype` is not compatible with the target `device`.
  
  Returns:
      [`DiffusionPipeline`]: The pipeline converted to specified `dtype` and/or `dtype`.
docstr_tok: ["Performs","Pipeline","dtype","and\/or","device","conversion",".","A","torch.dtype","and","torch.device","are","inferred","from","the","arguments","of","`","self.to","(","*","args",",","*","*","kwargs",")",".","`","<","Tip",">","If","the","pipeline","already","has","the","correct","torch.dtype","and","torch.device",",","then","it","is","returned","as","is",".","Otherwise",",","the","returned","pipeline","is","a","copy","of","self","with","the","desired","torch.dtype","and","torch.device",".","<","\/Tip",">","Here","are","the","ways","to","call","`","to","`",":","-","`","to","(","dtype",",","silence_dtype_warnings=False",")","\u2192","DiffusionPipeline","`","to","return","a","pipeline","with","the","specified","[","`","dtype","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.dtype",")","-","`","to","(","device",",","silence_dtype_warnings=False",")","\u2192","DiffusionPipeline","`","to","return","a","pipeline","with","the","specified","[","`","device","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.device",")","-","`","to","(","device=None",",","dtype=None",",","silence_dtype_warnings=False",")","\u2192","DiffusionPipeline","`","to","return","a","pipeline","with","the","specified","[","`","device","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.device",")","and","[","`","dtype","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.dtype",")","Arguments",":","dtype","(","`","torch.dtype","`",",","*","optional","*",")",":","Returns","a","pipeline","with","the","specified","[","`","dtype","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.dtype",")","device","(","`","torch.Device","`",",","*","optional","*",")",":","Returns","a","pipeline","with","the","specified","[","`","device","`","]","(","https",":","\/\/pytorch.org\/docs\/stable\/tensor_attributes.html","#","torch.device",")","silence_dtype_warnings","(","`","str","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","omit","warnings","if","the","target","`","dtype","`","is","not","compatible","with","the","target","`","device","`",".","Returns",":","[","`","DiffusionPipeline","`","]",":","The","pipeline","converted","to","specified","`","dtype","`","and\/or","`","dtype","`","."]
code: def to(self, *args, **kwargs):
      r"""
      Performs Pipeline dtype and/or device conversion. A torch.dtype and torch.device are inferred from the
      arguments of `self.to(*args, **kwargs).`
  
      <Tip>
  
          If the pipeline already has the correct torch.dtype and torch.device, then it is returned as is. Otherwise,
          the returned pipeline is a copy of self with the desired torch.dtype and torch.device.
  
      </Tip>
  
  
      Here are the ways to call `to`:
  
      - `to(dtype, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the specified
        [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
      - `to(device, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the specified
        [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)
      - `to(device=None, dtype=None, silence_dtype_warnings=False) → DiffusionPipeline` to return a pipeline with the
        specified [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device) and
        [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
  
      Arguments:
          dtype (`torch.dtype`, *optional*):
              Returns a pipeline with the specified
              [`dtype`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype)
          device (`torch.Device`, *optional*):
              Returns a pipeline with the specified
              [`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)
          silence_dtype_warnings (`str`, *optional*, defaults to `False`):
              Whether to omit warnings if the target `dtype` is not compatible with the target `device`.
  
      Returns:
          [`DiffusionPipeline`]: The pipeline converted to specified `dtype` and/or `dtype`.
      """
  
      torch_dtype = kwargs.pop("torch_dtype", None)
      if torch_dtype is not None:
          deprecate("torch_dtype", "0.27.0", "")
      torch_device = kwargs.pop("torch_device", None)
      if torch_device is not None:
          deprecate("torch_device", "0.27.0", "")
  
      dtype_kwarg = kwargs.pop("dtype", None)
      device_kwarg = kwargs.pop("device", None)
      silence_dtype_warnings = kwargs.pop(
          "silence_dtype_warnings", False
      )
  
      if torch_dtype is not None and dtype_kwarg is not None:
          raise ValueError(
              "You have passed both `torch_dtype` and `dtype` as a keyword argument. Please make sure to only pass `dtype`."
          )
  
      dtype = torch_dtype or dtype_kwarg
  
      if torch_device is not None and device_kwarg is not None:
          raise ValueError(
              "You have passed both `torch_device` and `device` as a keyword argument. Please make sure to only pass `device`."
          )
  
      device = torch_device or device_kwarg
  
      dtype_arg = None
      device_arg = None
      if len(args) == 1:
          if isinstance(args[0], torch.dtype):
              dtype_arg = args[0]
          else:
              device_arg = (
                  torch.device(args[0]) if args[0] is not None else None
              )
      elif len(args) == 2:
          if isinstance(args[0], torch.dtype):
              raise ValueError(
                  "When passing two arguments, make sure the first corresponds to `device` and the second to `dtype`."
              )
          device_arg = (
              torch.device(args[0]) if args[0] is not None else None
          )
          dtype_arg = args[1]
      elif len(args) > 2:
          raise ValueError(
              "Please make sure to pass at most two arguments (`device` and `dtype`) `.to(...)`"
          )
  
      if dtype is not None and dtype_arg is not None:
          raise ValueError(
              "You have passed `dtype` both as an argument and as a keyword argument. Please only pass one of the two."
          )
  
      dtype = dtype or dtype_arg
  
      if device is not None and device_arg is not None:
          raise ValueError(
              "You have passed `device` both as an argument and as a keyword argument. Please only pass one of the two."
          )
  
      device = device or device_arg
  
      # throw warning if pipeline is in "offloaded"-mode but user tries to manually set to GPU.
      def module_is_sequentially_offloaded(module):
          if not is_accelerate_available() or is_accelerate_version(
              "<", "0.14.0"
          ):
              return False
  
          return hasattr(module, "_hf_hook") and not isinstance(
              module._hf_hook,
              (
                  accelerate.hooks.CpuOffload,
                  accelerate.hooks.AlignDevicesHook,
              ),
          )
  
      def module_is_offloaded(module):
          if not is_accelerate_available() or is_accelerate_version(
              "<", "0.17.0.dev0"
          ):
              return False
  
          return hasattr(module, "_hf_hook") and isinstance(
              module._hf_hook, accelerate.hooks.CpuOffload
          )
  
      # .to("cuda") would raise an error if the pipeline is sequentially offloaded, so we raise our own to make it clearer
      pipeline_is_sequentially_offloaded = any(
          module_is_sequentially_offloaded(module)
          for _, module in self.components.items()
      )
      if (
          pipeline_is_sequentially_offloaded
          and device
          and torch.device(device).type == "cuda"
      ):
          raise ValueError(
              "It seems like you have activated sequential model offloading by calling `enable_sequential_cpu_offload`, but are now attempting to move the pipeline to GPU. This is not compatible with offloading. Please, move your pipeline `.to('cpu')` or consider removing the move altogether if you use sequential offloading."
          )
  
      # Display a warning in this case (the operation succeeds but the benefits are lost)
      pipeline_is_offloaded = any(
          module_is_offloaded(module)
          for _, module in self.components.items()
      )
      if (
          pipeline_is_offloaded
          and device
          and torch.device(device).type == "cuda"
      ):
          logger.warning(
              f"It seems like you have activated model offloading by calling `enable_model_cpu_offload`, but are now manually moving the pipeline to GPU. It is strongly recommended against doing so as memory gains from offloading are likely to be lost. Offloading automatically takes care of moving the individual components {', '.join(self.components.keys())} to GPU when needed. To make sure offloading works as expected, you should consider moving the pipeline back to CPU: `pipeline.to('cpu')` or removing the move altogether if you use offloading."
          )
  
      module_names, _ = self._get_signature_keys(self)
      modules = [getattr(self, n, None) for n in module_names]
      modules = [m for m in modules if isinstance(m, torch.nn.Module)]
  
      is_offloaded = (
          pipeline_is_offloaded or pipeline_is_sequentially_offloaded
      )
      for module in modules:
          is_loaded_in_8bit = (
              hasattr(module, "is_loaded_in_8bit")
              and module.is_loaded_in_8bit
          )
  
          if is_loaded_in_8bit and dtype is not None:
              logger.warning(
                  f"The module '{module.__class__.__name__}' has been loaded in 8bit and conversion to {torch_dtype} is not yet supported. Module is still in 8bit precision."
              )
  
          if is_loaded_in_8bit and device is not None:
              logger.warning(
                  f"The module '{module.__class__.__name__}' has been loaded in 8bit and moving it to {torch_dtype} via `.to()` is not yet supported. Module is still on {module.device}."
              )
          else:
              module.to(device, dtype)
  
          if (
              module.dtype == torch.float16
              and str(device) in ["cpu"]
              and not silence_dtype_warnings
              and not is_offloaded
          ):
              logger.warning(
                  "Pipelines loaded with `dtype=torch.float16` cannot run with `cpu` device. It"
                  " is not recommended to move them to `cpu` as running them will fail. Please make"
                  " sure to use an accelerator to run the pipeline in inference, due to the lack of"
                  " support for`float16` operations on this device in PyTorch. Please, remove the"
                  " `torch_dtype=torch.float16` argument, or use another device for inference."
              )
      return self
  
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 requests
  import torch
  from huggingface_hub import ModelCard, create_repo, hf_hub_download, model_info, snapshot_download
  from huggingface_hub.utils import OfflineModeIsEnabled, validate_hf_hub_args
  from packaging import version
  from requests.exceptions import HTTPError
  from tqdm.auto import tqdm
  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, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME, BaseOutput, deprecate, get_class_from_dynamic_module, is_accelerate_available, is_accelerate_version, is_peft_available, 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 4 for calling the DiffusionPipeline obj's underlying member method code with example usage: obj.to() and returns: self, unknown, unknown, False, False