
    wi0                        d dl mZ ddlmZmZmZ ddlmZmZm	Z	 d Z
 e	            rd Zi Z e            r5dged<   d	ged
<   dged<    e	            rdged<   g ded<   dged<   dged<   dged<   eserJ e            r8ddlmZ ddlmZ ddlmZ  e	            rddlmZ ddlmZmZmZ ddlmZ ddlmZ ddlmZ d S d d lZ ee e             d!         ee!"          ej"        e<   d S )#    )TYPE_CHECKING   )DIFFUSERS_SLOW_IMPORT_LazyModule	deprecate)is_peft_availableis_torch_availableis_transformers_availablec                 Z   t          ddd           i }t          |           D ]\  }}|j        j                                                                        D ]\  }}||| d| <   |j        j                                                                        D ]\  }}||| d| <   |j        j                                                                        D ]\  }}||| d| <   |j        j                                                                        D ]\  }}||| d| <   |S )Nz(text_encoder_load_state_dict in `models`0.27.0`text_encoder_lora_state_dict` is deprecated and will be removed in 0.27.0. Make sure to retrieve the weights using `get_peft_model`. See https://huggingface.co/docs/peft/v0.6.2/en/quicktour#peftmodel for more information.z.q_proj.lora_linear_layer.z.k_proj.lora_linear_layer.z.v_proj.lora_linear_layer.z.out_proj.lora_linear_layer.)	r   text_encoder_attn_modulesq_projlora_linear_layer
state_dictitemsk_projv_projout_proj)text_encoderr   namemodulekvs         j/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/diffusers/loaders/__init__.pytext_encoder_lora_state_dictr      s   2 	i  
 J1,?? E EfM3>>@@FFHH 	C 	CDAqABJ$==!==>>M3>>@@FFHH 	C 	CDAqABJ$==!==>>M3>>@@FFHH 	C 	CDAqABJ$==!==>>O5@@BBHHJJ 	E 	EDAqCDJ$??A??@@	E     c                 *   t          ddd           ddlm}m} g }t	          | ||f          rIt          | j        j        j                  D ])\  }}d| d}|j	        }|
                    ||f           *nt          d| j        j                   |S )	Nz%text_encoder_attn_modules in `models`r   r   r   )CLIPTextModelCLIPTextModelWithProjectionztext_model.encoder.layers.z
.self_attnz.do not know how to get attention modules for: )r   transformersr   r    
isinstance	enumerate
text_modelencoderlayers	self_attnappend
ValueError	__class____name__)r   r   r    attn_modulesilayerr   mods           r   r   r   !   s    3 m	
 	
 	

 	LKKKKKKKl]4O$PQQ 	q%l&=&E&LMM 1 15AAAAAo##T3K00001
 olNdNmoopppr   FromOriginalModelMixinsingle_file_modelUNet2DConditionLoadersMixinunetAttnProcsLayersutilsFromSingleFileMixinsingle_file)LoraLoaderMixin StableDiffusionXLLoraLoaderMixinSD3LoraLoaderMixinloraTextualInversionLoaderMixintextual_inversionIPAdapterMixin
ip_adapterPeftAdapterMixinpeft   )r0   )r2   )r4   )r>   )r8   r:   r9   )r6   )r<   )r@   N__file__)module_spec)#typingr   r5   r   r   r   utils.import_utilsr   r	   r
   r   r   _import_structurer1   r0   r3   r2   r4   r?   r>   r;   r8   r:   r9   r7   r6   r=   r<   rA   r@   sysr+   globals__spec__modules r   r   <module>rM      s8               A A A A A A A A A A a a a a a a a a a a  0    *   =.F-G)*!> ?f"3!4g  "" =,A+B-($q$q$q&!2O1P-.+;*<,'/0 &   r) r 	G======555555******$$&& 	G222222cccccccccc888888FFFFFF&&&&&&&&JJJ'K''))J2GIZhpqqqCKr   