
    +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JrJrJr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  SSK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)  \)RT                  " \+5      r,\RZ                  " S5      r. " S S\	5      r/ " S S5      r0S r1S r2 " S S\05      r3g)z%ConfigMixin base class and utilities.    N)OrderedDict)Path)AnyDictOptionalTupleUnion)	DDUFEntrycreate_repohf_hub_download)EntryNotFoundErrorRepositoryNotFoundErrorRevisionNotFoundErrorvalidate_hf_hub_args)	HTTPError)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/james-whalen/.local/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/   r2   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/   r2   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/   r2   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#   r0   r)   r1   r   __setattr__r$   namer(   r)   s      r*   rB   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?   )rA   r#   r0   r)   r1   r   __setitem__rC   s      r*   rH   FrozenDict.__setitem__R   rF   r,   )r@   )r1   
__module____qualname____firstlineno__r    r3   r6   r9   r<   rB   rH   __static_attributes____classcell__r)   s   @r*   r   r   8   s/    dc\_)
) )r,   r   c                   :   \ rS rSrSrSr/ rSr/ rS r	S\
S\4S jrSS	\\
\R                  4   S
\4S jjr\ SS\\\\
\4   4   S\\\\\\
\4   4   4   4S jj5       r\S 5       r\\  SS\\
\R                  4   S\\\
\4   \\
\4   4   4S jj5       5       r\S 5       r\S 5       r\ S S\\
\R                  4   S\\\
\4      4S jj5       r S r!\"S\\
\4   4S j5       r#S\
4S jr$S\\
\R                  4   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 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)   r9   rA   dictrT   loggerdebugr   )r$   r&   internal_dictprevious_dicts       r*   register_to_configConfigMixin.register_to_configo   s    #%7GGn&opp 	

8T"t-.."M !4!45M=t22=f=MLL0tM?ST(7r,   rD   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
rT   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.z'.zdirect config name access1.0.0Fstandard_warn'z' object has no attribute ')__dict__rA   typer1   r   rT   AttributeError)r$   rD   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)ro   rq   rs   	subfolder)rs   rp   rr   rv   )ospathisfileAssertionErrormakedirsjoinrU   to_json_filerX   infor9   splitsepr   rt   _upload_folder)r$   rl   rm   r&   output_config_filerp   rq   rr   rs   rt   rv   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-pathr`   Fra   T)r   return_unused_kwargsdtype_class_name )
r9   
ValueError
isinstancerW   r1   r   load_configextract_init_dict_deprecated_kwargsr\   )
clsr   r   r&   ri   	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_dictr`   Fra   )r   r   )r   r%   r&   ri   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))am	  
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 (`Union[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proxiesrs   local_files_onlyrevisionmirrorrv   
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   rs   r   rv   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.)r9   r   strrU   r   _get_config_file_from_ddufrw   rx   ry   isdirr|   EnvironmentErrorr   r   r   r   r   r   _dict_from_json_filer   jsonJSONDecodeErrorUnicodeDecodeError)r   r   r   return_commit_hashr&   r   r   r   r   r   rs   r   r   _rv   r   r   config_fileerrconfig_dictcommit_hashoutputss                         r*   r   ConfigMixin.load_config#  s9   j JJ{D1	JJ{D1	!',Df!M$4e<**Y-

7D)!::&8%@::j$/JJx&JJ{D1	ZZb1
7=zz.RV7W:
: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)setrW   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!   rW   r   removerA   r   lenignore_for_configr   	importlibimport_moduler1   r   has_compatibles_get_compatiblesr   r   unionr9   r   getattrlisttupler   
startswithrX   warningrU   r   r~   )r   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)r   r   r   textreaders        r*   r    ConfigMixin._dict_from_json_file5  sN     *446Diw76{{} 8zz$ 87s   A
A#c                 T    U R                   R                   SU R                  5        3$ )N )r)   r1   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.
rT   r   s    r*   r   ConfigMixin.configC  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[        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.
rT   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_posixrA   callabler  r   )r(   r   to_json_saveables     r*   r	  4ConfigMixin.to_json_string.<locals>.to_json_saveableY  s    %,, L E4(((
 L	 	**x/F/F L E4((6;<e)!,e<L =s   0Cr   _ignore_filesNr   _pre_quantization_dtype   T)indent	sort_keys
)rA   rT   r)   r1   r   r   r   rW   r  r!   r9   r   dumps)r$   r   r   r   r   r	  s        @r*   r   ConfigMixin.to_json_stringM  s    .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<zz+a4@4GG Os   *D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_filet  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 )rU   r|   r   r   )r   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   )FNF)FFr   )(r1   rJ   rK   rL   __doc__rU   r   r   r   r\   r   r   rj   r	   rw   PathLikeboolr   classmethodr   r   r   r   r   r   r   r   staticmethodr   r   r   r
   r   r   propertyr   r   r}   r   rM   r   r,   r*   rQ   rQ   X   s      KO8"Z Z Z$*%R[[0@*A *PT *X TYY:tCH~56Y	tU4c3h/00	1Y Yv 0 0  # 	g',S"++-='>g 
tCH~tCH~-	.g  gR T T `< `<D `d c2;;./ ?GSR[^H\?]   D #S#X # #%H %HN	05bkk1A+B 	0 s Z^_bdm_mZn  r,   rQ   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   r\   r   )r!   r   r   rQ   RuntimeErrorr)   r1   r   r   r   	enumerater   defaultzipr   r<   r   r   r   r   )r$   r%   r&   r   r   init_kwargsconfig_init_kwargsignore
new_kwargsr   irD   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)r2  r3  s   ` r*   r\   r\     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   r\   r   )r   rQ   r(  r)   r1   rW   r!   dataclassesfieldsrD   r   re   r*  _MISSING_TYPEr   r9   r)  r   r   r   r   )r$   r%   r&   r,  r:  default_kwargsfieldr/  r0  r   rD   original_inits              r*   r2  %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    r5  r6  )r   r2  r>  s     @r*   flax_register_to_configr@    s4    LLM__]#&- $&-P LJr,   c                   V   ^  \ rS rSrSr\SS\\\\	\
4   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_utilsrD  r   rB  r   )r   r   r   r&   rD  remapped_classr)   s         r*   r   LegacyConfigMixin.from_config  sJ     	P 9E *NGohnoo!--fUfUUr,   r   r  )r1   rJ   rK   rL   r  r!  r	   r   r   r   r   r   rM   rN   rO   s   @r*   rB  rB    s8    
 
Vz4S>'A!B 
V 
Vr,   rB  )4r  r9  r5  r   r   r   rw   recollectionsr   pathlibr   typingr   r   r   r   r	   numpyr  huggingface_hubr
   r   r   huggingface_hub.utilsr   r   r   r   requestsr   typing_extensionsr   r  r   utilsr   r   r   r   r   r   
get_loggerr1   rX   compile_re_configuration_filer   rQ   r\   r@  rB  r   r,   r*   <module>rU     s     ,      	 	 #  4 4  C C   "   
		H	%$9: ) )@s sl/d-`V Vr,   