
    /;ji                     x   d Z ddlZddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZmZmZmZ ddlZddlmZmZ ddlmZmZmZmZ ddlmZ d	d
lmZ d	dlm Z m!Z!m"Z"m#Z#m$Z$m%Z%  e%j&        e'          Z( ej)        d          Z* G d de	          Z+ G d d          Z,d Z-d Z. G d de,          Z/dS )z%ConfigMixin base class and utilities.    N)OrderedDict)	PosixPath)AnyDictTupleUnion)create_repohf_hub_download)EntryNotFoundErrorRepositoryNotFoundErrorRevisionNotFoundErrorvalidate_hf_hub_args)	HTTPError   )__version__)HUGGINGFACE_CO_RESOLVE_ENDPOINTDummyObject	deprecateextract_commit_hashhttp_user_agentloggingzconfig\.(.*)\.jsonc                   J     e Zd Z fdZd Zd Zd Zd Z fdZ fdZ	 xZ
S )
FrozenDictc                      t                      j        |i | |                                 D ]\  }}t          | ||           d| _        d S )NT)super__init__itemssetattr_FrozenDict__frozen)selfargskwargskeyvalue	__class__s        W/root/voice-cloning/.venv/lib/python3.11/site-packages/diffusers/configuration_utils.pyr   zFrozenDict.__init__8   sZ    $)&)))**,, 	& 	&JCD#u%%%%    c                 <    t          d| j        j         d          )Nz$You cannot use ``__delitem__`` on a 
 instance.	Exceptionr%   __name__r    r!   r"   s      r&   __delitem__zFrozenDict.__delitem__@   s!    bt~?Vbbbcccr'   c                 <    t          d| j        j         d          )Nz#You cannot use ``setdefault`` on a r)   r*   r-   s      r&   
setdefaultzFrozenDict.setdefaultC   s!    adn>Uaaabbbr'   c                 <    t          d| j        j         d          )NzYou cannot use ``pop`` on a r)   r*   r-   s      r&   popzFrozenDict.popF   s!    Zt~7NZZZ[[[r'   c                 <    t          d| j        j         d          )NzYou cannot use ``update`` on a r)   r*   r-   s      r&   updatezFrozenDict.updateI   s!    ]$.:Q]]]^^^r'   c                     t          | d          r$| j        rt          d| j        j         d          t                                          ||           d S N__frozenz$You cannot use ``__setattr__`` on a r)   )hasattrr   r+   r%   r,   r   __setattr__r    namer$   r%   s      r&   r9   zFrozenDict.__setattr__L   _    4$$ 	h 	hf4>CZfffgggD%(((((r'   c                     t          | d          r$| j        rt          d| j        j         d          t                                          ||           d S r6   )r8   r   r+   r%   r,   r   __setitem__r:   s      r&   r>   zFrozenDict.__setitem__Q   r<   r'   )r,   
__module____qualname__r   r.   r0   r2   r4   r9   r>   __classcell__)r%   s   @r&   r   r   7   s            d d dc c c\ \ \_ _ _) ) ) ) )
) ) ) ) ) ) ) ) )r'   r   c                      e Zd ZdZdZg ZdZg Zd Zde	de
fdZddee	ej        f         d	efd
Zeddeeee	e
f         f         fd            Zed             Zee	 	 ddee	ej        f         deee	e
f         ee	e
f         f         fd                        Zed             Zed             Zedee	ej        f         fd            Zd Zedee	e
f         fd            Zde	fdZ dee	ej        f         fdZ!dS )ConfigMixina  
    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                 <   | j         t          d| j         d          |                    dd            t	          | d          s|}n?t          | j                  }i | j        |}t                              d| d|            t          |          | _        d S )NzMake sure that z' has defined a class name `config_name`r"   _internal_dictzUpdating config from z to )
config_nameNotImplementedErrorr%   r2   r8   dictrE   loggerdebugr   )r    r"   internal_dictprevious_dicts       r&   register_to_configzConfigMixin.register_to_confign   s    #%&o&o&o&oppp 	

8T"""t-.. 	U"MM !455M=t2=f=MLLSSSMSSTTT(77r'   r;   returnc                 `   d| j         v ot          | j         d         |          }|| j         v }|rX|sVd| dt          |           j         d| dt          |           j         d| d}t	          dd	|d
           | j        |         S t          dt          |           j         d| d          )aW  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
        rE   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__r8   typer,   r   rE   AttributeError)r    r;   is_in_configis_attributedeprecation_messages        r&   __getattr__zConfigMixin.__getattr__   s$    (4=8kWT]ScEdfj=k=kt}, 	- 	- #z  #z  #zW[\`WaWaWj  #z  #z  ^b  #z  #z  lp  qu  lv  lv  l  #z  #z  rv  #z  #z  #z17<O_deeee&t,,Xd!4XXQUXXXYYYr'   save_directorypush_to_hubc                    t           j                            |          rt          d| d          t          j        |d           t           j                            || j                  }|                     |           t          	                    d|            |r|
                    dd          }|
                    dd	          }|
                    d
d	          }|
                    dd          }|
                    d|                    t           j        j                  d                   }	t          |	d||          j        }	|                     ||	|||           dS dS )aI  
        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privateF	create_prtokenrepo_id)r^   r`   rb   )rb   r_   ra   )ospathisfileAssertionErrormakedirsjoinrF   to_json_filerI   infor2   splitsepr	   rc   _upload_folder)
r    r[   r\   r"   output_config_filer_   r`   ra   rb   rc   s
             r&   save_configzConfigMixin.save_config   so    7>>.)) 	h !f>!f!f!fggg
NT2222  W\\.$:JKK,---B.@BBCCC 	#ZZ(8$??NjjE22G

;66IJJw--EjjN,@,@,M,Mb,QRRG!'D'QVWWW_G-#       	 	r'   configc                 *   d|v r|                     d          }|t          d          t          |t                    sPd}d| j        v r
|d|  dz  }nd| j        v r|d	|  d
|  dz  }t          dd|d            | j        d|dd|\  }} | j        |fi |\  }}}d|v r|                     d          |d<   | j        D ]}||v r|                     |          ||<    | di |}	d|v r
| j        |d<    |	j	        di | i ||}|r|	|fS |	S )a
  
        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_pathNzFPlease 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-pathrP   FrQ   T)rt   return_unused_kwargsdtype_class_name )
r2   
ValueError
isinstancerH   r,   r   load_configextract_init_dict_deprecated_kwargsrM   )
clsrr   rw   r"   rY   	init_dictunused_kwargshidden_dictdeprecated_kwargmodels
             r&   from_configzConfigMixin.from_config   s   J +f44ZZ ?@@F>efff &$'' 	x"ncl**#-# - - -##
 CL((#Nc N NN N N#
 -w8K[`aaaa,S_w6hlwwpvwwNFF0E0Ef0W0WPV0W0W-	=+ m##!.!2!27!;!;Ig !$ 6 	R 	R=00.;.?.?@P.Q.Q	*+   i   K''),K&  //;/// 9=8K8 	=))Lr'   c                 N    d|  d}t          dd|d            | j        |i |S )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_dictrP   FrQ   )r   r}   )r   r!   r"   rY   s       r&   r   zConfigMixin.get_config_dict  sP    )s ) ) ) 	 	#W.AQVWWWWs////r'   rt   c                    |                     dd          }|                     dd          }|                     dd          }|                     dd          }|                     dd          }	|                     d	d          }
|                     d
d          }|                     dd          }|                     dd          }|                     dd          }|                     dd          }|                     di           }i |ddi}t          |          }t          |          }| j        t	          d          t
          j                            |          r|}n	t
          j                            |          r|kt
          j                            t
          j        	                    ||| j                            r(t
          j        	                    ||| j                  }n}t
          j                            t
          j        	                    || j                            r't
          j        	                    || j                  }nt          d| j         d| d          	 t          || j        |||
|	|||||||          }n# t          $ r t          | d          t          $ r t          | d| d          t          $ r t          | d| j         d          t          $ r}t          d| d|           d}~wt          $ r$ t          dt            d| d| j         d           t          $ r t          d!| d"| d#| j         d$          w xY w	 |                     |          }t%          |          }n-# t&          j        t*          f$ r t          d%| d&          w xY w|s|s|S |f}|r||fz  }|r||fz  }|S )'aN  
        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.
            resume_download:
                Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1
                of Diffusers.
            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resume_downloadproxiesrb   local_files_onlyrevisionmirror	subfolder
user_agent	file_typerr   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`zError no file named z found in directory .)filenamer   r   r   r   r   rb   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 `huggingface-cli 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 filez"It looks like the config file at 'z' is not a valid JSON file.)r2   r   strrF   r{   re   rf   rg   isdirrj   EnvironmentErrorr
   r   r   r   r   r   _dict_from_json_filer   jsonJSONDecodeErrorUnicodeDecodeError)r   rt   rw   return_commit_hashr"   r   r   r   r   r   r   rb   r   r   _r   r   config_fileerrconfig_dictcommit_hashoutputss                         r&   r}   zConfigMixin.load_config  s	   p JJ{D11	JJ{D11	!',Df!M!M$4e<< **%6==**Y--

7D))!::&8%@@::j$//JJx&&JJ{D11	ZZb11
:
:K::
$Z00
(+,I(J(J%?"s  
 7>>788 C	7KKW]]899 A	$:IsWW* *$ !gll+H)UXUdee-JCO \ \]]  gll+H#/ZZ&p3?ppPmppp  4-1 _'#1#$3%5)'%'+A   +   &4 q q q  
 )   & j j0Mj j j  
 &   &4nn\_\knnn      &@5@ @:=@ @      &Z/N Z Z>[Z Z/2Z Z Z   $   &;.K ; ;-J; ; %(O; ; ;  	r22;??K-k::KK$&89 	r 	r 	r"#p#p#p#pqqq	r % 	(: 	. 	!y G 	&~%Gs&   9!J A&M.LAM.2$N *Oc                     t          t          t          j        | j                  j                                                            S N)setrH   inspect	signaturer   
parameterskeys)input_classs    r&   _get_init_keyszConfigMixin._get_init_keys  s5    4)+*>??JKKPPRRSSSr'   c           	         |                     dg           fd|                                D             }t          |                                          }|                     |           }|                    d           d|v r|                    d           t          | d          r| j        D ]}|                    |           t          | j                  dk    r|t          | j                  z
  }t          j        t                              d          d                   }| j        rd |                                 D             }ng }t                      |D ],}|                     |          }	                    |	          -|                     |           z
  fd	|                                D             }|                    d
| j                  }
t%          |
t&                    rd|
| j        k    rYt          ||
          rIt)          ||
          }|                     |          |z
  fd|                                D             }n@t%          |
t&                    s+t%          |
t*          t,          f          st/          d          d |                                D             }i |D ][}||v r||v r|                    |          ||<   ||v r|                    |          |<   ?||v r|                    |          |<   \t          |          dk    r.t0                              d| d| j         d| j         d           t                                                    }t          ||z
            dk    r t0                              ||z
   d           i ||}fd|                                D             }||fS )N_use_default_valuesc                 0    i | ]\  }}|v	|d k    ||S )r   rz   ).0kvused_defaultss      r&   
<dictcomp>z1ConfigMixin.extract_init_dict.<locals>.<dictcomp>  s5    uuu1q?U?UZ[_tZtZtq!ZtZtZtr'   r    r"   _flax_internal_argsr   r   c                 <    g | ]}t          |t                    |S rz   )r|   r   )r   cs     r&   
<listcomp>z1ConfigMixin.extract_init_dict.<locals>.<listcomp>  s)    !f!f!f:VWYdKeKe!f!!f!f!fr'   c                 $    i | ]\  }}|v	||S rz   rz   )r   r   r   expected_keys_comp_clss      r&   r   z1ConfigMixin.extract_init_dict.<locals>.<dictcomp>  s*    ___1qH^?^?^q!?^?^?^r'   ry   c                 $    i | ]\  }}|v	||S rz   rz   )r   r   r   unexpected_keys_from_origs      r&   r   z1ConfigMixin.extract_init_dict.<locals>.<dictcomp>  s*    fffDAq1LeCeCe1aCeCeCer'   z\Make sure that the `_class_name` is of type string or list of string (for custom pipelines).c                 D    i | ]\  }}|                     d           ||S r   
startswithr   r   r   s      r&   r   z1ConfigMixin.extract_init_dict.<locals>.<dictcomp>  s0    UUU11<<PSCTCTUq!UUUr'   z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.c                 $    i | ]\  }}|v	||S rz   rz   )r   r   r   r   s      r&   r   z1ConfigMixin.extract_init_dict.<locals>.<dictcomp>(  s*    [[[tq!QZHZHZaHZHZHZr'   )getr   rH   r   remover8   r   lenignore_for_configr   	importlibimport_moduler,   rm   has_compatibles_get_compatiblesunionr2   r|   r   getattrlisttupler{   rI   warningrF   r   rl   )r   r   r"   original_dictexpected_keysargdiffusers_librarycompatible_classesr   expected_keys_corig_cls_nameorig_clsr#   passed_keysr   hidden_config_dictr   r   r   r   s                   @@@@r&   r~   zConfigMixin.extract_init_dict  s`    $(=rBBuuuu(9(9(;(;uuu [..0011 **3//V$$$}$$  ***3-.. 	*. * *$$S)))) s$%%)))C0E,F,FFM &3HNN34G4G4JKK 	$!f!fS-A-A-C-C!f!f!f!#!$# 	S 	SA!0033O%;%A%A/%R%R""!7#:L:LS:Q:Q!Q____(9(9(;(;___ $s|DD}c**	--)=99 . 0-@@H(+(:(:8(D(D}(T%ffffK,=,=,?,?fffKKM3// 	
=SWY^R_8`8` 	n  
 VU(9(9(;(;UUU 	  	6 	6C f}}!3!3#)::c??C f}}!'C	###!,!5!5	# {aNN9 9 9cl 9 9?9 9 9   )..**++}{*++a//KK ;.www  
 2;1&1 \[[[}/B/B/D/D[[[-);;;r'   	json_filec                     t          |dd          5 }|                                }d d d            n# 1 swxY w Y   t          j        |          S )Nrutf-8encoding)openreadr   loads)r   r   readertexts       r&   r   z ConfigMixin._dict_from_json_file,  s    )S7333 	!v;;==D	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!z$s   488c                 H    | j         j         d|                                  S )N )r%   r,   to_json_stringr    s    r&   __repr__zConfigMixin.__repr__2  s'    .)CCD,?,?,A,ACCCr'   c                     | j         S )z
        Returns the config of the class as a frozen dictionary

        Returns:
            `Dict[str, Any]`: Config of the class.
        )rE   r   s    r&   rr   zConfigMixin.config5  s     ""r'   c                 :   t          | d          r| j        ni }| j        j        |d<   t          |d<   d fd|                                D             }|                    dd           |                    dd           t          j        |d	d
          dz   S )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.
        rE   ry   _diffusers_versionc                     t          | t          j                  r|                                 } n$t          | t                    rt          |           } | S r   )r|   npndarraytolistr   r   )r$   s    r&   to_json_saveablez4ConfigMixin.to_json_string.<locals>.to_json_saveableK  sG    %,, #E9-- #E

Lr'   c                 .    i | ]\  }}| |          S rz   rz   )r   r   r   r   s      r&   r   z.ConfigMixin.to_json_string.<locals>.<dictcomp>R  s+    NNN$!Qq**1--NNNr'   _ignore_filesNr      T)indent	sort_keys
)	r8   rE   r%   r,   r   r   r2   r   dumps)r    r   r   s     @r&   r   zConfigMixin.to_json_string?  s     .5T;K-L-LTd))RT%)^%<M",7()	 	 	 ONNN+:K:K:M:MNNN...-t444z+a4@@@4GGr'   json_file_pathc                     t          |dd          5 }|                    |                                            ddd           dS # 1 swxY w Y   dS )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&   rk   zConfigMixin.to_json_fileY  s     .#888 	0FLL,,..///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   (AAA)FNF)FF)"r,   r?   r@   __doc__rF   r   r   r   rM   r   r   rZ   r   re   PathLikeboolrq   classmethodr   r   r   r   r   r   r}   staticmethodr   r~   r   r   propertyrr   r   rk   rz   r'   r&   rC   rC   W   sr          KO8 8 8"Z Z Z Z Z Z$( (%R[0@*A (PT ( ( ( (T W Wz4S>'A!B W W W [Wr 0 0 [0  # 	f f',S"+-='>f 
tCH~tCH~-	.f f f  [fP T T \T ]< ]< []<~  U33C-D       [ 
D D D #S#X # # # X#H H H H H4	05bk1A+B 	0 	0 	0 	0 	0 	0r'   rC   c                 F     t          j                    fd            }|S )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                   	
 d |                                 D             	d |                                 D             }t          | t                    st          d| j        j         d          t          | dg           i 
t          j                  }fdt          |j
                                                   D             }t          ||                                          D ]
\  }}|
|<   
                    	
fd|                                 D                        t          t          
                                          t          	          z
            dk    rAt!          t          
                                          t          	          z
            
d	<   i |

 t          | d
          di 
  | g|R i 	 d S )Nc                 D    i | ]\  }}|                     d           ||S r   r   r   s      r&   r   z:register_to_config.<locals>.inner_init.<locals>.<dictcomp>q  s/    PPP1all3>O>OPq!PPPr'   c                 D    i | ]\  }}|                     d           ||S r   r   r   s      r&   r   z:register_to_config.<locals>.inner_init.<locals>.<dictcomp>r  s/    SSStq!cARARSaSSSr'   &`@register_for_config` was applied to A init method, but this class does not inherit from `ConfigMixin`.r   c                 @    i | ]\  }\  }}|d k    |v||j         S )r   )default)r   ir;   pignores       r&   r   z:register_to_config.<locals>.inner_init.<locals>.<dictcomp>}  sD     
 
 
 ,9D![\_`[`[`eiqwewewD!)ewewewr'   c                 T    i | ]$\  }}|v	|v|                     ||          %S rz   )r   )r   r   r  r  init_kwargs
new_kwargss      r&   r   z:register_to_config.<locals>.inner_init.<locals>.<dictcomp>  sJ       AwF??q
':': ;??1g..':':':r'   r   r   rM   rz   )r   r|   rC   RuntimeErrorr%   r,   r   r   r   	enumerater   zipr   r4   r   r   r   )r    r!   r"   config_init_kwargsr   r   r   r;   r  r  r  inits           @@@r&   
inner_initz&register_to_config.<locals>.inner_initn  s1    QPPPPSSv||~~SSS$,, 	29P 2 2 2  
 2B77
%d++	
 
 
 
09):N:T:T:V:V0W0W
 
 

 T:??#4#455 	# 	#IC"Jt 	     ","2"2"4"4  	
 	
 	
 s:??$$%%K(8(8899A==04S9J9J5K5KcR]N^N^5^0_0_J,-9*9j9
+*++99j999T(D(((K(((((r'   )	functoolswraps)r  r  s   ` r&   rM   rM   e  s<     _T#) #) #) #) #)J r'   c                 b    | j         t          j                  fd            }|| _         | S )Nc                 l   t          | t                    st          d| j        j         d          t          |                                          }t          j        |           }i }|D ][}|j	        | j
        v rt          |j                  t          j        k    rd ||j	        <   >t          | |j	                  ||j	        <   \i ||}d|v r|                    d           t!          |          D ]\  }}	||         j	        }
|	||
<   t#          t%          |                                          t%          |          z
            dk    rAt)          t%          |                                          t%          |          z
            |d<    t          | d          di |  | g|R i | d S )Nr  r  rx   r   r   rM   rz   )r|   rC   r  r%   r,   rH   r   dataclassesfieldsr;   r   rU   r  _MISSING_TYPEr   r2   r  r   r   r   r   )r    r!   r"   r  r!  default_kwargsfieldr  r  r   r;   original_inits              r&   r  z%flax_register_to_config.<locals>.init  s   $,, 	29P 2 2 2   6<<>>** #D)) 	G 	GEzT555EM""k&???-1uz**-4T5:-F-Fuz** 76+6
j  NN7###  oo 	# 	#FAs!9>D"Jt s:??$$%%K(8(8899A==04S9J9J5K5KcR]N^N^5^0_0_J,-+*++99j999d,T,,,V,,,,,r'   )r   r  r  )r   r  r%  s     @r&   flax_register_to_configr&    sG    LM_]##&- &- &- &- $#&-P CLJr'   c                   P    e Zd ZdZeddeeeee	f         f         fd            Z
dS )LegacyConfigMixinz
    A subclass of `ConfigMixin` to resolve class mapping from legacy classes (like `Transformer2DModel`) to more
    pipeline-specific classes (like `DiTTransformer2DModel`).
    NFrr   c                 D    ddl m}  |||           } |j        ||fi |S )Nr   )_fetch_remapped_cls_from_config)models.model_loading_utilsr*  r   )r   rr   rw   r"   r*  remapped_classs         r&   r   zLegacyConfigMixin.from_config  sI     	POOOOO 98EE)~)&2FQQ&QQQr'   r  )r,   r?   r@   r  r  r   r   r   r   r   r   rz   r'   r&   r(  r(    sd         
 R Rz4S>'A!B R R R [R R Rr'   r(  )0r  r   r  r   r   r   re   recollectionsr   pathlibr   typingr   r   r   r   numpyr   huggingface_hubr	   r
   huggingface_hub.utilsr   r   r   r   requestsr    r   utilsr   r   r   r   r   r   
get_loggerr,   rI   compile_re_configuration_filer   rC   rM   r&  r(  rz   r'   r&   <module>r:     sT    , +               				 				 # # # # # #       * * * * * * * * * * * *     8 8 8 8 8 8 8 8                                       
	H	%	%#$9:: ) ) ) ) ) ) ) )@K0 K0 K0 K0 K0 K0 K0 K0\/ / /d- - -`R R R R R R R R R Rr'   