class_docstr: Load LoRA layers into [`UNet2DConditionModel`] and
  [`CLIPTextModel`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel).
class_docstr_tok: ["Load","LoRA","layers","into","[","`","UNet2DConditionModel","`","]","and","[","`","CLIPTextModel","`","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/clip","#","transformers.CLIPTextModel",")","."]
docstr: Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
  `self.text_encoder`.
  
  All kwargs are forwarded to `self.lora_state_dict`.
  
  See [`~loaders.LoraLoaderMixin.lora_state_dict`] for more details on how the state dict is loaded.
  
  See [`~loaders.LoraLoaderMixin.load_lora_into_unet`] for more details on how the state dict is loaded into
  `self.unet`.
  
  See [`~loaders.LoraLoaderMixin.load_lora_into_text_encoder`] for more details on how the state dict is loaded
  into `self.text_encoder`.
  
  Parameters:
      pretrained_model_name_or_path_or_dict (`str` or `os.PathLike` or `dict`):
          See [`~loaders.LoraLoaderMixin.lora_state_dict`].
      kwargs (`dict`, *optional*):
          See [`~loaders.LoraLoaderMixin.lora_state_dict`].
      adapter_name (`str`, *optional*):
          Adapter name to be used for referencing the loaded adapter model. If not specified, it will use
          `default_{i}` where i is the total number of adapters being loaded.
docstr_tok: ["Load","LoRA","weights","specified","in","`","pretrained_model_name_or_path_or_dict","`","into","`","self.unet","`","and","`","self.text_encoder","`",".","All","kwargs","are","forwarded","to","`","self.lora_state_dict","`",".","See","[","`","~loaders.LoraLoaderMixin.lora_state_dict","`","]","for","more","details","on","how","the","state","dict","is","loaded",".","See","[","`","~loaders.LoraLoaderMixin.load_lora_into_unet","`","]","for","more","details","on","how","the","state","dict","is","loaded","into","`","self.unet","`",".","See","[","`","~loaders.LoraLoaderMixin.load_lora_into_text_encoder","`","]","for","more","details","on","how","the","state","dict","is","loaded","into","`","self.text_encoder","`",".","Parameters",":","pretrained_model_name_or_path_or_dict","(","`","str","`","or","`","os.PathLike","`","or","`","dict","`",")",":","See","[","`","~loaders.LoraLoaderMixin.lora_state_dict","`","]",".","kwargs","(","`","dict","`",",","*","optional","*",")",":","See","[","`","~loaders.LoraLoaderMixin.lora_state_dict","`","]",".","adapter_name","(","`","str","`",",","*","optional","*",")",":","Adapter","name","to","be","used","for","referencing","the","loaded","adapter","model",".","If","not","specified",",","it","will","use","`","default_","{","i","}","`","where","i","is","the","total","number","of","adapters","being","loaded","."]
code: def load_lora_weights(
      self,
      pretrained_model_name_or_path_or_dict: Union[
          str, Dict[str, torch.Tensor]
      ],
      adapter_name=None,
      **kwargs,
  ):
      """
      Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
      `self.text_encoder`.
  
      All kwargs are forwarded to `self.lora_state_dict`.
  
      See [`~loaders.LoraLoaderMixin.lora_state_dict`] for more details on how the state dict is loaded.
  
      See [`~loaders.LoraLoaderMixin.load_lora_into_unet`] for more details on how the state dict is loaded into
      `self.unet`.
  
      See [`~loaders.LoraLoaderMixin.load_lora_into_text_encoder`] for more details on how the state dict is loaded
      into `self.text_encoder`.
  
      Parameters:
          pretrained_model_name_or_path_or_dict (`str` or `os.PathLike` or `dict`):
              See [`~loaders.LoraLoaderMixin.lora_state_dict`].
          kwargs (`dict`, *optional*):
              See [`~loaders.LoraLoaderMixin.lora_state_dict`].
          adapter_name (`str`, *optional*):
              Adapter name to be used for referencing the loaded adapter model. If not specified, it will use
              `default_{i}` where i is the total number of adapters being loaded.
      """
      # First, ensure that the checkpoint is a compatible one and can be successfully loaded.
      state_dict, network_alphas = self.lora_state_dict(
          pretrained_model_name_or_path_or_dict, **kwargs
      )
  
      is_correct_format = all(
          "lora" in key for key in state_dict.keys()
      )
      if not is_correct_format:
          raise ValueError("Invalid LoRA checkpoint.")
  
      low_cpu_mem_usage = kwargs.pop(
          "low_cpu_mem_usage", _LOW_CPU_MEM_USAGE_DEFAULT
      )
  
      self.load_lora_into_unet(
          state_dict,
          network_alphas=network_alphas,
          unet=getattr(self, self.unet_name)
          if not hasattr(self, "unet")
          else self.unet,
          low_cpu_mem_usage=low_cpu_mem_usage,
          adapter_name=adapter_name,
          _pipeline=self,
      )
      self.load_lora_into_text_encoder(
          state_dict,
          network_alphas=network_alphas,
          text_encoder=getattr(self, self.text_encoder_name)
          if not hasattr(self, "text_encoder")
          else self.text_encoder,
          lora_scale=self.lora_scale,
          low_cpu_mem_usage=low_cpu_mem_usage,
          adapter_name=adapter_name,
          _pipeline=self,
      )
  
imports: import inspect
  import os
  from contextlib import nullcontext
  from pathlib import Path
  from typing import Callable, Dict, List, Optional, Union
  import safetensors
  import torch
  from huggingface_hub import model_info
  from huggingface_hub.constants import HF_HUB_OFFLINE
  from huggingface_hub.utils import validate_hf_hub_args
  from packaging import version
  from torch import nn
  from ..None import __version__
  from ..models.modeling_utils import _LOW_CPU_MEM_USAGE_DEFAULT, load_model_dict_into_meta
  from ..utils import USE_PEFT_BACKEND, _get_model_file, convert_state_dict_to_diffusers, convert_state_dict_to_peft, convert_unet_state_dict_to_peft, delete_adapter_layers, deprecate, get_adapter_name, get_peft_kwargs, is_accelerate_available, is_transformers_available, logging, recurse_remove_peft_layers, scale_lora_layers, set_adapter_layers, set_weights_and_activate_adapters
  from .lora_conversion_utils import _convert_kohya_lora_to_diffusers, _maybe_map_sgm_blocks_to_diffusers
label_desc: Use image node_id 1 for calling the LoraLoaderMixin obj's underlying member method code with example usage: obj.load_lora_weights(pretrained_model_name_or_path_or_dict, adapter_name) without return types