class_docstr: Pipeline for text-to-image generation using Stable Diffusion XL with ControlNet guidance.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
  
  The pipeline also inherits the following loading methods:
      - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
      - [`~loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
      - [`~loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
      - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
      - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
      text_encoder ([`~transformers.CLIPTextModel`]):
          Frozen text-encoder ([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)).
      text_encoder_2 ([`~transformers.CLIPTextModelWithProjection`]):
          Second frozen text-encoder
          ([laion/CLIP-ViT-bigG-14-laion2B-39B-b160k](https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k)).
      tokenizer ([`~transformers.CLIPTokenizer`]):
          A `CLIPTokenizer` to tokenize text.
      tokenizer_2 ([`~transformers.CLIPTokenizer`]):
          A `CLIPTokenizer` to tokenize text.
      unet ([`UNet2DConditionModel`]):
          A `UNet2DConditionModel` to denoise the encoded image latents.
      controlnet ([`ControlNetModel`] or `List[ControlNetModel]`):
          Provides additional conditioning to the `unet` during the denoising process. If you set multiple
          ControlNets as a list, the outputs from each ControlNet are added together to create one combined
          additional conditioning.
      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`].
      force_zeros_for_empty_prompt (`bool`, *optional*, defaults to `"True"`):
          Whether the negative prompt embeddings should 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](https://github.com/ShieldMnt/invisible-watermark/) library to
          watermark output images. If not defined, it defaults to `True` if the package is installed; otherwise no
          watermarker is used.
class_docstr_tok: ["Pipeline","for","text-to-image","generation","using","Stable","Diffusion","XL","with","ControlNet","guidance",".","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","implemented","for","all","pipelines","(","downloading",",","saving",",","running","on","a","particular","device",",","etc.",")",".","The","pipeline","also","inherits","the","following","loading","methods",":","-","[","`","~loaders.TextualInversionLoaderMixin.load_textual_inversion","`","]","for","loading","textual","inversion","embeddings","-","[","`","~loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights","`","]","for","loading","LoRA","weights","-","[","`","~loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights","`","]","for","saving","LoRA","weights","-","[","`","~loaders.FromSingleFileMixin.from_single_file","`","]","for","loading","`",".ckpt","`","files","-","[","`","~loaders.IPAdapterMixin.load_ip_adapter","`","]","for","loading","IP","Adapters","Args",":","vae","(","[","`","AutoencoderKL","`","]",")",":","Variational","Auto-Encoder","(","VAE",")","model","to","encode","and","decode","images","to","and","from","latent","representations",".","text_encoder","(","[","`","~transformers.CLIPTextModel","`","]",")",":","Frozen","text-encoder","(","[","clip-vit-large-patch14","]","(","https",":","\/\/huggingface.co\/openai\/clip-vit-large-patch14",")",")",".","text_encoder_2","(","[","`","~transformers.CLIPTextModelWithProjection","`","]",")",":","Second","frozen","text-encoder","(","[","laion\/CLIP-ViT-bigG-14-laion2B-39B-b160k","]","(","https",":","\/\/huggingface.co\/laion\/CLIP-ViT-bigG-14-laion2B-39B-b160k",")",")",".","tokenizer","(","[","`","~transformers.CLIPTokenizer","`","]",")",":","A","`","CLIPTokenizer","`","to","tokenize","text",".","tokenizer_2","(","[","`","~transformers.CLIPTokenizer","`","]",")",":","A","`","CLIPTokenizer","`","to","tokenize","text",".","unet","(","[","`","UNet2DConditionModel","`","]",")",":","A","`","UNet2DConditionModel","`","to","denoise","the","encoded","image","latents",".","controlnet","(","[","`","ControlNetModel","`","]","or","`","List","[","ControlNetModel","]","`",")",":","Provides","additional","conditioning","to","the","`","unet","`","during","the","denoising","process",".","If","you","set","multiple","ControlNets","as","a","list",",","the","outputs","from","each","ControlNet","are","added","together","to","create","one","combined","additional","conditioning",".","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","`","]",".","force_zeros_for_empty_prompt","(","`","bool","`",",","*","optional","*",",","defaults","to","`","``","True","''","`",")",":","Whether","the","negative","prompt","embeddings","should","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","]","(","https",":","\/\/github.com\/ShieldMnt\/invisible-watermark\/",")","library","to","watermark","output","images",".","If","not","defined",",","it","defaults","to","`","True","`","if","the","package","is","installed",";","otherwise","no","watermarker","is","used","."]
docstr: See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
  
  Args:
      timesteps (`torch.Tensor`):
          generate embedding vectors at these timesteps
      embedding_dim (`int`, *optional*, defaults to 512):
          dimension of the embeddings to generate
      dtype:
          data type of the generated embeddings
  
  Returns:
      `torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
docstr_tok: ["See","https",":","\/\/github.com\/google-research\/vdm\/blob\/dc27b98a554f65cdc654b800da5aa1846545d41b\/model_vdm.py","#","L298","Args",":","timesteps","(","`","torch.Tensor","`",")",":","generate","embedding","vectors","at","these","timesteps","embedding_dim","(","`","int","`",",","*","optional","*",",","defaults","to","512",")",":","dimension","of","the","embeddings","to","generate","dtype",":","data","type","of","the","generated","embeddings","Returns",":","`","torch.FloatTensor","`",":","Embedding","vectors","with","shape","`","(","len","(","timesteps",")",",","embedding_dim",")","`"]
code: def get_guidance_scale_embedding(
      self, w, embedding_dim=512, dtype=torch.float32
  ):
      """
      See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
  
      Args:
          timesteps (`torch.Tensor`):
              generate embedding vectors at these timesteps
          embedding_dim (`int`, *optional*, defaults to 512):
              dimension of the embeddings to generate
          dtype:
              data type of the generated embeddings
  
      Returns:
          `torch.FloatTensor`: Embedding vectors with shape `(len(timesteps), embedding_dim)`
      """
      assert len(w.shape) == 1
      w = w * 1000.0
  
      half_dim = embedding_dim // 2
      emb = torch.log(torch.tensor(10000.0)) / (half_dim - 1)
      emb = torch.exp(torch.arange(half_dim, dtype=dtype) * -emb)
      emb = w.to(dtype)[:, None] * emb[None, :]
      emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1)
      if embedding_dim % 2 == 1:  # zero pad
          emb = torch.nn.functional.pad(emb, (0, 1))
      assert emb.shape == (w.shape[0], embedding_dim)
      return emb
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import PIL.Image
  import torch
  import torch.nn.functional
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionModelWithProjection
  from diffusers.utils.import_utils import is_invisible_watermark_available
  from ...image_processor import PipelineImageInput, VaeImageProcessor
  from ...loaders import FromSingleFileMixin, IPAdapterMixin, StableDiffusionXLLoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AutoencoderKL, ControlNetModel, ImageProjection, 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, deprecate, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import is_compiled_module, is_torch_version, randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from ..stable_diffusion_xl.pipeline_output import StableDiffusionXLPipelineOutput
  from .multicontrolnet import MultiControlNetModel
label_desc: Use image node_id 17 for calling the StableDiffusionXLControlNetPipeline obj's underlying member method code with example usage: obj.get_guidance_scale_embedding(w, embedding_dim, dtype) and returns: emb