Ë
    T^(hâÊ  ã            $       óú  — 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mZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZ ddlZddlZddlmZmZmZmZmZmZmZmZmZmZmZmZ dd	l m!Z!m"Z" dd
l#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<  e3jz                  e>«      Z?ej0                  j€                  ZAd„ ZB ej†                  dejˆ                  j‹                   ej†                  dd«      d«      «      ZFejŽ                  ZG ej†                  dej�                  «      ZI ej†                  deI«      ZJ ej†                  deJ«      ZK ej†                  dejˆ                  j‹                  ej˜                  d«      «      ZMdZN e«       jž                  ZPdD ],  ZQ ej†                  eQ«      €Œ ej¤                  deQ› d�eS«       Œ. dZTdZUej¬                  j¯                  d d!«      j±                  «       e7v ZYeYrd"nd#ZZeZZ[ej¬                  j¯                  d$d«      �/ ej¤                  d%eS«       ej¬                  j¯                  d$d«      Z[ej¬                  j¯                  d&e[«      Z[e[d'z   Z\e[d(z   Z]	 dYd)e^d*e^d+ee^e
df   d,ee^   fd-„Z_d.„ Z`d/„ ZadZd0eebe^df   d1e^fd2„Zcd3ee^   d4ee^   d1ee^   fd5„Zdd)ee^ejÊ                  f   d6e^d1ee^   fd7„Zf	 	 	 	 	 	 	 	 	 	 	 	 	 	 d[d)ee^ejÊ                  f   d9ege^   d+eee^ejÊ                  f      d:ehd;eeh   d<eebe^e^f      d=eeehe^f      d,ee^   d>ehd?e^d@ee^   d0eee^ebe^e^f   f      dAehdBehdCehdDee^   d1ee^   f"dE„ZidF„ ZjdZdG„Zk	 	 	 d\d8dddHœdIee^ejÊ                  f   d6e^d,ee^   d<eebe^e^f      d=eeehe^f      d>ehd+ee^e
df   d@ee^   fdJ„Zl G dK„ dL«      ZmdMdNœdO„ZndPeeoe^f   fdQ„Zp	 	 	 	 	 	 	 	 	 	 d]dR„Zq	 	 	 d^dSe^dTeege^      d=ee^   dUehfdV„Zr G dW„ dX«      Zsy)_z?
Hub utilities: utilities related to download and cache models
é    N)Úfutures)ÚPath)ÚOptionalÚUnion)Úurlparse)Úuuid4)Ú_CACHED_NO_EXISTÚCommitOperationAddÚ	ModelCardÚModelCardDataÚ	constantsÚcreate_branchÚcreate_commitÚcreate_repoÚhf_hub_downloadÚ
hf_hub_urlÚsnapshot_downloadÚtry_to_load_from_cache)ÚREGEX_COMMIT_HASHÚhttp_get)ÚEntryNotFoundErrorÚGatedRepoErrorÚHfHubHTTPErrorÚLocalEntryNotFoundErrorÚOfflineModeIsEnabledÚRepositoryNotFoundErrorÚRevisionNotFoundErrorÚbuild_hf_headersÚget_sessionÚhf_raise_for_statusÚsend_telemetry)Ú	HTTPErroré   )Ú__version__Úlogging)Úworking_or_temp_dir)ÚENV_VARS_TRUE_VALUESÚ_tf_versionÚ_torch_versionÚis_tf_availableÚis_torch_availableÚis_training_run_on_sagemakerc                  ó   — t         S ©N)Ú_is_offline_mode© ó    úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/utils/hub.pyÚis_offline_moder3   O   s   € ÜÐr1   Ú
TORCH_HOMEÚXDG_CACHE_HOMEz~/.cacheÚtorchÚPYTORCH_PRETRAINED_BERT_CACHEÚPYTORCH_TRANSFORMERS_CACHEÚTRANSFORMERS_CACHEÚHF_MODULES_CACHEÚmodulesÚtransformers_modules)r7   r8   r9   zUsing `zQ` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.z3https://s3.amazonaws.com/models.huggingface.co/bertzhttps://cdn.huggingface.coÚHUGGINGFACE_CO_STAGINGÚNOzhttps://hub-ci.huggingface.cozhttps://huggingface.coÚHUGGINGFACE_CO_RESOLVE_ENDPOINTz‘Using the environment variable `HUGGINGFACE_CO_RESOLVE_ENDPOINT` is deprecated and will be removed in Transformers v5. Use `HF_ENDPOINT` instead.ÚHF_ENDPOINTz)/{model_id}/resolve/{revision}/{filename}z/api/telemetry/examplesÚpath_or_repo_idÚfull_filenameÚ	cache_dirÚrevisionc                 ó<   — t        | |||¬«      }|�|t        k7  r|S y )N)rC   rD   )r   r	   )rA   rB   rC   rD   Úresolved_files        r2   Ú_get_cache_file_to_returnrG   ‚   s-   € ô +¨?¸MÐU^ÐiqÔr€MØÐ  ]Ô6FÒ%FØÐØr1   c                 ó4   — t        | «      }|j                  dv S )N)ÚhttpÚhttps)r   Úscheme)Úurl_or_filenameÚparseds     r2   Úis_remote_urlrN   Œ   s   € Ü�oÓ&€FØ�=‰=Ð-Ð-Ð-r1   c            	      ó\  — 	 t        j                  t        j                  d   «      j	                  «       } | d   }| d   j                  d«      d   }t	        j                  t        j                  dd«      «      }d|v rdnd	}d
t        j                  v r't        j                  d
«      j                  d«      d   nd }t        j                  dd «      t        j                  dd «      t        j                  dd«      t        j                  dd«      ||||dœ}|S # t        $ r d }d }Y ŒØw xY w)NÚECS_CONTAINER_METADATA_URIÚImageú:r#   ÚSM_FRAMEWORK_PARAMSz{}Ú*sagemaker_distributed_dataparallel_enabledTFÚTRAINING_JOB_ARNé   ÚSM_FRAMEWORK_MODULEÚ
AWS_REGIONÚSM_NUM_GPUSr   ÚSM_NUM_CPUS)Úsm_frameworkÚ	sm_regionÚsm_number_gpuÚsm_number_cpuÚsm_distributed_trainingÚsm_deep_learning_containerÚsm_deep_learning_container_tagÚsm_account_id)	ÚrequestsÚgetÚosÚenvironÚjsonÚsplitÚ	ExceptionÚloadsÚgetenv)Úinstance_dataÚdlc_container_usedÚdlc_tagÚsagemaker_paramsÚruns_distributed_trainingÚ
account_idÚsagemaker_objects          r2   Údefine_sagemaker_informationrs   ‘   s  € ðÜ Ÿ™¤R§Z¡ZÐ0LÑ%MÓN×SÑSÓUˆØ*¨7Ñ3ÐØ Ñ(×.Ñ.¨sÓ3°AÑ6ˆô
 —z‘z¤"§)¡)Ð,AÀ4Ó"HÓIÐØ(TÐXhÑ(h¡ÐnsÐØ@RÔVX×V`ÑV`Ñ@`”—‘Ð-Ó.×4Ñ4°SÓ9¸!Ò<Ðfj€Jô Ÿ	™	Ð"7¸Ó>Ü—Y‘Y˜|¨TÓ2ÜŸ™ =°!Ó4ÜŸ™ =°!Ó4Ø#<Ø&8Ø*1Ø#ñ	Ðð Ðøô% ò Ø!ÐØŠðús   ‚AD ÄD+Ä*D+Ú
user_agentÚreturnc                 ó†  — dt         › dt        j                  j                  «       d   › dt        › �}t        «       r|dt        › �z  }t        «       r|dt        › �z  }t        j                  r|dz   S t        «       r4|ddj                  d	„ t        «       j                  «       D «       «      z   z  }t        j                   j#                  d
d«      j%                  «       t&        v r|dz  }t)        | t*        «      r.|ddj                  d„ | j                  «       D «       «      z   z  }|S t)        | t,        «      r|d| z   z  }|S )zF
    Formats a user-agent string with basic info about a request.
    ztransformers/z	; python/r   z; session_id/z; torch/z; tensorflow/z; telemetry/offz; c              3   ó0   K  — | ]  \  }}|› d |› �–— Œ y­w©ú/Nr0   ©Ú.0ÚkÚvs      r2   ú	<genexpr>z"http_user_agent.<locals>.<genexpr>·   s   è ø€ Ò]©d¨a° !  A a SœzÑ]ùó   ‚ÚTRANSFORMERS_IS_CIÚ z; is_ci/truec              3   ó0   K  — | ]  \  }}|› d |› �–— Œ y­wrx   r0   rz   s      r2   r~   z"http_user_agent.<locals>.<genexpr>¼   s   è ø€ ÒI©d¨a° !  A a SœzÑIùr   )r$   ÚsysÚversionrh   Ú
SESSION_IDr+   r)   r*   r(   r   ÚHF_HUB_DISABLE_TELEMETRYr,   Újoinrs   Úitemsre   rf   rd   Úupperr'   Ú
isinstanceÚdictÚstr)rt   Úuas     r2   Úhttp_user_agentrŽ   «   s*  € ð œ˜ Y¬s¯{©{×/@Ñ/@Ó/BÀ1Ñ/EÐ.FÀmÔT^ÐS_Ð	`€BÜÔØ
�œÐ(Ð)Ñ)ˆÜÔØ
�œk˜]Ð+Ñ+ˆÜ×)Ò)ØÐ%Ñ%Ð%Ü#Ô%Ø
ˆd�T—Y‘YÑ]Ô6RÓ6T×6ZÑ6ZÓ6\Ô]Ó]Ñ]Ñ]ˆä	‡z�z‡~�~Ð*¨BÓ/×5Ñ5Ó7Ô;OÑOØ
ˆnÑˆÜ�*œdÔ#Ø
ˆd�T—Y‘YÑI°j×6FÑ6FÓ6HÔIÓIÑIÑIˆð €Iô 
�J¤Ô	$Ø
ˆd�ZÑÑˆØ€Ir1   rF   Úcommit_hashc                 óÜ   — | �|�|S t        t        | «      j                  «       «      } t        j                  d| «      }|€y|j                  «       d   }t        j                  |«      r|S dS )zP
    Extracts the commit hash from a resolved filename toward a cache file.
    Nzsnapshots/([^/]+)/r   )rŒ   r   Úas_posixÚreÚsearchÚgroupsr   Úmatch)rF   r�   r“   s      r2   Úextract_commit_hashr–   Â   sn   € ð Ð Ð 7ØÐÜœ˜]Ó+×4Ñ4Ó6Ó7€MÜ�Y‰YÐ,¨mÓ<€FØ€~ØØ—-‘-“/ !Ñ$€KÜ+×1Ñ1°+Ô>ˆ;ÐHÀDÐHr1   Úfilenamec                 ó:   — t        d| |gdœ|¤Ž}|�|d   }|S |}|S )a—
  
    Tries to locate a file in a local folder and repo, downloads and cache it if necessary.

    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.
        filename (`str`):
            The name of the file to locate in `path_or_repo`.
        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.
        resume_download:
            Deprecated and ignored. All downloads are now resumed by default when possible.
            Will be removed in v5 of Transformers.
        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 `huggingface-cli 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.
        subfolder (`str`, *optional*, defaults to `""`):
            In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
            specify the folder name here.
        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:
        `Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).

    Examples:

    ```python
    # Download a model weight from the Hub and cache it.
    model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
    ```
    )rA   Ú	filenamesr   r0   )Úcached_files)rA   r—   ÚkwargsÚfiles       r2   Úcached_filer�   Ð   s;   € ôt ÐX¨ÀHÀ:ÑXÐQWÑX€DØÐ&ˆ4�‰7€DØ€Kð -1€DØ€Kr1   Fr™   Úforce_downloadÚresume_downloadÚproxiesÚtokenÚlocal_files_onlyÚ	subfolderÚ	repo_typeÚ _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesÚ'_raise_exceptions_for_connection_errorsÚ_commit_hashc                 óD	  — |j                  dd«      }|�)t        j                  dt        «       |�t	        d«      ‚|}t        «       r|st        j                  d«       d}|	€d}	|D �cg c]"  }t        j                  j                  |	|«      ‘Œ$ }}t        | «      } g }|D ]¶  }t        j                  j                  | «      sŒ#t        j                  j                  | |«      }t        j                  j                  |«      sD|r@|t        j                  j                  |	d«      k7  r|€d	n|}t        | › d
|› d| › d|› d�«      ‚ y|j                  |«       Œ¸ t!        |«      t!        |«      k(  r|S |€t"        }t%        |t&        «      rt        |«      }g }d}|�T|sR|D ]M  }t)        | ||||
¬«      }|€Œ|t*        ur|dz  }|j                  |«       Œ5|s|dz  }Œ=t        d|› d| › d�«      ‚ |t!        |«      k(  rt!        |«      dkD  r|S dS t-        |«      }	 t!        |«      dk(  r+t/        | |d   t!        |	«      dk(  rdn|	|
||||||||¬«       nt1        | ||
||||||||¬«       |D �cg c]  }t;        | |||«      ‘Œ }}tG        d „ |D «       «      r“|r‘tI        ||«      D ��cg c]
  \  }}|�Œ	|‘Œ }}}t!        |«      dk(  r'|d   t        j                  j                  |	d«      k(  ry|€d	n|}t!        |«      dk(  rd!|d   › �nd"g |¢­› �}tK        | › d#|› d| › d|› d$�«      ‚|D �cg c]  }|€Œ|‘Œ	 }}t!        |«      dk(  rd}|S |}|S c c}w # t2        $ �r-}t%        |t4        «      rt%        |t6        «      st        | › d�«      |‚t%        |t8        «      rt        |› d| › d�«      |‚|D �cg c]  }t;        | |||«      ‘Œ nc c}w }}t=        d„ |D «       «      r|cY d}~S t%        |t6        «      r"|sY d}~yt        d| › dt        |«      › �«      |‚t%        |t>        «      r|sY d}~y|rLt        dt@        › d�«      |‚t%        |tB        «      r(t%        |tD        «      s|sY d}~yt        d| › d|› �«      ‚Y d}~�Œd}~ww xY wc c}w c c}}w c c}w )%ah  
    Tries to locate several files in a local folder and repo, downloads and cache them if necessary.

    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.
        filenames (`List[str]`):
            The name of all the files to locate in `path_or_repo`.
        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.
        resume_download:
            Deprecated and ignored. All downloads are now resumed by default when possible.
            Will be removed in v5 of Transformers.
        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 `huggingface-cli 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.
        subfolder (`str`, *optional*, defaults to `""`):
            In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
            specify the folder name here.
        repo_type (`str`, *optional*):
            Specify the repo type (useful when downloading from a space for instance).

    Private args:
        _raise_exceptions_for_gated_repo (`bool`):
            if False, do not raise an exception for gated repo error but return None.
        _raise_exceptions_for_missing_entries (`bool`):
            if False, do not raise an exception for missing entries but return None.
        _raise_exceptions_for_connection_errors (`bool`):
            if False, do not raise an exception for connection errors but return None.
        _commit_hash (`str`, *optional*):
            passed when we are chaining several calls to various files (e.g. when loading a tokenizer or
            a pipeline). If files are cached for this commit hash, avoid calls to head and get from the cache.

    <Tip>

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

    </Tip>

    Returns:
        `Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo).

    Examples:

    ```python
    # Download a model weight from the Hub and cache it.
    model_weights_file = cached_file("google-bert/bert-base-uncased", "pytorch_model.bin")
    ```
    Úuse_auth_tokenNúrThe `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.úV`token` and `use_auth_token` are both specified. Please set only the argument `token`.z+Offline mode: forcing local_files_only=TrueTr�   zconfig.jsonÚmainz& does not appear to have a file named z#. Checkout 'https://huggingface.co/z/tree/z' for available files.r   )rC   rD   r¤   r#   zCould not locate z inside ú.)
r£   r¤   rD   rC   rt   rž   r    rŸ   r¡   r¢   )
Úallow_patternsr¤   rD   rC   rt   rž   r    rŸ   r¡   r¢   a   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 either by logging in with `huggingface-cli login` or by passing `token=<your_token>`ú• 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/ú' for available revisions.c              3   ó$   K  — | ]  }|d u–— Œ
 y ­wr.   r0   ©r{   rœ   s     r2   r~   zcached_files.<locals>.<genexpr>Ù  s   è ø€ Ò; Dˆt˜4ÔÑ;ùó   ‚z`You are trying to access a gated repo.
Make sure to have access to it at https://huggingface.co/z.
zWe couldn't connect to 'zÙ' to load the files, and couldn't find them in the cached files.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.z:There was a specific connection error when trying to load z:
c              3   ó$   K  — | ]  }|d u –— Œ
 y ­wr.   r0   r³   s     r2   r~   zcached_files.<locals>.<genexpr>û  s   è ø€ Ò
3˜Dˆ4�4Œ<Ñ
3ùr´   za file named zfiles named z does not appear to have z'for available files.)&ÚpopÚwarningsÚwarnÚFutureWarningÚ
ValueErrorr3   ÚloggerÚinfore   Úpathr‡   rŒ   ÚisdirÚisfileÚOSErrorÚappendÚlenr9   rŠ   r   r   r	   rŽ   r   r   ri   r   r   r   rG   Úallr   r?   r"   r   ÚanyÚzipÚEnvironmentError)rA   r™   rC   rž   rŸ   r    r¡   rD   r¢   r£   r¤   rt   r¥   r¦   r§   r¨   Údeprecated_kwargsrª   rœ   Úfull_filenamesÚexisting_filesr—   rF   Ú	revision_Úfile_counterÚeÚresolved_filesÚoriginalÚresolvedÚmissing_entriesÚmsgs                                  r2   rš   rš     s¶  € ðf '×*Ñ*Ð+;¸TÓB€NØÐ!Ü�‰ð AÜô	
ð ÐÜÐuÓvÐvØˆäÔÑ!1Ü�‰ÐAÔBØÐØÐØˆ	ð AJÖJ¸”b—g‘g—l‘l 9¨dÕ3ÐJ€NÐJä˜/Ó*€OØ€NØ"ò 1ˆÜ�7‰7�=‰=˜Õ)ÜŸG™GŸL™L¨¸(ÓCˆMÜ—7‘7—>‘> -Ô0Ù8¸XÌÏÉÏÉÐV_ÐanÓIoÒ=oØ*2Ð*:¡À�IÜ!Ø*Ð+Ð+QÐRZÐQ[ð \3Ø3BÐ2CÀ6È)ÈÐTjðlóð ñ
  Ø×!Ñ! -Õ0ð1ô ˆ>Óœc .Ó1Ò1ØÐàÐÜ&ˆ	Ü�)œTÔ"Ü˜	“Nˆ	à€NØ€LØÐ©Ø&ò 	\ˆHä2Ø °YÈÐajôˆMð Ñ(Ø Ô(8Ñ8Ø  AÑ%�LØ"×)Ñ)¨-Õ8Ù>Ø  AÑ%‘Lä!Ð$5°h°Z¸xÈÐGXÐXYÐ"ZÓ[Ð[ð	\ð ”s˜>Ó*Ò*Ü!$ ^Ó!4°qÒ!8ˆ~ÐB¸dÐBä  Ó,€JðPpÜˆ~Ó !Ò#äØØ˜!‘Ü"% i£.°AÒ"5™$¸9Ø#Ø!Ø#Ø%Ø-ØØ /ØØ!1öô ØØ-Ø#Ø!Ø#Ø%Ø-ØØ /ØØ!1õðB cqöØV^Ô! /°8¸YÈÕQð€Nð ô Ñ
3 NÔ
3Ô3Ñ8]Ü>AÀ.ÐR`Ó>a×vÑ(:¨°(ÐemÑeuš8ÐvˆÑväˆ~Ó !Ò#¨¸Ñ(:¼b¿g¹g¿l¹lÈ9ÐVcÓ>dÒ(dØà&Ð.‘F°Hˆ	ä47¸Ó4HÈAÒ4Mˆm˜O¨AÑ.Ð/Ñ0ÐUaÐbuÐdsÑbuÐavÐSwð 	ô ØÐÐ8¸¸Ð=`ÐapÐ`qÐqwð  yBð  xCð C#ð #ó
ð 	
ð (6ÖJ˜t¸Ñ9I’dÐJ€NÐJä  Ó0°AÒ5�T€NàÐð <J€NàÐùòy Køôd ó 0pä�aÔ0Ô1¼*ÀQÌÔ:WÜØ"Ð#ð $'ð 'óð
 ðô ˜Ô0Ô1ÜØ�*ð +à+:Ð*;Ð;UðWóð ð	ð guö
ØZbÔ% o°xÀÈHÕUñ
ùò 
ˆð 
ô Ñ;¨NÔ;Ô;Ø!Õ!ô �aœÔ(Ù3ÜÜð*Ø*9Ð):¸#¼cÀ!»f¸XðGóð ðô ˜Ô2Ô3Ù:Üñ 7ÜØ.Ô/NÐ.Oð P]ð ]óð ð	ô ˜œ9Ô%¬j¸Ô<NÔ.OÙ:ÜÜÐVÐWfÐVgÐgjÐklÐjmÐnÓoÐoÿùða0püòdùó
 wùò Ksh   Á)'MÈAM É/RÊ)
RÊ4RÌ/RÌ7RÍ
RÍ"AR
Î7OÏR
Ï'RÏ-R
Ð-R
Ð68R
Ñ3R
Ò
Rc                  óJ   — t         j                  d«       t        | ddddœ|¤ŽS )a  
    Tries to locate a file in a local folder and repo, downloads and cache it if necessary.

    Args:
        path_or_repo (`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.
        filename (`str`):
            The name of the file to locate in `path_or_repo`.
        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.
        resume_download:
            Deprecated and ignored. All downloads are now resumed by default when possible.
            Will be removed in v5 of Transformers.
        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 `huggingface-cli 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.
        subfolder (`str`, *optional*, defaults to `""`):
            In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
            specify the folder name here.

    <Tip>

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

    </Tip>

    Returns:
        `Optional[str]`: Returns the resolved file (to the cache folder if downloaded from a repo) or `None` if the
        file does not exist.

    Examples:

    ```python
    # Download a tokenizer configuration from huggingface.co and cache.
    tokenizer_config = get_file_from_repo("google-bert/bert-base-uncased", "tokenizer_config.json")
    # This model does not have a tokenizer config so the result will be None.
    tokenizer_config = get_file_from_repo("FacebookAI/xlm-roberta-base", "tokenizer_config.json")
    ```
    zb`get_file_from_repo` is deprecated and will be removed in version 4.51. Use `cached_file` instead.F)r¥   r¦   r§   )r»   Úwarningr�   )Úargsr›   s     r2   Úget_file_from_reporÕ     s9   € ôv ‡N�NØlôô Ø	Ø).Ø.3Ø05ñ	ð
 ñð r1   c                 óä   — t        j                  d| › d�t        «       t        j                  «       \  }}t        j                  |d«      5 }t        | ||¬«       ddd«       |S # 1 sw Y   |S xY w)aw  
    Downloads a given url in a temporary file. This function is not safe to use in multiple processes. Its only use is
    for deprecated behavior allowing to download config/models with a single url instead of using the Hub.

    Args:
        url (`str`): The url of the file to download.
        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.

    Returns:
        `str`: The location of the temporary file where the url was downloaded.
    z5Using `from_pretrained` with the url of a file (here aY  ) is deprecated and won't be possible anymore in v5 of Transformers. You should host your file on the Hub (hf.co) instead and use the repository ID. Note that this is not compatible with the caching system (your file will be downloaded at each execution) or multiple processes (each process will download the file in a different temporary file).Úwb)r    N)r·   r¸   r¹   ÚtempfileÚmkstempre   Úfdopenr   )Úurlr    Útmp_fdÚtmp_fileÚfs        r2   Údownload_urlrß   Z  st   € ô ‡M�MØ
?À¸uð Ecð 	cô 	ôô  ×'Ñ'Ó)Ñ€FˆHÜ	�‰�6˜4Ó	 ð * AÜ��a Õ)÷*à€O÷*à€Oús   ÁA%Á%A/)r¢   rC   r¤   Úpath_or_repoc                ó€  — |j                  dd«      }	|	�)t        j                  dt        «       |�t	        d«      ‚|	}t
        j                  j                  | «      r=t
        j                  j                  t
        j                  j                  | |«      «      S t        | ||||¬«      }
t        |
t        «      }|r|S 	 t        «       j                  t        | |||¬«      t!        |t#        «       ¬«      d|d	¬
«      }	 t3        |«       y# t$        j&                  j(                  t$        j&                  j*                  f$ r ‚ t$        j&                  j,                  t$        j&                  j.                  t0        f$ r |cY S w xY w# t4        $ r,}t6        j9                  |«       t;        | › d| › d�«      |‚d}~wt<        $ r)}t6        j9                  |«       t;        | › d�«      |‚d}~wt>        $ r,}t6        j9                  |«       t;        |› d| › d�«      |‚d}~wt@        $ r Y yt$        jB                  $ r |cY S w xY w)aŸ  
    Checks if a repo contains a given file without downloading it. Works for remote repos and local folders.

    If offline mode is enabled, checks if the file exists in the cache.

    <Tip warning={false}>

    This function will raise an error if the repository `path_or_repo` is not valid or if `revision` does not exist for
    this repo, but will return False for regular connection errors.

    </Tip>
    rª   Nr«   r¬   )Úrepo_idr—   rD   r¤   rC   )r—   rD   r¤   )r¡   rt   Fé
   )ÚheadersÚallow_redirectsr    ÚtimeoutTzN is a gated repository. Make sure to request access at https://huggingface.co/z† and pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.zE is not a local folder or a valid repository name on 'https://hf.co'.r°   r±   )"r¶   r·   r¸   r¹   rº   re   r½   r¾   r¿   r‡   r   rŠ   rŒ   r   Úheadr   r   rŽ   rc   Ú
exceptionsÚSSLErrorÚ
ProxyErrorÚConnectionErrorÚTimeoutr   r    r   r»   ÚerrorrÀ   r   r   r   r"   )rà   r—   rD   r    r¡   r¢   rC   r¤   rÇ   rª   Úcached_pathÚhas_file_in_cacheÚresponserÌ   s                 r2   Úhas_filerñ   u  s?  € ð0 '×*Ñ*Ð+;¸TÓB€NØÐ!Ü�‰ð AÜô	
ð ÐÜÐuÓvÐvØˆô 
‡w�w‡}�}�\Ô"Ü�w‰w�~‰~œbŸg™gŸl™l¨<¸ÓBÓCÐCô )ØØØØØô€Kô # ;´Ó4Ðñ Ø Ð ð!Ü“=×%Ñ%Ü�|¨hÀÐU^Ô_Ü$¨5¼_Ó=NÔOØ!ØØð &ó 
ˆð"!Ü˜HÔ%Øøô ×Ñ×(Ñ(¬(×*=Ñ*=×*HÑ*HÐIò àä×Ñ×+Ñ+Ü×Ñ×#Ñ#Üðò !ð
 !Ò ð!ûô ò Ü�‰�QŒÜØˆnð &Ø&2 ^ð 4ZðZó
ð ð		ûô
 #ò uÜ�‰�QŒÜ˜˜Ð&kÐlÓmÐstÐtûÜ ò Ü�‰�QŒÜØˆjð KØKWÈ.ÐXrðtó
ð ð	ûô ò ÙÜ×Ñò !à Ò ð!úsO   Â?>D
 Ã>F Ä
A5FÆFÆ	H=Æ'F5Æ5H=Ç$G%Ç%H=Ç1'HÈH=È&H=È<H=c                   óœ  — e Zd ZdZ	 	 	 	 ddedee   deeeef      dee   dee   defd	„Zd
eee	j                  f   fd„Z	 	 	 	 	 dd
eee	j                  f   dedeeef   dee   deeeef      dedee   dee   fd„Z	 	 	 	 	 	 	 	 	 	 ddedee   dee   dee   deeeef      deeeef      dededee   dee   deee      defd„Zy)ÚPushToHubMixinzW
    A Mixin containing the functionality to push a model or tokenizer to the hub.
    Nrâ   Úprivater¡   Úrepo_urlÚorganizationru   c                 ó@  — |�;t        j                  d«       |�t        d«      ‚|j                  t        › d�d«      }|�Et        j                  d«       |j                  |«      sd|v r|j                  d«      d   }|› d|› �}t        |||d¬«      }|j                  S )	z‘
        Create the repo if needed, cleans up repo_id with deprecated kwargs `repo_url` and `organization`, retrieves
        the token.
        zgThe `repo_url` argument is deprecated and will be removed in v5 of Transformers. Use `repo_id` instead.zT`repo_id` and `repo_url` are both specified. Please set only the argument `repo_id`.ry   r�   zºThe `organization` argument is deprecated and will be removed in v5 of Transformers. Set your organization directly in the `repo_id` passed instead (`repo_id={organization}/{model_id}`).éÿÿÿÿT)râ   r¡   rô   Úexist_ok)	r·   r¸   rº   Úreplacer?   Ú
startswithrh   r   râ   )Úselfrâ   rô   r¡   rõ   rö   rÛ   s          r2   Ú_create_repozPushToHubMixin._create_repoÞ  s½   € ð ÐÜ�M‰Mðôð Ð"Ü Øjóð ð ×&Ñ&Ô*IÐ)JÈ!Ð'LÈbÓQˆGØÐ#Ü�M‰Mðoôð ×%Ñ% lÔ3Ø˜'‘>Ø%Ÿm™m¨CÓ0°Ñ4�GØ)˜N¨!¨G¨9Ð5�ä '°ÀÐRVÔWˆØ�{‰{Ðr1   Úworking_dirc           
      óÊ   — t        j                  |«      D �ci c]@  }|t         j                  j                  t         j                  j	                  ||«      «      “ŒB c}S c c}w )zS
        Returns the list of files with their last modification timestamp.
        )re   Úlistdirr½   Úgetmtimer‡   )rü   rþ   rÞ   s      r2   Ú_get_files_timestampsz$PushToHubMixin._get_files_timestamps  sG   € ô LNÏ:É:ÐVaÓKbÖcÀa�”2—7‘7×#Ñ#¤B§G¡G§L¡L°¸aÓ$@ÓAÑAÒcÐcùÒcs   ˜AA Úfiles_timestampsÚcommit_messageÚ	create_prrD   Úcommit_descriptionc	                 óŠ  — |€ d| j                   j                  v rd}n…d| j                   j                  v rd}njd| j                   j                  v rd}nOd| j                   j                  v rd	}n4d
| j                   j                  v rd}nd| j                   j                  › �}t        j                  |«      D �	cg c]K  }	|	|vsCt        j                  j                  t        j                  j                  ||	«      «      ||	   kD  r|	‘ŒM }
}	|
D �	cg c]~  }	t        j                  j                  t        j                  j                  ||	«      «      s=t        j                  j                  t        j                  j                  ||	«      «      r|	‘Œ€ }
}	g }|
D �]  }t        j                  j                  t        j                  j                  ||«      «      r’t        j                  t        j                  j                  ||«      «      D ][  }	|j                  t        t        j                  j                  |||	«      t        j                  j                  ||	«      ¬«      «       Œ] ŒÓ|j                  t        t        j                  j                  ||«      |¬«      «       �Œ |�!|j                  d«      s	 t        |||d¬«       t         j#                  d|› ddj                  |
«      › �«       t%        |||||||¬«      S c c}	w c c}	w # t        $ r'}|j                  j                  dk(  r|rn‚ Y d}~Œqd}~ww xY w)zh
        Uploads all modified files in `working_dir` to `repo_id`, based on `files_timestamps`.
        NÚModelzUpload modelÚConfigzUpload configÚ	TokenizerzUpload tokenizerÚFeatureExtractorzUpload feature extractorÚ	ProcessorzUpload processorzUpload )Úpath_or_fileobjÚpath_in_repozrefs/prT)râ   Úbranchr¡   rù   i“  z!Uploading the following files to z: ú,)râ   Ú
operationsr  r  r¡   r  rD   )Ú	__class__Ú__name__re   r   r½   r  r‡   r¿   r¾   rÁ   r
   rû   r   r   rð   Ústatus_coder»   r¼   r   )rü   rþ   râ   r  r  r¡   r  rD   r  rÞ   Úmodified_filesr  rœ   rÌ   s                 r2   Ú_upload_modified_filesz%PushToHubMixin._upload_modified_files  sÈ  € ð Ð!Ø˜$Ÿ.™.×1Ñ1Ñ1Ø!/‘Ø˜TŸ^™^×4Ñ4Ñ4Ø!0‘Ø §¡× 7Ñ 7Ñ7Ø!3‘Ø# t§~¡~×'>Ñ'>Ñ>Ø!;‘Ø §¡× 7Ñ 7Ñ7Ø!3‘à#*¨4¯>©>×+BÑ+BÐ*CÐ!D�ô —Z‘Z Ó,ö
àØÐ(Ñ(¬B¯G©G×,<Ñ,<¼R¿W¹W¿\¹\È+ÐWXÓ=YÓ,ZÐ]mÐnoÑ]pÒ,pò ð
ˆð 
ð $ö
àÜ�w‰w�~‰~œbŸg™gŸl™l¨;¸Ó:Ô;¼r¿w¹w¿}¹}ÌRÏWÉWÏ\É\ÐZeÐghÓMiÔ?jò ð
ˆð 
ð ˆ
à"ó 	ˆDÜ�w‰w�}‰}œRŸW™WŸ\™\¨+°tÓ<Ô=äŸ™¤B§G¡G§L¡L°¸dÓ$CÓDò �AØ×%Ñ%Ü*Ü,.¯G©G¯L©L¸ÀdÈAÓ,NÔ]_×]dÑ]d×]iÑ]iÐjnÐpqÓ]rôõñð ×!Ñ!Ü&´r·w±w·|±|ÀKÐQUÓ7VÐeiÔjöð	ð Ð¨×(;Ñ(;¸IÔ(Fð	Ü g°hÀeÐVZÕ[ô 	�‰Ð7¸°yÀÀ3Ç8Á8ÈNÓC[ÐB\Ð]Ô^ÜØØ!Ø)Ø1ØØØô
ð 	
ùòU
ùò
øô2 "ò Ø—:‘:×)Ñ)¨SÒ0±Yð àô ûðús&   Â:ALÄBLÊ=L Ì	MÌL=Ì=MÚuse_temp_dirÚmax_shard_sizeÚsafe_serializationÚtagsc                 óþ  — |j                  dd«      }|j                  dd«      }|�)t        j                  dt        «       |�t	        d«      ‚|}|j                  dd«      }|�Œt        j                  dt        «       |�t	        d	«      ‚t
        j                  j                  |«      r/|j                  t
        j                  j                  «      d
   }|}n+|}|j                  d«      d
   }n|j                  d«      d
   }|j                  dd«      }|j                  dd«      }| j                  |||||¬«      }t        ||||¬«      }|€ t
        j                  j                  |«       }t        ||¬«      5 }| j                  |«      }| j                  |||¬«       |j                  t
        j                  j!                  |d«      «       | j#                  |||||||	|
¬«      cddd«       S # 1 sw Y   yxY w)u!  
        Upload the {object_files} to the ðŸ¤— Model Hub.

        Parameters:
            repo_id (`str`):
                The name of the repository you want to push your {object} to. It should contain your organization name
                when pushing to a given organization.
            use_temp_dir (`bool`, *optional*):
                Whether or not to use a temporary directory to store the files saved before they are pushed to the Hub.
                Will default to `True` if there is no directory named like `repo_id`, `False` otherwise.
            commit_message (`str`, *optional*):
                Message to commit while pushing. Will default to `"Upload {object}"`.
            private (`bool`, *optional*):
                Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists.
            token (`bool` or `str`, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
                when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`
                is not specified.
            max_shard_size (`int` or `str`, *optional*, defaults to `"5GB"`):
                Only applicable for models. The maximum size for a checkpoint before being sharded. Checkpoints shard
                will then be each of size lower than this size. If expressed as a string, needs to be digits followed
                by a unit (like `"5MB"`). We default it to `"5GB"` so that users can easily load models on free-tier
                Google Colab instances without any CPU OOM issues.
            create_pr (`bool`, *optional*, defaults to `False`):
                Whether or not to create a PR with the uploaded files or directly commit.
            safe_serialization (`bool`, *optional*, defaults to `True`):
                Whether or not to convert the model weights in safetensors format for safer serialization.
            revision (`str`, *optional*):
                Branch to push the uploaded files to.
            commit_description (`str`, *optional*):
                The description of the commit that will be created
            tags (`List[str]`, *optional*):
                List of tags to push on the Hub.

        Examples:

        ```python
        from transformers import {object_class}

        {object} = {object_class}.from_pretrained("google-bert/bert-base-cased")

        # Push the {object} to your namespace with the name "my-finetuned-bert".
        {object}.push_to_hub("my-finetuned-bert")

        # Push the {object} to an organization with the name "my-finetuned-bert".
        {object}.push_to_hub("huggingface/my-finetuned-bert")
        ```
        rª   NÚignore_metadata_errorsFr«   r¬   Úrepo_path_or_namezpThe `repo_path_or_name` argument is deprecated and will be removed in v5 of Transformers. Use `repo_id` instead.z]`repo_id` and `repo_path_or_name` are both specified. Please set only the argument `repo_id`.rø   ry   rõ   rö   )rô   r¡   rõ   rö   ©r¡   r  )rþ   r  )r  r  z	README.md)r  r¡   r  rD   r  )r¶   r·   r¸   r¹   rº   re   r½   r¾   rh   Úseprý   Úcreate_and_tag_model_cardr&   r  Úsave_pretrainedÚsaver‡   r  )rü   râ   r  r  rô   r¡   r  r  r  rD   r  r  rÇ   rª   r  r  rþ   rõ   rö   Ú
model_cardÚwork_dirr  s                         r2   Úpush_to_hubzPushToHubMixin.push_to_hubV  s  € ð~ +×.Ñ.Ð/?ÀÓFˆØ!2×!6Ñ!6Ð7OÐQVÓ!WÐØÐ%Ü�M‰Mð EÜôð Ð Ü Ølóð ð #ˆEà-×1Ñ1Ð2EÀtÓLÐØÐ(ô �M‰Mð%äôð
 Ð"Ü Øsóð ô �w‰w�}‰}Ð.Ô/à!Ÿ-™-¬¯©¯©Ó4°RÑ8�Ø%‘ð ,�Ø%Ÿm™m¨CÓ0°Ñ4‘ð "Ÿ-™-¨Ó,¨RÑ0ˆKð %×(Ñ(¨°TÓ:ˆØ(×,Ñ,¨^¸TÓBˆà×#Ñ#Ø˜W¨E¸HÐS_ð $ó 
ˆô
 /Ø�T Ð?Uô
ˆ
ð ÐÜ!Ÿw™wŸ}™}¨[Ó9Ð9ˆLä ¨[À|ÔTð 	ÐX`Ø#×9Ñ9¸(ÓCÐð × Ñ  ¸.Ð]oÐ Ôpð �O‰OœBŸG™GŸL™L¨°;Ó?Ô@à×.Ñ.ØØØ Ø-ØØ#Ø!Ø#5ð /ó 	÷	÷ 	ò 	ús   Å<A-G3Ç3G<)NNNN)NNFNN)
NNNNÚ5GBFTNNN)r  Ú
__module__Ú__qualname__Ú__doc__rŒ   r   Úboolr   rý   re   ÚPathLiker  r‹   Úfloatr  ÚintÚlistr%  r0   r1   r2   ró   ró   Ù  s
  „ ñð #'Ø,0Ø"&Ø&*ñ!àð!ð ˜$‘ð!ð ˜˜d C˜iÑ(Ñ)ð	!ð
 ˜3‘-ð!ð ˜s‘mð!ð 
ó!ðFd°°s¸B¿K¹KÐ7GÑ1Hó dð )-Ø,0ØØ"&Ø,0ñM
à˜3 §¡Ð+Ñ,ðM
ð ðM
ð ˜s E˜zÑ*ð	M
ð
 ! ™ðM
ð ˜˜d C˜iÑ(Ñ)ðM
ð ðM
ð ˜3‘-ðM
ð % S™MóM
ðd (,Ø(,Ø"&Ø,0Ø49ØØ#'Ø"&Ø,0Ø$(ñGàðGð ˜t‘nðGð ! ™ð	Gð
 ˜$‘ðGð ˜˜d C˜iÑ(Ñ)ðGð !  s¨C x¡Ñ1ðGð ðGð !ðGð ˜3‘-ðGð % S™MðGð �t˜C‘yÑ!ðGð 
ôGr1   ró   Úpytorch)Ú	frameworkc                ó   — t        «       ry| |dœ}|D ]×  }|j                  j                  «       D ��ci c]  \  }}|j                  d«      rŒ|€Œ||“Œ }}}d|v r,|d   }t        j
                  j                  |«      s|d   |d<   d|v r	|d   |d<   Œ‚d|v sŒ‡| j                  dd	«      j                  d
d	«      j                  dd	«      }	|	j                  dd	«      }	|	› d|d   › �|d<   ŒÙ t        ddt        t        |«      ¬«       yc c}}w )a²  
    Sends telemetry that helps tracking the examples use.

    Args:
        example_name (`str`): The name of the example.
        *example_args (dataclasses or `argparse.ArgumentParser`): The arguments to the script. This function will only
            try to extract the model and dataset name from those. Nothing else is tracked.
        framework (`str`, *optional*, defaults to `"pytorch"`): The framework for the example.
    N)Úexampler0  Ú_Úmodel_name_or_pathÚ
model_nameÚdataset_nameÚ	task_nameÚtf_r�   Úflax_Úrun_Ú_no_trainerú-ÚexamplesÚtransformers)ÚtopicÚlibrary_nameÚlibrary_versionrt   )r3   Ú__dict__rˆ   rû   re   r½   r¾   rú   r!   r$   rŽ   )
Úexample_namer0  Úexample_argsÚdatarÔ   r|   r}   Úargs_as_dictr5  Úscript_names
             r2   Úsend_example_telemetryrH  à  s/  € ô ÔØà#°)Ñ<€DØò PˆØ)-¯©×)<Ñ)<Ó)>×j¡  AÀaÇlÁlÐSVÕFWÐ\]Ñ\i˜˜1™ÐjˆÑjØ <Ñ/Ø%Ð&:Ñ;ˆJä—7‘7—=‘= Ô,Ø%1Ð2FÑ%G��\Ñ"Ø˜\Ñ)Ø#/°Ñ#?ˆD�Ò Ø˜LÒ(à&×.Ñ.¨u°bÓ9×AÑAÀ'È2ÓN×VÑVÐW]Ð_aÓbˆKØ%×-Ñ-¨m¸RÓ@ˆKØ&1 ]°!°LÀÑ4MÐ3NÐ#OˆD�Ò ðPô  Ø ~Ä{Ô_nÐosÓ_töùó ks   ³D
ÁD
ÁD
Úsizec                 ó  — t        | t        «      r| S | j                  «       j                  d«      rt        | dd «      dz  S | j                  «       j                  d«      rt        | dd «      dz  S | j                  «       j                  d«      rt        | dd «      dz  S | j                  «       j                  d	«      r)t        | dd
 «      dz  }| j                  d«      r|dz  S |S | j                  «       j                  d«      r)t        | dd
 «      dz  }| j                  d«      r|dz  S |S | j                  «       j                  d«      r)t        | dd
 «      dz  }| j                  d«      r|dz  S |S t	        d«      ‚)a'  
    Converts a size expressed as a string with digits an unit (like `"5MB"`) to an integer (in bytes).

    Args:
        size (`int` or `str`): The size to convert. Will be directly returned if an `int`.

    Example:
    ```py
    >>> convert_file_size_to_int("1MiB")
    1048576
    ```
    ÚGIBNéýÿÿÿi   @ÚMIBi   ÚKIBi   ÚGBéþÿÿÿi Êš;Úbé   ÚMBi@B ÚKBiè  zR`size` is not in a valid format. Use an integer followed by the unit, e.g., '5GB'.)rŠ   r-  r‰   Úendswithrº   )rI  Úint_sizes     r2   Úconvert_file_size_to_intrW    s`  € ô �$œÔØˆØ‡z�zƒ|×Ñ˜UÔ#Ü�4˜˜�9‹~ Ñ'Ð'Ø‡z�zƒ|×Ñ˜UÔ#Ü�4˜˜�9‹~ Ñ'Ð'Ø‡z�zƒ|×Ñ˜UÔ#Ü�4˜˜�9‹~ Ñ'Ð'Ø‡z�zƒ|×Ñ˜TÔ"Ü�t˜C˜R�y“> UÑ+ˆØ $§¡¨cÔ 2ˆx˜1‰}Ð@¸Ð@Ø‡z�zƒ|×Ñ˜TÔ"Ü�t˜C˜R�y“> UÑ+ˆØ $§¡¨cÔ 2ˆx˜1‰}Ð@¸Ð@Ø‡z�zƒ|×Ñ˜TÔ"Ü�t˜C˜R�y“> UÑ+ˆØ $§¡¨cÔ 2ˆx˜1‰}Ð@¸Ð@Ü
ÐiÓ
jÐjr1   c                 ó  — ddl }|j                  dd«      }|�)t        j                  dt        «       |�t        d«      ‚|}t        j                  j                  |«      st        d|› d| › d�«      ‚t        |«      5 } |j                  |j                  «       «      }ddd«       t        t        d	   j                  «       «      «      }|d
   }t        |d	   j!                  «       «      |d<   |d	   j#                  «       |d	<   t        j                  j%                  | «      r2|D �cg c]#  }t        j                  j'                  | |
|«      ‘Œ% }}||fS t)        | |||||||||	|
|¬«      }||fS # 1 sw Y   ŒÔxY wc c}w )aÃ  
    For a given model:

    - download and cache all the shards of a sharded checkpoint if `pretrained_model_name_or_path` is a model ID on the
      Hub
    - returns the list of paths to all the shards, as well as some metadata.

    For the description of each arg, see [`PreTrainedModel.from_pretrained`]. `index_filename` is the full path to the
    index (downloaded and cached if `pretrained_model_name_or_path` is a model ID on the Hub).
    r   Nrª   r«   r¬   zCan't find a checkpoint index (z) in r®   Ú
weight_mapÚmetadataÚall_checkpoint_keys)
rC   rž   r    rŸ   r¢   r¡   rt   rD   r£   r¨   )rg   r¶   r·   r¸   r¹   rº   re   r½   r¿   Úopenrj   ÚreadÚsortedÚsetÚvaluesr.  ÚkeysÚcopyr¾   r‡   rš   )Úpretrained_model_name_or_pathÚindex_filenamerC   rž   r    rŸ   r¢   r¡   rt   rD   r£   r¨   rÇ   rg   rª   rÞ   ÚindexÚshard_filenamesÚsharded_metadataÚcached_filenamess                       r2   Úget_checkpoint_shard_filesri  $  sž  € ó2 à&×*Ñ*Ð+;¸TÓB€NØÐ!Ü�‰ð AÜô	
ð ÐÜÐuÓvÐvØˆä�7‰7�>‰>˜.Ô)ÜÐ:¸>Ð:JÈ%ÐPmÐOnÐnoÐpÓqÐqä	ˆnÓ	ð % Ø�—
‘
˜1Ÿ6™6›8Ó$ˆ÷%ô œS  |Ñ!4×!;Ñ!;Ó!=Ó>Ó?€OØ˜ZÑ(ÐÜ.2°5¸Ñ3F×3KÑ3KÓ3MÓ.NÐÐ*Ñ+Ø%*¨<Ñ%8×%=Ñ%=Ó%?Ð�\Ñ"ô 
‡w�w‡}�}Ð2Ô3Ø^mÖnÐYZœ2Ÿ7™7Ÿ<™<Ð(EÀyÐRSÕTÐnˆÐnØÐ 0Ð0Ð0ô $Ø%ØØØ%ØØ'Ø)ØØØØØ!ôÐð Ð-Ð-Ð-÷=%ð %üò os   Á>!E2Ä)(E>Å2E;râ   r  r  c                 ó†  — 	 t        j                  | ||¬«      }|�l|j
                  j                  €g |j
                  _        |D ]@  }||j
                  j                  vsŒ|j
                  j                  j                  |«       ŒB |S # t        $ r- d}t        |€g n|d¬«      }t        j                  ||¬«      }Y Œ¥w xY w)a‡  
    Creates or loads an existing model card and tags it.

    Args:
        repo_id (`str`):
            The repo_id where to look for the model card.
        tags (`List[str]`, *optional*):
            The list of tags to add in the model card
        token (`str`, *optional*):
            Authentication token, obtained with `huggingface_hub.HfApi.login` method. Will default to the stored token.
        ignore_metadata_errors (`bool`, *optional*, defaults to `False`):
            If True, errors while parsing the metadata section will be ignored. Some information might be lost during
            the process. Use it at your own risk.
    r  u†   This is the model card of a ðŸ¤— transformers model that has been pushed on the Hub. This model card has been automatically generated.r>  )r  r@  )Úmodel_description)r   Úloadr   r   Úfrom_templaterE  r  rÁ   )râ   r  r¡   r  r#  rk  Ú	card_dataÚ	model_tags           r2   r   r   m  sÂ   € ð(]ä—^‘^ G°5ÐQgÔhˆ
ð Ðà�?‰?×ÑÐ'Ø#%ˆJ�O‰OÔ Øò 	7ˆIØ 
§¡× 4Ñ 4Ò4Ø—‘×$Ñ$×+Ñ+¨IÕ6ð	7ð Ðøô ò ]ð eÐÜ!¨T¨\¡r¸tÐR`Ôaˆ	Ü×,Ñ,¨YÐJ[Ô\Š
ð	]ús   ‚B
 Â
3C Â?C c                   óP   — e Zd ZdZd	deej                     ddfd„Zd„ Zd„ Z	d
d„Z
y)ÚPushInProgresszj
    Internal class to keep track of a push in progress (which might contain multiple `Future` jobs).
    NÚjobsru   c                 ó&   — |€g | _         y || _         y r.   )rr  )rü   rr  s     r2   Ú__init__zPushInProgress.__init__š  s   € Ø˜,�Bˆ�	¨Dˆ�	r1   c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wr.   )Údone)r{   Újobs     r2   r~   z)PushInProgress.is_done.<locals>.<genexpr>ž  s   è ø€ Ò3 #�3—8‘8—:Ñ3ùs   ‚)rÃ   rr  ©rü   s    r2   Úis_donezPushInProgress.is_done�  s   € ÜÑ3¨¯©Ô3Ó3Ð3r1   c                 óB   — t        j                  | j                  «       y r.   )r   Úwaitrr  ry  s    r2   Úwait_until_donezPushInProgress.wait_until_done   s   € Ü�‰�T—Y‘YÕr1   c                 óŒ   — | j                   D �cg c]$  }|j                  «       s|j                  «       s|‘Œ& c}| _         y c c}w r.   )rr  Úcancelrw  )rü   rx  s     r2   r  zPushInProgress.cancel£  s8   € ð —y‘yö
àà—J‘J”L C§H¡H¤Jò ò
ˆ�	ùò 
s   �)Ar.   )ru   N)r  r'  r(  r)  r   r   ÚFuturert  rz  r}  r  r0   r1   r2   rq  rq  •  s2   „ ññ1˜X g§n¡nÑ5ð 1Àó 1ò4ò ô
r1   rq  )NNr.   )NFNNNNFr�   NNTTTN)NNN)
NFNNFNNNr�   N)NNF)tr)  rg   re   r’   rƒ   rØ   r·   Ú
concurrentr   Úpathlibr   Útypingr   r   Úurllib.parser   Úuuidr   Úhuggingface_hubrc   r	   r
   r   r   r   r   r   r   r   r   r   r   Úhuggingface_hub.file_downloadr   r   Úhuggingface_hub.utilsr   r   r   r   r   r   r   r   r   r    r!   Úrequests.exceptionsr"   r�   r$   r%   Úgenericr&   Úimport_utilsr'   r(   r)   r*   r+   r,   Ú
get_loggerr  r»   ÚHF_HUB_OFFLINEr/   r3   rk   r½   r‡   Útorch_cache_homeÚdefault_cache_pathÚHF_HUB_CACHEr7   r8   r9   ÚHF_HOMEr:   Ú TRANSFORMERS_DYNAMIC_MODULE_NAMEÚhexr…   Úkeyr¸   r¹   ÚS3_BUCKET_PREFIXÚCLOUDFRONT_DISTRIB_PREFIXrf   rd   r‰   Ú_staging_modeÚ_default_endpointr?   ÚHUGGINGFACE_CO_PREFIXÚ!HUGGINGFACE_CO_EXAMPLES_TELEMETRYrŒ   rG   rN   rs   r‹   rŽ   r–   r+  r�   r.  r*  rš   rÕ   rß   rñ   ró   rH  r-  rW  ri  r   rq  r0   r1   r2   ú<module>r›     sÖ  ðñó Û 	Û 	Û 
Û Û Ý Ý ß "Ý !Ý ã Û ÷÷ ÷ ó ÷ F÷÷ ÷ ñ õ *ç "Ý (÷÷ ð 
ˆ×	Ñ	˜HÓ	%€à"×,Ñ,×;Ñ;Ð òð �2—9‘9˜\¨2¯7©7¯<©<¸	¸¿	¹	ÐBRÐT^Ó8_ÐahÓ+iÓjÐ Ø×1Ñ1Ð ð !* §	¡	Ð*IÈ9×KaÑKaÓ bÐ Ø&˜RŸY™YÐ'CÐEbÓcÐ Ø�R—Y‘YÐ3Ð5OÓPÐ à�2—9‘9Ð/°·±·±¸i×>OÑ>OÐQZÓ1[Ó\Ð Ø#9Ð  Ù‹W�[‰[€
ð aò 
€CØ€r‡y�y�ƒ~Ñ!Øˆ�‰Ø�c�UÐkÐlØõ	
ð
ð IÐ Ø8Ð à—
‘
—‘Ð7¸Ó>×DÑDÓFÐJ^Ð^€Ù7DÑ3ÐJbÐ à"3Ð Ø‡:�:‡>�>Ð3°TÓ:ÐFØ€H‡M�Mð	6àôð
 ')§j¡j§n¡nÐ5VÐX\Ó&]Ð#Ø"$§*¡*§.¡.°Ð@_Ó"`Ð Ø7Ð:eÑeÐ Ø$CÐF_Ñ$_Ð !ð swñØðØ),ðØ9>¸sÀDÈ$¸Ñ9OðØbjÐknÑboóò.ò
ñ4  d¨C° oÑ 6ð À#ó ð.I x°¡}ð IÀ8ÈCÁ=ð IÐU]Ð^aÑUbó Ið<Ø˜3 §¡Ð+Ñ,ð<àð<ð ˆc�]ó	<ðD 48Ø Ø&*Ø(,Ø(,Ø"Ø"ØØ#Ø7;Ø-1Ø26Ø48Ø"&ñ!@Ø˜3 §¡Ð+Ñ,ð@à�C‰yð@ð ˜˜c 2§;¡;Ð.Ñ/Ñ0ð@ð ð	@ð
 ˜d‘^ð@ð �d˜3 ˜8‘nÑ%ð@ð �E˜$ ˜)Ñ$Ñ%ð@ð �s‰mð@ð ð@ð ð@ð ˜‰}ð@ð ˜˜s D¨¨c¨¡NÐ2Ñ3Ñ4ð@ð '+ð@ð ,0ð@ð .2ð@ð  ˜3‘-ð!@ð$ ˆc�]ó%@òHDóNð< #Ø(,Ø(,ða!ð #Ø(,Ø#òa!Ø˜˜RŸ[™[Ð(Ñ)ða!àða!ð �s‰mða!ð �d˜3 ˜8‘nÑ%ð	a!ð
 �E˜$ ˜)Ñ$Ñ%ða!ð ða!ð �S˜$ �_Ñ%ða!ð ˜‰}óa!÷HDñ DðN CLô  ðFk 5¨¨c¨¡?ó kðH ØØØØØ
ØØØØóF.ðV !%ØØ#(ñ	%Øð%à
�4˜‘9Ñ
ð%ð �C‰=ð%ð !ó	%÷P
ò 
r1   