class_docstr: Pipeline for text-to-image generation using Stable Diffusion XL.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
  
  In addition the pipeline inherits the following loading methods:
      - *LoRA*: [`loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights`]
      - *Ckpt*: [`loaders.FromSingleFileMixin.from_single_file`]
  
  as well as the following saving methods:
      - *LoRA*: [`loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights`]
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
      text_encoder ([`CLIPTextModel`]):
          Frozen text-encoder. Stable Diffusion XL uses the text portion of
          [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), specifically
          the [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) variant.
      text_encoder_2 ([` CLIPTextModelWithProjection`]):
          Second frozen text-encoder. Stable Diffusion XL uses the text and pool portion of
          [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModelWithProjection),
          specifically the
          [laion/CLIP-ViT-bigG-14-laion2B-39B-b160k](https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k)
          variant.
      tokenizer (`CLIPTokenizer`):
          Tokenizer of class
          [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer).
      tokenizer_2 (`CLIPTokenizer`):
          Second Tokenizer of class
          [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer).
      unet ([`UNet2DConditionModel`]): Conditional U-Net architecture to denoise the encoded image latents.
      scheduler ([`SchedulerMixin`]):
          A scheduler to be used in combination with `unet` to denoise the encoded image latents. Can be one of
          [`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`].
      requires_aesthetics_score (`bool`, *optional*, defaults to `"False"`):
          Whether the `unet` requires an `aesthetic_score` condition to be passed during inference. Also see the
          config of `stabilityai/stable-diffusion-xl-refiner-1-0`.
      force_zeros_for_empty_prompt (`bool`, *optional*, defaults to `"True"`):
          Whether the negative prompt embeddings shall be forced to always be set to 0. Also see the config of
          `stabilityai/stable-diffusion-xl-base-1-0`.
      add_watermarker (`bool`, *optional*):
          Whether to use the [invisible_watermark library](https://github.com/ShieldMnt/invisible-watermark/) to
          watermark output images. If not defined, it will default to True if the package is installed, otherwise no
          watermarker will be used.
class_docstr_tok: ["Pipeline","for","text-to-image","generation","using","Stable","Diffusion","XL",".","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","the","library","implements","for","all","the","pipelines","(","such","as","downloading","or","saving",",","running","on","a","particular","device",",","etc",".",")","In","addition","the","pipeline","inherits","the","following","loading","methods",":","-","*","LoRA","*",":","[","`","loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights","`","]","-","*","Ckpt","*",":","[","`","loaders.FromSingleFileMixin.from_single_file","`","]","as","well","as","the","following","saving","methods",":","-","*","LoRA","*",":","[","`","loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights","`","]","Args",":","vae","(","[","`","AutoencoderKL","`","]",")",":","Variational","Auto-Encoder","(","VAE",")","Model","to","encode","and","decode","images","to","and","from","latent","representations",".","text_encoder","(","[","`","CLIPTextModel","`","]",")",":","Frozen","text-encoder",".","Stable","Diffusion","XL","uses","the","text","portion","of","[","CLIP","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/clip","#","transformers.CLIPTextModel",")",",","specifically","the","[","clip-vit-large-patch14","]","(","https",":","\/\/huggingface.co\/openai\/clip-vit-large-patch14",")","variant",".","text_encoder_2","(","[","`","CLIPTextModelWithProjection","`","]",")",":","Second","frozen","text-encoder",".","Stable","Diffusion","XL","uses","the","text","and","pool","portion","of","[","CLIP","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/clip","#","transformers.CLIPTextModelWithProjection",")",",","specifically","the","[","laion\/CLIP-ViT-bigG-14-laion2B-39B-b160k","]","(","https",":","\/\/huggingface.co\/laion\/CLIP-ViT-bigG-14-laion2B-39B-b160k",")","variant",".","tokenizer","(","`","CLIPTokenizer","`",")",":","Tokenizer","of","class","[","CLIPTokenizer","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/v4.21.0\/en\/model_doc\/clip","#","transformers.CLIPTokenizer",")",".","tokenizer_2","(","`","CLIPTokenizer","`",")",":","Second","Tokenizer","of","class","[","CLIPTokenizer","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/v4.21.0\/en\/model_doc\/clip","#","transformers.CLIPTokenizer",")",".","unet","(","[","`","UNet2DConditionModel","`","]",")",":","Conditional","U-Net","architecture","to","denoise","the","encoded","image","latents",".","scheduler","(","[","`","SchedulerMixin","`","]",")",":","A","scheduler","to","be","used","in","combination","with","`","unet","`","to","denoise","the","encoded","image","latents",".","Can","be","one","of","[","`","DDIMScheduler","`","]",",","[","`","LMSDiscreteScheduler","`","]",",","or","[","`","PNDMScheduler","`","]",".","requires_aesthetics_score","(","`","bool","`",",","*","optional","*",",","defaults","to","`","``","False","''","`",")",":","Whether","the","`","unet","`","requires","an","`","aesthetic_score","`","condition","to","be","passed","during","inference",".","Also","see","the","config","of","`","stabilityai\/stable-diffusion-xl-refiner-1-0","`",".","force_zeros_for_empty_prompt","(","`","bool","`",",","*","optional","*",",","defaults","to","`","``","True","''","`",")",":","Whether","the","negative","prompt","embeddings","shall","be","forced","to","always","be","set","to","0",".","Also","see","the","config","of","`","stabilityai\/stable-diffusion-xl-base-1-0","`",".","add_watermarker","(","`","bool","`",",","*","optional","*",")",":","Whether","to","use","the","[","invisible_watermark","library","]","(","https",":","\/\/github.com\/ShieldMnt\/invisible-watermark\/",")","to","watermark","output","images",".","If","not","defined",",","it","will","default","to","True","if","the","package","is","installed",",","otherwise","no","watermarker","will","be","used","."]
code: def get_timesteps(
      self, num_inference_steps, strength, device, denoising_start=None
  ):
      # get the original timestep using init_timestep
      if denoising_start is None:
          init_timestep = min(
              int(num_inference_steps * strength), num_inference_steps
          )
          t_start = max(num_inference_steps - init_timestep, 0)
      else:
          t_start = 0
  
      timesteps = self.scheduler.timesteps[
          t_start * self.scheduler.order :
      ]
  
      # Strength is irrelevant if we directly request a timestep to start at;
      # that is, strength is determined by the denoising_start instead.
      if denoising_start is not None:
          discrete_timestep_cutoff = int(
              round(
                  self.scheduler.config.num_train_timesteps
                  - (
                      denoising_start
                      * self.scheduler.config.num_train_timesteps
                  )
              )
          )
          timesteps = list(
              filter(
                  lambda ts: ts < discrete_timestep_cutoff, timesteps
              )
          )
          return torch.tensor(timesteps), len(timesteps)
  
      return timesteps, num_inference_steps - t_start
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import PIL.Image
  import torch
  from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
  from ...image_processor import PipelineImageInput, VaeImageProcessor
  from ...loaders import FromSingleFileMixin, StableDiffusionXLLoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AutoencoderKL, UNet2DConditionModel
  from ...models.attention_processor import AttnProcessor2_0, LoRAAttnProcessor2_0, LoRAXFormersAttnProcessor, XFormersAttnProcessor
  from ...models.lora import adjust_lora_scale_text_encoder
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import USE_PEFT_BACKEND, is_invisible_watermark_available, is_torch_xla_available, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from .pipeline_output import StableDiffusionXLPipelineOutput
label_desc: Use image node_id 9 for calling the StableDiffusionXLImg2ImgPipeline obj's underlying member method code with example usage: obj.get_timesteps(num_inference_steps, strength, device, denoising_start) and returns: timesteps,  unknown, torch,  len