
    
3j                     h   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSKJr  SSKrSSKJrJrJr  SSKJrJrJrJrJr  SSKJr  S	S
KJr  S	SKJrJ r J!r!J"r"J#r#J$r$  \$RJ                  " \&5      r'\RP                  " S5      r) " S S\	5      r* " S S5      r+S r,S r- " S S\+5      r.g)z%ConfigMixin base class and utilities.    N)OrderedDict)Path)Any)	DDUFEntrycreate_repohf_hub_download)EntryNotFoundErrorHfHubHTTPErrorRepositoryNotFoundErrorRevisionNotFoundErrorvalidate_hf_hub_args)Self   )__version__)HUGGINGFACE_CO_RESOLVE_ENDPOINTDummyObject	deprecateextract_commit_hashhttp_user_agentloggingzconfig\.(.*)\.jsonc                   X   ^  \ rS rSrU 4S jrS rS rS rS rU 4S jr	U 4S jr
S	rU =r$ )

FrozenDict8   c                 ~   > [         TU ]  " U0 UD6  U R                  5        H  u  p4[        XU5        M     SU l        g )NT)super__init__itemssetattr_FrozenDict__frozen)selfargskwargskeyvalue	__class__s        W/home/wildlama/miniconda3/lib/python3.13/site-packages/diffusers/configuration_utils.pyr   FrozenDict.__init__9   s:    $)&)**,JCDu% '     c                 H    [        SU R                  R                   S35      e)Nz$You cannot use ``__delitem__`` on a 
 instance.	Exceptionr%   __name__r    r!   r"   s      r&   __delitem__FrozenDict.__delitem__A   s#    >t~~?V?V>WWabccr(   c                 H    [        SU R                  R                   S35      e)Nz#You cannot use ``setdefault`` on a r*   r+   r.   s      r&   
setdefaultFrozenDict.setdefaultD   s#    =dnn>U>U=VV`abbr(   c                 H    [        SU R                  R                   S35      e)NzYou cannot use ``pop`` on a r*   r+   r.   s      r&   popFrozenDict.popG   s"    6t~~7N7N6OzZ[[r(   c                 H    [        SU R                  R                   S35      e)NzYou cannot use ``update`` on a r*   r+   r.   s      r&   updateFrozenDict.updateJ   s#    9$..:Q:Q9RR\]^^r(   c                    > [        U S5      (       a4  U R                  (       a#  [        SU R                  R                   S35      e[
        TU ]  X5        g N__frozenz$You cannot use ``__setattr__`` on a r*   )hasattrr   r,   r%   r-   r   __setattr__r    namer$   r%   s      r&   r>   FrozenDict.__setattr__M   D    4$$B4>>CZCZB[[efggD(r(   c                    > [        U S5      (       a4  U R                  (       a#  [        SU R                  R                   S35      e[
        TU ]  X5        g r;   )r=   r   r,   r%   r-   r   __setitem__r?   s      r&   rD   FrozenDict.__setitem__R   rB   r(   )r<   )r-   
__module____qualname____firstlineno__r   r/   r2   r5   r8   r>   rD   __static_attributes____classcell__r%   s   @r&   r   r   8   s/    dc\_)
) )r(   r   c                   8   \ rS rSrSrSr/ rSr/ rSr	\
SS j5       rS rS\S\4S	 jrSS
\\R"                  -  S\4S jjr\
 S S\\\\4   -  S\\\\\\4   4   -  4S jj5       r\
S 5       r\
\  S!S\\R"                  -  S\\\\4   \\\4   4   4S jj5       5       r\S 5       r\
S 5       r\
S"S\\R"                  -  S\\\4   S-  4S jj5       r S r!\"S\\\4   4S j5       r#S\4S jr$S\\R"                  -  4S jr%\
S\S\\\4   4S j5       r&Sr'g)#ConfigMixinX   a  
Base class for all configuration classes. All configuration parameters are stored under `self.config`. Also
provides the [`~ConfigMixin.from_config`] and [`~ConfigMixin.save_config`] methods for loading, downloading, and
saving classes that inherit from [`ConfigMixin`].

Class attributes:
    - **config_name** (`str`) -- A filename under which the config should stored when calling
      [`~ConfigMixin.save_config`] (should be overridden by parent class).
    - **ignore_for_config** (`list[str]`) -- A list of attributes that should not be saved in the config (should be
      overridden by subclass).
    - **has_compatibles** (`bool`) -- Whether the class has compatible classes (should be overridden by subclass).
    - **_deprecated_kwargs** (`list[str]`) -- Keyword arguments that are deprecated. Note that the `init` function
      should only have a `kwargs` argument if at least one argument is deprecated (should be overridden by
      subclass).
NFc                 :    US:w  a  [        SU S35      eXl        g)a  
Register this class with the given auto class so that it can be loaded with `AutoModel.from_pretrained(...,
trust_remote_code=True)`.

When the config is saved, the resulting `config.json` will include an `auto_map` entry mapping the auto class
to this class's module and class name.

Args:
    auto_class (`str` or type, *optional*, defaults to `"AutoModel"`):
        The auto class to register this class with. Can be a string (e.g. `"AutoModel"`) or the class itself.
        Currently only `"AutoModel"` is supported.

Example:

```python
from diffusers import ModelMixin, ConfigMixin


class MyCustomModel(ModelMixin, ConfigMixin): ...


MyCustomModel.register_for_auto_class("AutoModel")
```
	AutoModelz$Only 'AutoModel' is supported, got ''.N)
ValueError_auto_class)cls
auto_classs     r&   register_for_auto_class#ConfigMixin.register_for_auto_classp   s&    4 $CJ<rRSS$r(   c                 <   U R                   c  [        SU R                   S35      eUR                  SS 5        [	        U S5      (       d  UnO@[        U R                  5      n0 U R                  EUEn[        R                  SU SU 35        [        U5      U l        g )NzMake sure that z' has defined a class name `config_name`r"   _internal_dictzUpdating config from z to )
config_nameNotImplementedErrorr%   r5   r=   dictrY   loggerdebugr   )r    r"   internal_dictprevious_dicts       r&   register_to_configConfigMixin.register_to_config   s    #%7GGn&opp 	

8T"t-.."M !4!45M=t22=f=MLL0tM?ST(7r(   r@   returnc                    SU R                   ;   =(       a    [        U R                   S   U5      nXR                   ;   nU(       aZ  U(       dS  SU S[        U 5      R                   SU S[        U 5      R                   SU S3n[	        SS	US
S9  U R
                  U   $ [        S[        U 5      R                   SU S35      e)a7  The only reason we overwrite `getattr` here is to gracefully deprecate accessing
config attributes directly. See https://github.com/huggingface/diffusers/pull/3129

This function is mostly copied from PyTorch's __getattr__ overwrite:
https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module
rY   zAccessing config attribute `z` directly via 'z1' object attribute is deprecated. Please access 'z' over 'z1's config object instead, e.g. 'scheduler.config.rQ   zdirect config name access1.0.0Fstandard_warn'z' object has no attribute ')__dict__r=   typer-   r   rY   AttributeError)r    r@   is_in_configis_attributedeprecation_messages        r&   __getattr__ConfigMixin.__getattr__   s    (4==8kWT]]ScEdfj=k}},$@FVW[\`WaWjWjVk  l]  ^b  ]c  ck  lp  qu  lv  l  l  k@  @q  rv  qw  wy  #z17<O_de&&t,,qd!4!4 55PQUPVVWXYYr(   save_directorypush_to_hubc           	         [         R                  R                  U5      (       a  [        SU S35      e[         R                  " USS9  [         R                  R                  XR                  5      nU R                  U5        [        R                  SU 35        U(       a  UR                  SS5      nUR                  SS5      nUR                  S	S
5      nUR                  SS5      nUR                  SUR                  [         R                  R                  5      S   5      n	[        U	SXhS9R                  n	UR                  SS5      n
U R                  UU	UUUU
S9  gg)a  
Save a configuration object to the directory specified in `save_directory` so that it can be reloaded using the
[`~ConfigMixin.from_config`] class method.

Args:
    save_directory (`str` or `os.PathLike`):
        Directory where the configuration JSON file is saved (will be created if it does not exist).
    push_to_hub (`bool`, *optional*, defaults to `False`):
        Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the
        repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
        namespace).
    kwargs (`dict[str, Any]`, *optional*):
        Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
zProvided path (z#) should be a directory, not a fileT)exist_okzConfiguration saved in commit_messageNprivate	create_prFtokenrepo_id)rt   rv   rx   	subfolder)rx   ru   rw   r{   )ospathisfileAssertionErrormakedirsjoinrZ   to_json_filer]   infor5   splitsepr   ry   _upload_folder)r    rq   rr   r"   output_config_fileru   rv   rw   rx   ry   r{   s              r&   save_configConfigMixin.save_config   s5    77>>.)) ?>2BBe!fgg
NT2  WW\\.:J:JK,--.@-ABC#ZZ(8$?NjjD1G

;6IJJw-EjjN,@,@,Mb,QRG!'D'W__G

;5I-##    r(   configc                 h   SU;   a  UR                  S5      nUc  [        S5      e[        U[        5      (       d[  SnSU R                  ;   a
  USU  S3-  nOSU R                  ;   a  USU  S	U  S
3-  n[        SSUSS9  U R                  " SUSS.UD6u  pU R                  " U40 UD6u  pVnSU;   a  UR                  S5      US'   U R                   H  nX;   d  M
  UR                  U5      XX'   M     U " S0 UD6n	SU;   a  U R                  US'   U	R                  " S0 UD6  0 UEUEnU(       a  X4$ U	$ )aB  
Instantiate a Python class from a config dictionary.

Parameters:
    config (`dict[str, Any]`):
        A config dictionary from which the Python class is instantiated. Make sure to only load configuration
        files of compatible classes.
    return_unused_kwargs (`bool`, *optional*, defaults to `False`):
        Whether kwargs that are not consumed by the Python class should be returned or not.
    kwargs (remaining dictionary of keyword arguments, *optional*):
        Can be used to update the configuration object (after it is loaded) and initiate the Python class.
        `**kwargs` are passed directly to the underlying scheduler/model's `__init__` method and eventually
        overwrite the same named arguments in `config`.

Returns:
    [`ModelMixin`] or [`SchedulerMixin`]:
        A model or scheduler object instantiated from a config dictionary.

Examples:

```python
>>> from diffusers import DDPMScheduler, DDIMScheduler, PNDMScheduler

>>> # Download scheduler from huggingface.co and cache.
>>> scheduler = DDPMScheduler.from_pretrained("google/ddpm-cifar10-32")

>>> # Instantiate DDIM scheduler class with same config as DDPM
>>> scheduler = DDIMScheduler.from_config(scheduler.config)

>>> # Instantiate PNDM scheduler class with same config as DDPM
>>> scheduler = PNDMScheduler.from_config(scheduler.config)
```
pretrained_model_name_or_pathzFPlease make sure to provide a config as the first positional argument.zJIt is deprecated to pass a pretrained model name or path to `from_config`.	Schedulerz3If you were trying to load a scheduler, please use z.from_pretrained(...) instead. Otherwise, please make sure to pass a configuration dictionary instead. This functionality will be removed in v1.0.0.Modelz/If you were trying to load a model, please use z.load_config(...) followed by z.from_config(...) instead. Otherwise, please make sure to pass a configuration dictionary instead. This functionality will be removed in v1.0.0.zconfig-passed-as-pathre   Frf   T)r   return_unused_kwargsdtype_class_name )
r5   rR   
isinstancer\   r-   r   load_configextract_init_dict_deprecated_kwargsra   )
rT   r   r   r"   rn   	init_dictunused_kwargshidden_dictdeprecated_kwargmodels
             r&   from_configConfigMixin.from_config   s   N +f4ZZ ?@F>eff &$''"ncll*#I# O- -#
 CLL(#EcU Ku NN#
 -w8K[`a __w6hlwpvwNF030E0Ef0WPV0W-	+ m#!.!2!27!;Ig !$ 6 60.;.?.?@P.Q	+ !7
  i  K'),K&  /;/ 9=8K8))Lr(   c                 J    SU  S3n[        SSUSS9  U R                  " U0 UD6$ )Nz8 The function get_config_dict is deprecated. Please use zE.load_config instead. This function will be removed in version v1.0.0get_config_dictre   Frf   )r   r   )rT   r!   r"   rn   s       r&   r   ConfigMixin.get_config_dict:  sC     Gse L) ) 	 	#W.AQVW///r(   r   c                    UR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      n	UR                  S	S5      n
UR                  S
S5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  S0 5      nUR                  SS5      n0 UESS0En[        U5      n[        U5      nU R                  c  [	        S5      eU(       a"  Ub  [	        S5      eU R                  UU5      nGOw[        R                  R                  U5      (       a  UnGOO[        R                  R                  U5      (       Ga  Ubw  [        R                  R                  [        R                  R                  XU R                  5      5      (       a+  [        R                  R                  XU R                  5      nO[        R                  R                  [        R                  R                  XR                  5      5      (       a*  [        R                  R                  XR                  5      nO;[        SU R                   SU S35      e [        UU R                  UUU	UU
UUUUUS9n U R%                  UUS&9n['        U5      nU(       d	  U(       d  U$ U4nU(       a  UU4-  nU(       a  UU4-  nU$ ! [         a    [        U S35      e[         a    [        U SU S35      e[         a    [        U SU R                   S35      e[          a  n[        SU SU 35      eSnAf[         a$    [        S["         SU S U R                   S!35      e[         a     [        S"U S#U S$U R                   S%35      ef = f! [(        R*                  [,        4 a    [        S'U S(35      ef = f))ag	  
Load a model or scheduler configuration.

Parameters:
    pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*):
        Can be either:

            - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on
              the Hub.
            - A path to a *directory* (for example `./my_model_directory`) containing model weights saved with
              [`~ConfigMixin.save_config`].

    cache_dir (`str | os.PathLike`, *optional*):
        Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
        is not used.
    force_download (`bool`, *optional*, defaults to `False`):
        Whether or not to force the (re-)download of the model weights and configuration files, overriding the
        cached versions if they exist.
    proxies (`dict[str, str]`, *optional*):
        A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
        'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
    output_loading_info(`bool`, *optional*, defaults to `False`):
        Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.
    local_files_only (`bool`, *optional*, defaults to `False`):
        Whether to only load local model weights and configuration files or not. If set to `True`, the model
        won't be downloaded from the Hub.
    token (`str` or *bool*, *optional*):
        The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
        `diffusers-cli login` (stored in `~/.huggingface`) is used.
    revision (`str`, *optional*, defaults to `"main"`):
        The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
        allowed by Git.
    subfolder (`str`, *optional*, defaults to `""`):
        The subfolder location of a model file within a larger model repository on the Hub or locally.
    return_unused_kwargs (`bool`, *optional*, defaults to `False):
        Whether unused keyword arguments of the config are returned.
    return_commit_hash (`bool`, *optional*, defaults to `False):
        Whether the `commit_hash` of the loaded configuration are returned.

Returns:
    `dict`:
        A dictionary of all the parameters stored in a JSON configuration file.

	cache_dirN	local_dirlocal_dir_use_symlinksautoforce_downloadFproxiesrx   local_files_onlyrevisionmirrorr{   
user_agentdduf_entries	file_typer   z`self.config_name` is not defined. Note that one should not load a config from `ConfigMixin`. Please make sure to define `config_name` in a class inheriting from `ConfigMixin`zDDUF file only allow for 1 level of directory (e.g transformer/model1/model.safetentors is not allowed). Please check the DDUF structurezError no file named z found in directory .)filenamer   r   r   r   rx   r   r{   r   r   r   z is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo with `token` or log in with `hf auth login`.z is not a valid git identifier (branch name, tag name or commit id) that exists for this model name. Check the model page at 'https://huggingface.co/z' for available revisions.z& does not appear to have a file named z:There was a specific connection error when trying to load z:
zWe couldn't connect to 'zM' to load this model, couldn't find it in the cached files and it looks like z- is not the path to a directory containing a z file.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/diffusers/installation#offline-mode'.zCan't load config for 'z'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'z2' is the correct path to a directory containing a z file)r   z"It looks like the config file at 'z' is not a valid JSON file.)r5   r   strrZ   rR   _get_config_file_from_ddufr|   r}   r~   isdirr   EnvironmentErrorr   r   r   r	   r
   r   _dict_from_json_filer   jsonJSONDecodeErrorUnicodeDecodeError)rT   r   r   return_commit_hashr"   r   r   r   r   r   rx   r   r   _r{   r   r   config_fileerrconfig_dictcommit_hashoutputss                         r&   r   ConfigMixin.load_configC  s8   j JJ{D1	JJ{D1	!',Df!M$4e<**Y-

7D)!::&8%@::j$/JJx&JJ{D1	ZZb1
4:JJ~t4T:
:K:
$Z0
(+,I(J%??"s 
 $ 6  889VXdeKWW^^9::7KWW]]899$:sW* * !ggll+HUXUdUde-JOO \]] ggll+H//Z&*3??*;;OPmOnnop 3-1 __'#1#%5)'%'+Ad	r22;\2ZK-k:K %(:.y G~%Gm + &45 6i i 
 ) &j !00M/NNhj 
 & &455[\_\k\k[llmn  " &56c#@   &./N.O P>>[=\ ]//2.? @ZZ  $ &-.K-L M--J,K L$$'OO#4E;  $$&89 	r"%G}To#pqq	rs&   K: 0O :AOM**AO*O0c                     [        [        [        R                  " U R                  5      R
                  5      R                  5       5      $ N)setr\   inspect	signaturer   
parameterskeys)input_classs    r&   _get_init_keysConfigMixin._get_init_keys  s2    4))+*>*>?JJKPPRSSr(   c           	         UR                  S/ 5      nUR                  5        VVs0 s H  u  pEXC;  d  M  US:w  d  M  XE_M     nnn[        UR                  5       5      nU R                  U 5      nUR	                  S5        SU;   a  UR	                  S5        [        U S5      (       a$  U R                   H  nUR	                  U5        M     [        U R                  5      S:  a  U[        U R                  5      -
  n[        R                  " [        R                  S5      S   5      n	U R                  (       a8  U R                  5        V
s/ s H  n
[!        U
["        5      (       a  M  U
PM     nn
O/ n[        5       nU H%  n
U R                  U
5      nUR%                  U5      nM'     XR                  U 5      -
  nUR                  5        VVs0 s H  u  pEXL;  d  M  XE_M     nnnUR'                  SU R                  5      n[!        U[(        5      (       ak  XR                  :w  a\  [        X5      (       aL  [+        X5      nU R                  U5      U-
  nUR                  5        VVs0 s H  u  pEUU;  d  M  XE_M     nnnO;[!        U[(        5      (       d&  [!        U[,        [.        45      (       d  [1        S5      eUR                  5        VVs0 s H  u  pEUR3                  S	5      (       a  M  XE_M!     nnnUR                  5        VVs0 s H  u  pEUS
:w  d  M  XE_M     nnn0 nU H[  nUU;   a  UU;   a  UR'                  U5      UU'   UU;   a  UR'                  U5      UU'   M?  UU;   d  MG  UR'                  U5      UU'   M]     [        U5      S:  a3  [4        R7                  SU SU R                   SU R8                   S35        [        UR;                  5       5      n[        UU-
  5      S:  a  [4        R=                  UU-
   S35        0 UEUEnUR                  5        VVs0 s H  u  pEUU;  d  M  XE_M     nnnUUU4$ s  snnf s  sn
f s  snnf s  snnf s  snnf s  snnf s  snnf )N_use_default_valuesr    r"   _flax_internal_argsr   r   r   z\Make sure that the `_class_name` is of type string or list of string (for custom pipelines).r   quantization_configzThe config attributes z were passed to z?, but are not expected and will be ignored. Please verify your z configuration file.zG was not found in config. Values will be initialized to default values.)getr   r\   r   remover=   r   lenignore_for_configr   	importlibimport_moduler-   r   has_compatibles_get_compatiblesr   r   unionr5   r   getattrlisttuplerR   
startswithr]   warningrZ   r   r   )rT   r   r"   used_defaultskvoriginal_dictexpected_keysargdiffusers_libraryccompatible_classesexpected_keys_comp_clsexpected_keys_corig_cls_nameorig_clsunexpected_keys_from_origr   r#   passed_keysr   hidden_config_dicts                         r&   r   ConfigMixin.extract_init_dict  s?    $(=rB(3(9(9(;u(;q?UtZ[_tZttqt(;u [..01 **3/V$}$  *3-....$$S) /
 s$$%))C0E0E,FFM &33HNN34G4JK-0-A-A-C!f-C:VWYdKe!-C!f!#!$#A!003O%;%A%A/%R" $ "8:L:LS:Q!Q(3(9(9(;_(;q?^tqt(;_ $s||D}c**-)990@H(+(:(:8(D}(T%,7,=,=,?f,?DA1LeCe414,?KfKM3//
=SWY^R_8`8`n 
 )4(9(9(;U(;1<<PSCTtqt(;U )4(9(9(;Z(;qDY?Ytqt(;Z 	 C f}!3#)::c?C f}!'C	##!,!5	# ! {aNN(5Ecll^ TP??##79 )..*+}{*+a/KK ;.//vw
 2;1&1 0=/B/B/D[/DtqQZHZdad/D[-);;;{ v2 "g ` g V [H \sW   Q	Q	Q	Q*QQQ*Q:QQ 2Q Q&Q&+Q,;Q,	json_filer   c                     U(       a  X!   R                  5       nO$[        USSS9 nUR                  5       nS S S 5        [        R                  " W5      $ ! , (       d  f       N$= f)Nrutf-8encoding)	read_textopenreadr   loads)rT   r   r   textreaders        r&   r    ConfigMixin._dict_from_json_fileU  sL    *446Diw76{{} 8zz$ 87s   A
A#c                 T    U R                   R                   SU R                  5        3$ )N )r%   r-   to_json_stringr    s    r&   __repr__ConfigMixin.__repr__^  s(    ..))*!D,?,?,A+BCCr(   c                     U R                   $ )zm
Returns the config of the class as a frozen dictionary

Returns:
    `dict[str, Any]`: Config of the class.
rY   r   s    r&   r   ConfigMixin.configa  s     """r(   c                   ^ [        U S5      (       a  U R                  O0 nU R                  R                  US'   [        US'   U4S jmSU;   aH  [        UR                  [        5      (       d  UR                  R                  5       OUR                  US'   UR                  5        VVs0 s H  u  p#UT" U5      _M     nnnUR                  SS5        UR                  SS5        UR                  S	S5      n[        U S
S5      be  U R                  R                  R                  S5      S   nUR                  S0 5      nU SU R                  R                   3X`R                  '   XaS'   [         R"                  " USSS9S-   $ s  snnf )z
Serializes the configuration instance to a JSON string.

Returns:
    `str`:
        String containing all the attributes that make up the configuration instance in JSON format.
rY   r   _diffusers_versionc                   > [        U [        R                  5      (       a  U R                  5       n U $ [        U [        5      (       a  U R                  5       n U $ [        U S5      (       a,  [        U R                  5      (       a  U R                  5       n U $ [        U [        5      (       a  U  Vs/ s H  nT" U5      PM     n nU $ s  snf )Nto_dict)
r   npndarraytolistr   as_posixr=   callabler  r   )r$   r   to_json_saveables     r&   r  4ConfigMixin.to_json_string.<locals>.to_json_saveablew  s    %,, L E4(((
 L	 	**x/F/F L E4((6;<e)!,e<L =s   0Cr   _ignore_filesNr   _pre_quantization_dtyperS   r   rz   auto_map   T)indent	sort_keys
)r=   rY   r%   r-   r   r   r   r\   r  r   r5   r   rF   r   r   rS   r   dumps)r    r   r   r   r   moduler  r  s          @r&   r   ConfigMixin.to_json_stringk  sp    .5T;K-L-Ld))RT%)^^%<%<M",7()		 !K/ "+"A"A4HH //779 44 -. ;F:K:K:MN:M$!q*1--:MN.-t4OO5t<4-9^^..44S9"=F"z26H,281T^^5L5L4M)NH%%&&.
#zz+a4@4GG Os   *Fjson_file_pathc                     [        USSS9 nUR                  U R                  5       5        SSS5        g! , (       d  f       g= f)z
Save the configuration instance's parameters to a JSON file.

Args:
    json_file_path (`str` or `os.PathLike`):
        Path to the JSON file to save a configuration instance's parameters.
wr   r   N)r   writer   )r    r  writers      r&   r   ConfigMixin.to_json_file  s3     .#8FLL,,./ 988s	    5
Ac                     US:X  a  U R                   OSR                  XR                   /5      nX2;  a  [        SU SUR                  5        35      eU$ )N /z#We did not manage to find the file z4 in the dduf file. We only have the following files )rZ   r   rR   r   )rT   r   r   r   s       r&   r   &ConfigMixin._get_config_file_from_dduf  s~    
 -2 OO8//JK 	
 *5k]Bv  xD  xI  xI  xK  wL  M  r(   r  )rP   )FNF)FFr   )(r-   rF   rG   rH   __doc__rZ   r   r   r   rS   classmethodrV   ra   r   r   ro   r|   PathLikeboolr   r   r\   r   r   r   r   r   r   staticmethodr   r   r   r   r   propertyr   r   r   r   rI   r   r(   r&   rM   rM   X   s     KOK% %<8"Z Z Z$*#*; *$ *X NSY$sCx.0Y	dDcN*+	+Y Yv 0 0  # 	g'*R[['8g 
tCH~tCH~-	.g  gR T T `< `<D  S2;;->  dSVXaSaNbeiNi    D #S#X # #+H +HZ	03+< 	0 s Z^_bdm_mZn  r(   rM   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )a  
Decorator to apply on the init of classes inheriting from [`ConfigMixin`] so that all the arguments are
automatically sent to `self.register_for_config`. To ignore a specific argument accepted by the init but that
shouldn't be registered in the config, use the `ignore_for_config` class variable

Warning: Once decorated, all private arguments (beginning with an underscore) are trashed and not sent to the init!
c                   > UR                  5        VVs0 s H  u  p4UR                  S5      (       a  M  X4_M!     nnnUR                  5        VVs0 s H  u  p4UR                  S5      (       d  M  X4_M!     nnn[        U [        5      (       d#  [	        SU R
                  R                   S35      e[        U S/ 5      n0 n[        R                  " T5      n	[        U	R                  R                  5       5       V
VVs0 s H#  u  n
u  pU
S:  d  M  X;  d  M  XR                  _M%     nnn
n[        XR                  5       5       H	  u  pXU'   M     UR                  UR                  5        VVs0 s H$  u  p?X7;  d  M  X8;  d  M  X5R!                  X?5      _M&     snn5        [#        [%        UR                  5       5      [%        U5      -
  5      S:  a1  ['        [%        UR                  5       5      [%        U5      -
  5      US'   0 UEUEn[        U S5      " S0 UD6  T" U /UQ70 UD6  g s  snnf s  snnf s  snnn
f s  snnf )	Nr   &`@register_for_config` was applied to A init method, but this class does not inherit from `ConfigMixin`.r   r   r   ra   r   )r   r   r   rM   RuntimeErrorr%   r-   r   r   r   	enumerater   defaultzipr   r8   r   r   r   r   )r    r!   r"   r   r   init_kwargsconfig_init_kwargsignore
new_kwargsr   ir@   pr   r   r/  inits                   r&   
inner_init&register_to_config.<locals>.inner_init  s    )/Pall3>OtqtP/5||~S~tqcARdad~S$,,89P9P8Q R2 2 
 2B7
%%d+	09):N:N:T:T:V0W
0W9D[\_`[`OeiewOD))O0W 	 
 T??#45IC"t 6 	 #-"2"2"4"4JA? /'(': /??1.."4	
 s:??$%K(889A=04S9J5KcR]N^5^0_J,-9*9j9
*+9j9T(D(K(C QS
s:   H+H+H11H1>H7H7H70H>
?H>
H>
)	functoolswraps)r7  r8  s   ` r&   ra   ra     s)     __T#) #)J r(   c                 j   ^ U R                   m[        R                  " T5      U4S j5       nXl         U $ )Nc                 Z  > [        U [        5      (       d#  [        SU R                  R                   S35      e[        UR                  5       5      n[        R                  " U 5      n0 nU Hw  nUR                  U R                  ;   a  M  [        UR                  5      [        R                  :X  a  S XVR                  '   MV  [        XR                  5      XVR                  '   My     0 UEUEnSU;   a  UR                  S5        [!        U5       H  u  pXH   R                  n
XU
'   M     [#        [%        UR'                  5       5      [%        U5      -
  5      S:  a1  [)        [%        UR'                  5       5      [%        U5      -
  5      US'   [        U S5      " S0 UD6  T" U /UQ70 UD6  g )Nr+  r,  r   r   r   ra   r   )r   rM   r-  r%   r-   r\   r   dataclassesfieldsr@   r   rj   r/  _MISSING_TYPEr   r5   r.  r   r   r   r   )r    r!   r"   r1  r?  default_kwargsfieldr4  r5  r   r@   original_inits              r&   r7  %flax_register_to_config.<locals>.init  su   $,,89P9P8Q R2 2  6<<>* ##D)EzzT555EMM"k&?&??-1zz*-4T::-Fzz*  76+6
j NN7#  oFA9>>D"t &
 s:??$%K(889A=04S9J5KcR]N^5^0_J,-*+9j9d,T,V,r(   )r   r:  r;  )rT   r7  rC  s     @r&   flax_register_to_configrE    s4    LLM__]#&- $&-P LJr(   c                   R   ^  \ rS rSrSr\SS\\\\	4   -  4U 4S jjj5       r
SrU =r$ )LegacyConfigMixini  z
A subclass of `ConfigMixin` to resolve class mapping from legacy classes (like `Transformer2DModel`) to more
pipeline-specific classes (like `DiTTransformer2DModel`).
r   c                 x   > SSK Jn  U" X5      nXPL a  [        [        U]  " X40 UD6$ UR                  " X40 UD6$ )Nr   )_fetch_remapped_cls_from_config)models.model_loading_utilsrI  r   rG  r   )rT   r   r   r"   rI  remapped_classr%   s         r&   r   LegacyConfigMixin.from_config  sJ     	P 9E *NGohnoo!--fUfUUr(   r   r"  )r-   rF   rG   rH   r#  r$  r   r\   r   r   r   rI   rJ   rK   s   @r&   rG  rG    s3    
 
Vd38n!< 
V 
Vr(   rG  )/r#  r>  r:  r   r   r   r|   recollectionsr   pathlibr   typingr   numpyr  huggingface_hubr   r   r   huggingface_hub.utilsr	   r
   r   r   r   typing_extensionsr   r  r   utilsr   r   r   r   r   r   
get_loggerr-   r]   compile_re_configuration_filer   rM   ra   rE  rG  r   r(   r&   <module>rY     s     ,      	 	 #    C C  #   
		H	%$9: ) )@W	 W	t/d-`V Vr(   