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",")","."]
code: def _best_guess_weight_name(
      cls,
      pretrained_model_name_or_path_or_dict,
      file_extension=".safetensors",
      local_files_only=False,
  ):
      if local_files_only or HF_HUB_OFFLINE:
          raise ValueError(
              "When using the offline mode, you must specify a `weight_name`."
          )
  
      targeted_files = []
  
      if os.path.isfile(pretrained_model_name_or_path_or_dict):
          return
      elif os.path.isdir(pretrained_model_name_or_path_or_dict):
          targeted_files = [
              f
              for f in os.listdir(pretrained_model_name_or_path_or_dict)
              if f.endswith(file_extension)
          ]
      else:
          files_in_repo = model_info(
              pretrained_model_name_or_path_or_dict
          ).siblings
          targeted_files = [
              f.rfilename
              for f in files_in_repo
              if f.rfilename.endswith(file_extension)
          ]
      if len(targeted_files) == 0:
          return
  
      # "scheduler" does not correspond to a LoRA checkpoint.
      # "optimizer" does not correspond to a LoRA checkpoint
      # only top-level checkpoints are considered and not the other ones, hence "checkpoint".
      unallowed_substrings = {"scheduler", "optimizer", "checkpoint"}
      targeted_files = list(
          filter(
              lambda x: all(
                  substring not in x
                  for substring in unallowed_substrings
              ),
              targeted_files,
          )
      )
  
      if any(f.endswith(LORA_WEIGHT_NAME) for f in targeted_files):
          targeted_files = list(
              filter(
                  lambda x: x.endswith(LORA_WEIGHT_NAME), targeted_files
              )
          )
      elif any(
          f.endswith(LORA_WEIGHT_NAME_SAFE) for f in targeted_files
      ):
          targeted_files = list(
              filter(
                  lambda x: x.endswith(LORA_WEIGHT_NAME_SAFE),
                  targeted_files,
              )
          )
  
      if len(targeted_files) > 1:
          raise ValueError(
              f"Provided path contains more than one weights file in the {file_extension} format. Either specify `weight_name` in `load_lora_weights` or make sure there's only one  `.safetensors` or `.bin` file in  {pretrained_model_name_or_path_or_dict}."
          )
      weight_name = targeted_files[0]
      return weight_name
  
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 3 for calling the LoraLoaderMixin obj's underlying member method code with example usage: obj._best_guess_weight_name(cls, pretrained_model_name_or_path_or_dict, file_extension, local_files_only) and returns: weight_name