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*: [`StableDiffusionXLPipeline.load_lora_weights`]
      - *Ckpt*: [`loaders.FromSingleFileMixin.from_single_file`]
  
  as well as the following saving methods:
      - *LoRA*: [`loaders.StableDiffusionXLPipeline.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`].
code: def save_lora_weights(
      self,
      save_directory: Union[str, os.PathLike],
      unet_lora_layers: Dict[
          str, Union[torch.nn.Module, torch.Tensor]
      ] = None,
      text_encoder_lora_layers: Dict[
          str, Union[torch.nn.Module, torch.Tensor]
      ] = None,
      text_encoder_2_lora_layers: Dict[
          str, Union[torch.nn.Module, torch.Tensor]
      ] = None,
      is_main_process: bool = True,
      weight_name: str = None,
      save_function: Callable = None,
      safe_serialization: bool = False,
  ):
      state_dict = {}
  
      def pack_weights(layers, prefix):
          layers_weights = (
              layers.state_dict()
              if isinstance(layers, torch.nn.Module)
              else layers
          )
          layers_state_dict = {
              f"{prefix}.{module_name}": param
              for module_name, param in layers_weights.items()
          }
          return layers_state_dict
  
      state_dict.update(pack_weights(unet_lora_layers, "unet"))
  
      if text_encoder_lora_layers and text_encoder_2_lora_layers:
          state_dict.update(
              pack_weights(text_encoder_lora_layers, "text_encoder")
          )
          state_dict.update(
              pack_weights(text_encoder_2_lora_layers, "text_encoder_2")
          )
  
      self.write_lora_layers(
          state_dict=state_dict,
          save_directory=save_directory,
          is_main_process=is_main_process,
          weight_name=weight_name,
          save_function=save_function,
          safe_serialization=safe_serialization,
      )
  
imports: import inspect
  import os
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
  from diffusers import DiffusionPipeline, StableDiffusionXLPipeline
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
  from diffusers.models.attention_processor import AttnProcessor2_0, LoRAAttnProcessor2_0, LoRAXFormersAttnProcessor, XFormersAttnProcessor
  from diffusers.pipelines.stable_diffusion_xl import StableDiffusionXLPipelineOutput
  from diffusers.schedulers import KarrasDiffusionSchedulers
  from diffusers.utils import is_accelerate_available, is_accelerate_version, is_invisible_watermark_available, logging, replace_example_docstring
  from diffusers.utils.torch_utils import randn_tensor
label_desc: Use image node_id 15 for calling the SDXLLongPromptWeightingPipeline obj's underlying member method code with example usage: obj.save_lora_weights(save_directory, unet_lora_layers, text_encoder_lora_layers, text_encoder_2_lora_layers, is_main_process, weight_name, save_function, safe_serialization) and returns: layers_state_dict