
    Z j                        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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JrJr  SSKJr  SS	KJrJrJrJrJr  SS
KJ r J!r!  \RD                  " \#5      r$S\%S\%4S jr&\RN                  " 5       r(S r)S\%\RT                  -  SS4S jr+S\%\RT                  -  S\,\%   4S jr-S\%\RT                  -  S\,\%   4S jr.S\%\RT                  -  S\,\%   4S jr/S\%\RT                  -  S\,\%   4S jr0SS.S\%S\%\RT                  -  S\1S\24S jjr3S\%\RT                  -  S\%\RT                  -  S\%\RT                  -  S\,\%   S\%4
S jr4        S4S\%\RT                  -  S\%S \%\RT                  -  S-  S!\1S"\5\%\%4   S-  S#\1\%-  S-  S$\%S-  S%\1S&\%S-  S'\%S-  S\%4S( jjr6        S4S)\%S\%\RT                  -  S \%\RT                  -  S-  S!\1S"\5\%\%4   S-  S#\1\%-  S-  S$\%S-  S%\1S&\%S-  S*\%S-  S\24S+ jjr7S5S,\S-\%\RT                  -  S.\5S-  S\,\%   4S/ jjr8S0 r9S1r: S6S2 jr;S7S3 jr<g)8z3Utilities to dynamically load objects from the Hub.    N)Path)
ModuleType)Any)is_offline_modetry_to_load_from_cache)version   )HF_MODULES_CACHE TRANSFORMERS_DYNAMIC_MODULE_NAMEcached_fileextract_commit_hashlogging)VersionComparisonsplit_package_versionnamereturnc                 f   U R                  SS5      R                  SS5      nU(       a  US   R                  5       (       a  SU 3n[        R                  " U5      (       a  [        R                  SU SU  S	35        U$ UR                  5       (       d  [        R                  SU SU  S
35        U$ )a  
Tries to sanitize a module name so that it can be used as a Python module.

The following transformations are applied:

1. Replace `.` in module names with `_dot_`.
2. Replace `-` in module names with `_hyphen_`.
3. If the module name starts with a digit, prepend it with `_`.
4. Warn if the sanitized name is a Python reserved keyword or not a valid identifier.

If the input name is already a valid identifier, it is returned unchanged.
._dot_-_hyphen_r   _zThe module name z (originally z\) is a reserved keyword in Python. Please rename the original module to avoid import issues.z]) is not a valid Python identifier. Please rename the original module to avoid import issues.)replaceisdigitkeyword	iskeywordloggerwarningisidentifier)r   new_names     r/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/dynamic_module_utils.py_sanitize_module_namer"   1   s    " ||C)11#zBHHQK''))xj>""xjdV <H H	
 O ""$$xjdV <H H	
 O    c                  H   [         [        R                  ;   a  g[        R                  R                  [         5        [        R
                  " [         SS9  [        [         5      S-  n U R                  5       (       d&  U R                  5         [        R                  " 5         gg)zW
Creates the cache directory for modules with an init, and adds it to the Python path.
NTexist_ok__init__.py)r
   syspathappendosmakedirsr   existstouch	importlibinvalidate_caches)	init_paths    r!   init_hf_modulesr2   U   sm    
 388#HHOO$%KK 40%&6I##% r#   c                 j   [        5         [        [        5      U -  R                  5       nUR                  R                  5       (       d  [        UR                  5        [        R                  " USS9  US-  nUR                  5       (       d&  UR                  5         [        R                  " 5         gg)z
Creates a dynamic module in the cache directory for modules.

Args:
    name (`str` or `os.PathLike`):
        The name of the dynamic module to create.
Tr%   r'   N)r2   r   r
   resolveparentr-   create_dynamic_moduler+   r,   r.   r/   r0   )r   dynamic_module_pathr1   s      r!   r6   r6   e   s      01D8AAC%%,,..1889KK#d3#m3I 	##%	 r#   module_filec                 (   [        U SS9 nUR                  5       nSSS5        [        R                  " SW[        R                  S9nU[        R                  " SU[        R                  S9-  n[        [        U5      5      $ ! , (       d  f       Nm= f)z
Get the list of modules that are relatively imported in a module file.

Args:
    module_file (`str` or `os.PathLike`): The module file to inspect.

Returns:
    `list[str]`: The list of relative imports in the module.
utf-8encodingNz^\s*import\s+\.(\S+)\s*$)flagsz^\s*from\s+\.(\S+)\s+import)openreadrefindall	MULTILINElistset)r8   fcontentrelative_importss       r!   get_relative_importsrH   {   st     
kG	,&&( 
- zz"=wbll[

#A7RTR^R^__$%&& 
-	,s   B
Bc                 l   SnU /n/ nU(       d  / nU H  nUR                  [        U5      5        M     [        U 5      R                  nU Vs/ s H  n[	        Xg-  5       S3PM     nnU Vs/ s H  oUU;  d  M
  UPM     nn[        U5      S:H  nUR                  U5        U(       d  M  U$ s  snf s  snf )a  
Get the list of all files that are needed for a given module. Note that this function recurses through the relative
imports (if a imports b and b imports c, it will return module files for b and c).

Args:
    module_file (`str` or `os.PathLike`): The module file to inspect.

Returns:
    `list[str]`: The list of all relative imports a given module needs (recursively), which will give us the list
    of module files a given module needs.
F.pyr   )extendrH   r   r5   strlen)	r8   	no_changefiles_to_checkall_relative_importsnew_importsrE   module_pathmnew_import_filess	            r!   get_relative_import_filesrU      s     I!]N A3A67   ;'..BMN+Qs;?34C8+N%5W%5BV9V!%5W'1,	##N3 i   OWs   B,-	B1:B1filenamec                    ^^^ [        U SS9 nUR                  5       nSSS5        [        5       mSSKmUUU4S jm[        R
                  " W5      nT" U5        [        T5      $ ! , (       d  f       NM= f)z
Extracts all the libraries (not relative imports this time) that are imported in a file.

Args:
    filename (`str` or `os.PathLike`): The module file to inspect.

Returns:
    `list[str]`: The list of all packages required to use the input module.
r:   r;   Nr   c                   > [        U [        R                  5      (       a  g [        U [        R                  5      (       a  U R                  n[        R
                  " U5       H  n[        U[        R                  5      (       d  M$  [        UR                  SS5      nUR                  S5      (       a  UR                  S5      (       d'  [        T	R                  R                  U5      (       d  M    g    O[        U [        R                  5      (       aL  U R                   H;  nUR                   R#                  S5      S   nU(       d  M*  TR%                  U5        M=     Ov[        U [        R&                  5      (       aW  U R(                  S:X  aG  U R*                  (       a6  U R*                  R#                  S5      S   nU(       a  TR%                  U5        [        R,                  " U 5       H  nT" U5        M     g )Nid 	availableis_flash_attnr   r   )
isinstanceastTryIftestwalkCallgetattrfuncendswith
startswithhasattrutilsimport_utilsImportnamesr   splitadd
ImportFromlevelmoduleiter_child_nodes)
nodera   condition_nodecheck_functionalias
top_modulechildimported_modulesrecursive_look_for_importstransformerss
          r!   rz   /get_imports.<locals>.recursive_look_for_imports   sb   dCGG$$cff%%99D"%((4.nchh77%,^-@-@$%KN&//<<*55oFF"<#5#5#B#BNSS  #1 cjj))"ZZ--c215
:$((4 $ cnn--zzQ4;;![[..s3A6
$((4 ))$/E&u- 0r#   )r>   r?   rD   transformers.utilsr^   parsesorted)rV   rE   rF   treery   rz   r{   s       @@@r!   get_importsr      s`     
h	)Q&&( 
*u.B 99WDt$"##U 
*	)s   A&&
A4c                    [        U 5      n/ nU H  n [        R                  " U5        M     [        U5      S:  a0  [        SSR                  U5       SS	R                  U5       S
35      e[        U 5      $ ! [         aG  n[        R                  SU SU 35        S[        U5      ;   a  UR                  U5         SnAM  e SnAff = f)a  
Check if the current Python environment contains all the libraries that are imported in a file. Will raise if a
library is missing.

Args:
    filename (`str` or `os.PathLike`): The module file to check.

Returns:
    `list[str]`: The list of relative imports in the file.
z&Encountered exception while importing z: zNo module namedNr   z\This modeling file requires the following packages that were not found in your environment: z, z. Run `pip install  `)r   r/   import_moduleImportErrorr   r   rL   r*   rM   joinrH   )rV   importsmissing_packagesimp	exceptions        r!   check_importsr      s     (#G
	##C(  q jyy)*++>sxxHX?Y>ZZ[]
 	

  ))!  	NNCC59+VW !C	N2 '',,	s   A88
C	;CCC	Fforce_reload
class_namerR   r   c          
         [         R                  R                  U5      nUR                  S5      nUR	                  [         R                  R
                  S5      n[        [        5      U-  n[           U(       a5  [        R                  R                  US5        [        R                  " 5         [        R                  R                  U5      n[        R                  R!                  X4S9nU/[#        [%        [        ['        U5      5      5      -   n[(        R*                  " SR-                  S U 5       5      5      R/                  5       nUc3  [        R                  R1                  U5      n	U	[        R                  U'   OUn	[3        U	SS5      U:w  a!  UR4                  R7                  U	5        Xl        [3        X5      sSSS5        $ ! , (       d  f       g= f)	a  
Import a module on the cache directory for modules and extract a class from it.

Args:
    class_name (`str`): The name of the class to import.
    module_path (`str` or `os.PathLike`): The path to the module to import.
    force_reload (`bool`, *optional*, defaults to `False`):
        Whether to reload the dynamic module from file if it already exists in `sys.modules`.
        Otherwise, the module is only reloaded if the file has changed.

Returns:
    `typing.Type`: The class looked for.
rJ   r   N)locationr#   c              3   Z   #    U  H!  n[        U5      UR                  5       -   v   M#     g 7fN)bytes
read_bytes).0rE   s     r!   	<genexpr>&get_class_in_module.<locals>.<genexpr>*  s"     2cVbQR58alln3LVbs   )+__transformers_module_hash__rZ   )r+   r)   normpathremovesuffixr   sepr   r
   _HF_REMOTE_CODE_LOCKr(   modulespopr/   r0   getutilspec_from_file_locationr   maprU   hashlibsha256r   	hexdigestmodule_from_specrd   loaderexec_moduler   )
r   rR   r   r   r8   cached_modulemodule_specmodule_filesmodule_hashrq   s
             r!   get_class_in_moduler   
  sT   & 77K(DU#D<<S)D-.<K	KKOOD$''')+.;;??4+@nn<<T<X %0=6#dD]^iDj:k3l#l">>#((2cVb2c*cdnnp  ^^44[AF &CKK"F692>+M**622=/v*- 
		s   3EG


Gpretrained_model_name_or_pathresolved_module_filemodules_neededc                 <  ^ [        U 5      R                  5       m[        U5      R                  n[        U5      R                  5       nS[         S[        4U4S jjnU" U5      U4/nU H5  nTU-  U S3-  R                  5       nUR	                  U" U5      U45        M7     [
        R                  " 5       n	[        US S9 HD  u  pU	R                  U
R                  S5      5        U	R                  UR                  5       5        MF     U	R                  5       SS	 $ )
zm
Computes a stable hash from the bytes of the local source file and its direct relative-import source files.
source_file_pathr   c                    >  U R                  T5      R                  5       $ ! [         a    U R                  5       s $ f = fr   )relative_toas_posix
ValueError)r   
model_paths    r!   _resolve_relative_source_pathG_compute_local_source_files_hash.<locals>._resolve_relative_source_pathH  s@    	/#//
;DDFF 	/#,,..	/s   " ??rJ   c                     U S   $ )Nr    )entrys    r!   <lambda>2_compute_local_source_files_hash.<locals>.<lambda>W  s	    ERSHr#   )keyr:   N   )r   r4   r5   rL   r*   r   r   r   updateencoder   r   )r   r8   r   r   module_parentr   files_to_hashmodule_neededmodule_needed_pathsource_files_hashrelative_path	file_pathr   s               @r!    _compute_local_source_files_hashr   :  s    34<<>J%,,M 45==?/ / / 
'';	<>RSM ((=8m_C;PPYY[;<NOQcde (  ($*=>T$U   !5!5g!>?  !5!5!78 %V &&("--r#   	cache_dirforce_downloadproxiestokenrevisionlocal_files_only	repo_type_commit_hashc
                 	   [        5       (       a  U(       d  [        R                  S5        Sn[        U 5      n [        R
                  R                  U 5      nSnU(       dQ  [        R
                  R                  R                  [        [        U R                  S5      5      5      n[        XX)US9n/ n [        U UUUUUUUUU	S9
nU(       d  X:w  a  UR                  U5        [!        U5      nU(       a  [        [        R
                  R#                  [        R
                  R%                  U 5      5      5      n['        XUU5      nU(       a,  [        R
                  R                  R                  UU/5      nOUn[(        [        R
                  R                  -   W-   n[+        U5        [-        [.        5      U-  nU(       GaC  UU-  R1                  5       (       a(  [2        R4                  " U[        UU-  5      5      (       dL  UU-  R6                  R9                  SSS
9  [:        R<                  " UUU-  5        [>        R@                  " 5         U H  n[-        U5      R6                  U S3-  n[        R
                  R                  U U5      nUU-  R1                  5       (       a*  [2        R4                  " U[        UU-  5      5      (       a  M  [:        R<                  " UUU-  5        [>        R@                  " 5         M     GO&[C        X5      nUU-  nU[        R
                  R                  -   U-   n[        R
                  R                  UU5      n[+        [-        U5      R6                  5        UU-  R1                  5       (       d/  [:        R<                  " UUU-  5        [>        R@                  " 5         U Hk  nUU-  R6                  U S3-  R1                  5       (       a  M-  [E        U [-        U5      R6                  U-   S3UUUUUUUS9	  UR                  U S35        Mm     [G        U5      S:  aU  UcR  SR                  U Vs/ s H  nSU 3PM
     sn5      nUc  SOU S3nSU U  3n[        RI                  SU SU S35        [        R
                  R                  UU5      $ ! [         a    [        R                  SU SU  S	35        e f = fs  snf )a  
Prepares Downloads a module from a local folder or a distant repo and returns its path inside the cached
Transformers module.

Args:
    pretrained_model_name_or_path (`str` or `os.PathLike`):
        This can be either:

        - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
          huggingface.co.
        - a path to a *directory* containing a configuration file saved using the
          [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`.

    module_file (`str`):
        The name of the module file containing the class to look for.
    cache_dir (`str` or `os.PathLike`, *optional*):
        Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
        cache should not be used.
    force_download (`bool`, *optional*, defaults to `False`):
        Whether or not to force to (re-)download the configuration files and override the cached versions if they
        exist.
    proxies (`dict[str, str]`, *optional*):
        A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
        'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
    token (`str` or *bool*, *optional*):
        The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
        when running `hf auth login` (stored in `~/.huggingface`).
    revision (`str`, *optional*, defaults to `"main"`):
        The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
        git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
        identifier allowed by git.
    local_files_only (`bool`, *optional*, defaults to `False`):
        If `True`, will only try to load the tokenizer configuration from local files.
    repo_type (`str`, *optional*):
        Specify the repo type (useful when downloading from a space for instance).

<Tip>

Passing `token=True` is required when you want to use a private model.

</Tip>

Returns:
    `str`: The path to the module inside the cache.
z+Offline mode: forcing local_files_only=TrueTN/)r   r   r   )r   r   r   r   r   r   r   r   zCould not locate the z inside r   )parentsr&   rJ   )r   r   r   r   r   r   r   r   
z- rZ   zs/zhttps://huggingface.co/z9A new version of the following files was downloaded from z:
z
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.)%r   r   inforL   r+   r)   isdirr   r   r   r"   rm   r   r   r*   OSErrorr   basenamer   r   r   r6   r   r
   r-   filecmpcmpr5   mkdirshutilcopyfiler/   r0   r   get_cached_module_filerM   r   )r   r8   r   r   r   r   r   r   r   r   deprecated_kwargsis_localr   	submodule	new_filesr   r   local_model_namelocal_source_files_hashfull_submodulesubmodule_pathr   module_needed_filecommit_hashfull_submodule_module_file_pathrE   repo_type_strurls                               r!   r   r   ^  sk   t !1AB %((E$F!ww}}:;HMGGKK$$S)>@]@c@cdg@h%ij	.))nw
 I*))-% 
 MA[) ##78N01A1A"''BRBRSpBq1rs"B)8Ln#
 ((*:<S)TUI/I 6CiON.)*+n<N ,4466gkk #n{&B"C?
 ?
 k)1177t7TOO0.;2NO'')+M -44-7LLM!#.K]!["]2::<<GKK"C(F$GE E  2N]4RS++- , **>M (+5'"''++5C*,'',,~{*S'd#BCJJK,4466OO0.;2NO'')+M#k199}oS<QQYY[[&1K(//-?@D'#1#%%5!,
   M?#!67 , 9~h.II;AA3x;<	'/	{"5E'7T6UVGuCPY{AA	
 77<<44[  +K=A^@__`abH <s   5/R3 S3(Sclass_referencecode_revisionc
                     SU ;   a  U R                  S5      u  pOUnU R                  S5      u  pU	c  X:X  a  Un	[        UUS-   UUUUU	UUS9	n[        XUS9$ )a  
Extracts a class from a module file, present in the local folder or repository of a model.

<Tip warning={true}>

Calling this function will execute the code in the module file found locally or downloaded from the Hub. It should
therefore only be called on trusted repos.

</Tip>



Args:
    class_reference (`str`):
        The full name of the class to load, including its module and optionally its repo.
    pretrained_model_name_or_path (`str` or `os.PathLike`):
        This can be either:

        - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
          huggingface.co.
        - a path to a *directory* containing a configuration file saved using the
          [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`.

        This is used when `class_reference` does not specify another repo.
    module_file (`str`):
        The name of the module file containing the class to look for.
    class_name (`str`):
        The name of the class to import in the module.
    cache_dir (`str` or `os.PathLike`, *optional*):
        Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
        cache should not be used.
    force_download (`bool`, *optional*, defaults to `False`):
        Whether or not to force to (re-)download the configuration files and override the cached versions if they
        exist.
    proxies (`dict[str, str]`, *optional*):
        A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
        'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
    token (`str` or `bool`, *optional*):
        The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
        when running `hf auth login` (stored in `~/.huggingface`).
    revision (`str`, *optional*, defaults to `"main"`):
        The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
        git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
        identifier allowed by git.
    local_files_only (`bool`, *optional*, defaults to `False`):
        If `True`, will only try to load the tokenizer configuration from local files.
    repo_type (`str`, *optional*):
        Specify the repo type (useful when downloading from a space for instance).
    code_revision (`str`, *optional*, defaults to `"main"`):
        The specific revision to use for the code on the Hub, if the code leaves in a different repository than the
        rest of the model. It can be a branch name, a tag name, or a commit id, since we use a git-based system for
        storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git.

<Tip>

Passing `token=True` is required when you want to use a private model.

</Tip>

Returns:
    `typing.Type`: The class, dynamically imported from the module.

Examples:

```python
# Download module `modeling.py` from huggingface.co and cache then extract the class `MyBertModel` from this
# module.
cls = get_class_from_dynamic_module("modeling.MyBertModel", "sgugger/my-bert-model")

# Download module `modeling.py` from a given repo and cache then extract the class `MyBertModel` from this
# module.
cls = get_class_from_dynamic_module("sgugger/my-bert-model--modeling.MyBertModel", "sgugger/another-bert-model")
```z--r   rJ   )r   r   r   r   r   r   r   r   )rm   r   r   )r   r   r   r   r   r   r   r   r   r   kwargsrepo_idr8   r   final_modules                  r!   get_class_from_dynamic_moduler     s    n #2#8#8#> /-33C8K!>!I )e%)
L znUUr#   objfolderconfigc                 t  ^  T R                   S:X  a  [        R                  ST  SU S35        gU 4S jn[        U[        [
        45      (       a  U H  nU" U5        M     OUb  U" U5        / n[        R                  T R                      R                  n[        U5      [        U5      R                  -  n[        R                  " Xg5        UR                  U5        [        U5       HK  n[        U5      [        U5      R                  -  n[        R                  " X5        UR                  U5        MM     U$ )a  
Save the modeling files corresponding to a custom model/configuration/tokenizer etc. in a given folder. Optionally
adds the proper fields in a config.

Args:
    obj (`Any`): The object for which to save the module files.
    folder (`str` or `os.PathLike`): The folder where to save.
    config (`PreTrainedConfig` or dictionary, `optional`):
        A config in which to register the auto_map corresponding to this custom object.

Returns:
    `list[str]`: The list of files saved.
__main__z We can't save the code defining z in z as it's been defined in __main__. You should put this code in a separate module so we can include it in the saved folder and make it easier to share via the Hub.Nc                   > T
R                   R                  nUR                  S5      S   nU ST
R                   R                   3nSU;   a  S nS nT
R                   R                  R	                  S5      (       ag  U ST
R                   R                   3n[        T
SS 5      b=  [        T
S5      nUR                  nUR                  S5      S   nU SUR                   3nOU ST
R                   R                   3nXE4n[        U [        5      (       a%  U R                  S0 5      n	X9T
R                  '   XS'   g [        U SS 5      b  X0R                  T
R                  '   g T
R                  U0U l
        g )Nr   	TokenizerFastslow_tokenizer_classauto_map)	__class__
__module__rm   __name__rf   rd   r]   dictr   _auto_classr   )_configmodule_namelast_module	full_namer   fast_tokenizer_classslow_tokenizerslow_tok_module_namelast_slow_tok_moduler   r   s             r!   _set_auto_map_in_config3custom_object_save.<locals>._set_auto_map_in_config  so   mm..!'',R0"m1S]]%;%;$<=	)##' #' }}%%..v66*5a8N8N7O'P$3 6=I%,S2H%IN+9+D+D(+?+E+Ec+J2+N(.B-C1^E\E\D]+^( +6a8N8N7O'P$-DIgt$${{:r2H(1S__%"*JWj$/;09S__- #;Gr#   )r  r   r   r]   rC   tupler(   r   __file__r   r   r   r   r*   rU   )	r   r   r   r  cfgresultobject_file	dest_fileneeded_files	   `        r!   custom_object_saver  v  s
    ~~#.se4x @ 	

 	<@ &4-((C#C( 		'F++cnn-66KV[ 1 6 67I
OOK+
MM) 1=LD$5$:$:;	/i  >
 Mr#   c                     [        S5      e)NzLoading this model requires you to execute custom code contained in the model repository on your local machine. Please set the option `trust_remote_code=True` to permit loading of this model.)r   )signumframes     r!   _raise_timeout_errorr    s    
	c r#      c                    Ucd  Ub  SU SU SU S3nOT[         R                  R                  U5      (       a'  SU S[         R                  R                  U5       S3nO	SU SU S3nU Gc  U(       a  Sn GOU(       a  [        S	:  a  Sn [
        R
                  " [
        R                  [        5      n[
        R                  " [        5        U cC  [        U S
U S35      nUR                  5       S;   a  Sn OUR                  5       S;   a  Sn U c  MC  [
        R                  " S	5         Ub;  [
        R
                  " [
        R                  U5        [
        R                  " S	5        OU(       a  [        SS5        U(       a  U(       d  U (       d  [        U S
U S35      eU $ ! [         a    [        U S
U S35      ef = f! Ub<  [
        R
                  " [
        R                  U5        [
        R                  " S	5        f f = f)a  
Resolves the `trust_remote_code` argument. If there is remote code to be loaded, the user must opt-in to loading
it.

Args:
    trust_remote_code (`bool` or `None`):
        User-defined `trust_remote_code` value.
    model_name (`str`):
        The name of the model repository in huggingface.co.
    has_local_code (`bool`):
        Whether the model has local code.
    has_remote_code (`bool`):
        Whether the model has remote code.
    error_message (`str`, *optional*):
        Custom error message to display if there is remote code to load and the user didn't opt-in. If unset, the error
        message will be regarding loading a model with custom code.

Returns:
    The resolved `trust_remote_code` value.
NzThe repository z% references custom code contained in zm which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/z .
zt contains custom code which must be executed to correctly load the model. You can inspect the repository content at z contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/Fr   z9 You can inspect the repository content at https://hf.co/z.
You can avoid this prompt in future by passing the argument `trust_remote_code=True`.

Do you wish to run the custom code? [y/N] )yesy1T)non0rZ   zS.
Please pass the argument `trust_remote_code=True` to allow custom code to be run.)r+   r)   r   abspathTIME_OUT_REMOTE_CODEsignalSIGALRMr  alarminputlower	Exceptionr   )trust_remote_code
model_namehas_local_codehas_remote_codeerror_messageupstream_repoprev_sig_handleranswers           r!   resolve_trust_remote_coder4    s   . $!*-RS`Ra b,,9?$@ 
 WW]]:&&!* . ggooj9:$@  "* .,,6<t=    %!5!9#$#)==AU#V 12'/"(/)bcmbn oE FF
 ||~)::,0)+??,1) (/ Q $/MM&..2BCLLO t,~6GoVWaVb c` a
 	

 )   $o%^_i^j kh i  $/MM&..2BCLLO 0s    BF% F% %GG AHc                 ^   / n [        SXS.UD6n[        US5       nUR                  5       nSSS5        U H  nUR                  5       nU(       a  UR	                  S5      (       a  M2   [        U5      u  pxn	 [        R                  R                  U5      n
UbR  U	bO  [        R                  " U5      R                  [        R                  " U
5      [        R                  " U	5      5      nOSnU(       a  M  UR                  U SU
 S	35        M     U(       a!  [#        S
U  S3SR%                  U5      -   5      eg! , (       d  f       GN= f! [         a	    UnSu  p Nf = f! [        R                  R                   a    UR                  U S35         GMc  f = f! [          a     Nf = f)a  
Tries to locate `requirements_file` in a local folder or repo, and confirms that the environment has all the
python dependencies installed.

Args:
    path_or_repo_id (`str` or `os.PathLike`):
        This can be either:
        - a string, the *model id* of a model repo on huggingface.co.
        - a path to a *directory* potentially containing the file.
    kwargs (`dict[str, Any]`, *optional*):
        Additional arguments to pass to `cached_file`.
)path_or_repo_idrV   rN#NNz (installed: None)Tz (installed: )z4Missing requirements in your local environment for `z`:
r   r   )r   r>   	readlinesstriprg   r   r   r/   metadatar   PackageNotFoundErrorr*   r   from_stringvaluer~   r   r   r   )r6  requirements_filer   failedrequirementsrE   requirementpackage_name	delimiterversion_numberlocal_package_versionis_satisfieds               r!   check_python_requirementsrJ  !  s    F""i?ibhi,$;;=L % (K%++-K+"8"8"="=7:OP[:\7
(1(:(:(B(B<(P%
 $)C0<<YGMMMM"78'--:W   $<];P:QQRST5 (> B?BSSWX[_[d[dek[ll
 	
 E %$  7*,6)	>7 %%:: -?@A  sp   F D=<F +E:E%AF 9F =
EF E"F !E""F %2FF FF 
F,+F,)NFNNNFNNr   r9  )zrequirements.txt)=__doc__r^   r   r   r/   importlib.metadataimportlib.utilr   r+   r@   r   r&  r(   	threadingpathlibr   typesr   typingr   huggingface_hubr   r   	packagingr   ri   r
   r   r   r   r   utils.import_utilsr   r   
get_loggerr  r   rL   r"   Lockr   r2   PathLiker6   rC   rH   rU   r   r   booltyper   r   r  r   r   r  r  r%  r4  rJ  r   r#   r!   <module>rZ     s   : 
       	 	   
     C   I 
		H	%  B !~~' & &bkk 1 &d &,'cBKK&7 'DI '* 3+<  c  @4$#+ 4$S	 4$n *C"++-  *$s)  *N 	-+-+r{{"-+ 	-+
 
-+`!.#&#4!.r{{"!. +!. I	!.
 	!.N +/ %)#" #g5#&#4g5g5 R[[ 4'g5 	g5
 #s(^d"g5 #:g5 Djg5 g5 Tzg5 *g5 	g5Z +/ %)#"  $kVkV#&#4kV R[[ 4'kV 	kV
 #s(^d"kV #:kV DjkV kV TzkV :kV 
kV\IC Ir{{): ID4K I[_`c[d IX   gkRj5
r#   