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: Offloads all models to CPU using 🤗 Accelerate, significantly reducing memory usage. When called, the state
  dicts of all `torch.nn.Module` components (except those in `self._exclude_from_cpu_offload`) are saved to CPU
  and then moved to `torch.device('meta')` and loaded to GPU only when their specific submodule has its `forward`
  method called. Offloading happens on a submodule basis. Memory savings are higher than with
  `enable_model_cpu_offload`, but performance is lower.
  
  Arguments:
      gpu_id (`int`, *optional*):
          The ID of the accelerator that shall be used in inference. If not specified, it will default to 0.
      device (`torch.Device` or `str`, *optional*, defaults to "cuda"):
          The PyTorch device type of the accelerator that shall be used in inference. If not specified, it will
          default to "cuda".
docstr_tok: ["Offloads","all","models","to","CPU","using","\ud83e\udd17","Accelerate",",","significantly","reducing","memory","usage",".","When","called",",","the","state","dicts","of","all","`","torch.nn.Module","`","components","(","except","those","in","`","self._exclude_from_cpu_offload","`",")","are","saved","to","CPU","and","then","moved","to","`","torch.device","(","'meta","'",")","`","and","loaded","to","GPU","only","when","their","specific","submodule","has","its","`","forward","`","method","called",".","Offloading","happens","on","a","submodule","basis",".","Memory","savings","are","higher","than","with","`","enable_model_cpu_offload","`",",","but","performance","is","lower",".","Arguments",":","gpu_id","(","`","int","`",",","*","optional","*",")",":","The","ID","of","the","accelerator","that","shall","be","used","in","inference",".","If","not","specified",",","it","will","default","to","0.","device","(","`","torch.Device","`","or","`","str","`",",","*","optional","*",",","defaults","to","``","cuda","''",")",":","The","PyTorch","device","type","of","the","accelerator","that","shall","be","used","in","inference",".","If","not","specified",",","it","will","default","to","``","cuda","''","."]
code: def enable_sequential_cpu_offload(
      self,
      gpu_id: Optional[int] = None,
      device: Union[torch.device, str] = "cuda",
  ):
      r"""
      Offloads all models to CPU using 🤗 Accelerate, significantly reducing memory usage. When called, the state
      dicts of all `torch.nn.Module` components (except those in `self._exclude_from_cpu_offload`) are saved to CPU
      and then moved to `torch.device('meta')` and loaded to GPU only when their specific submodule has its `forward`
      method called. Offloading happens on a submodule basis. Memory savings are higher than with
      `enable_model_cpu_offload`, but performance is lower.
  
      Arguments:
          gpu_id (`int`, *optional*):
              The ID of the accelerator that shall be used in inference. If not specified, it will default to 0.
          device (`torch.Device` or `str`, *optional*, defaults to "cuda"):
              The PyTorch device type of the accelerator that shall be used in inference. If not specified, it will
              default to "cuda".
      """
      if is_accelerate_available() and is_accelerate_version(
          ">=", "0.14.0"
      ):
          from accelerate import cpu_offload
      else:
          raise ImportError(
              "`enable_sequential_cpu_offload` requires `accelerate v0.14.0` or higher"
          )
  
      torch_device = torch.device(device)
      device_index = torch_device.index
  
      if gpu_id is not None and device_index is not None:
          raise ValueError(
              f"You have passed both `gpu_id`={gpu_id} and an index as part of the passed device `device`={device}"
              f"Cannot pass both. Please make sure to either not define `gpu_id` or not pass the index as part of the device: `device`={torch_device.type}"
          )
  
      # _offload_gpu_id should be set to passed gpu_id (or id in passed `device`) or default to previously set id or default to 0
      self._offload_gpu_id = (
          gpu_id
          or torch_device.index
          or getattr(self, "_offload_gpu_id", 0)
      )
  
      device_type = torch_device.type
      device = torch.device(f"{device_type}:{self._offload_gpu_id}")
  
      if self.device.type != "cpu":
          self.to("cpu", silence_dtype_warnings=True)
          device_mod = getattr(torch, self.device.type, None)
          if (
              hasattr(device_mod, "empty_cache")
              and device_mod.is_available()
          ):
              device_mod.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)
  
      for name, model in self.components.items():
          if not isinstance(model, torch.nn.Module):
              continue
  
          if name in self._exclude_from_cpu_offload:
              model.to(device)
          else:
              # make sure to offload buffers if not all high level weights
              # are of type nn.Module
              offload_buffers = len(model._parameters) > 0
              cpu_offload(
                  model, device, offload_buffers=offload_buffers
              )
  
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 12 for calling the DiffusionPipeline obj's underlying member method code with example usage: obj.enable_sequential_cpu_offload(gpu_id, device) without return types