ó
    pyüi&„  ã                   óØ  • S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
Jr  SSKJr  SSKJr  SS	KJrJr  SS
KJrJrJrJrJrJrJrJrJr  SSKJrJrJ r   \" 5       (       a  SSK!J"r"  \RF                  " \$5      r%\" S5      r&\'\(\
   S-  \(\
   S-  4   r)Sr*Sr+Sr,S r- " S S5      r. " S S\.5      r/S!S\04S jjr1S"S\0S\04S jjr2S r3S r4S r5 " S S\\(\   \)4   5      r6S /r7g)#z-Factory function to build auto-model classes.é    N)ÚOrderedDict)ÚIterator)ÚAnyÚTypeVar)Úrepo_existsé   )ÚPreTrainedConfig)Úget_class_from_dynamic_moduleÚresolve_trust_remote_code)	ÚCONFIG_NAMEÚcached_fileÚ	copy_funcÚextract_commit_hashÚfind_adapter_config_fileÚis_peft_availableÚis_torch_availableÚloggingÚrequires_backendsé   )Ú
AutoConfigÚmodel_type_to_module_nameÚ!replace_list_option_in_docstrings)ÚGenerationMixinÚ_TaJ  
    This is a generic model class that will be instantiated as one of the model classes of the library when created
    with the [`~BaseAutoModelClass.from_pretrained`] class method or the [`~BaseAutoModelClass.from_config`] class
    method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
aù  
        Instantiates one of the model classes of the library from a configuration.

        Note:
            Loading a model from its configuration file does **not** load the model weights. It only affects the
            model's configuration. Use [`~BaseAutoModelClass.from_pretrained`] to load the model weights.

        Args:
            config ([`PreTrainedConfig`]):
                The model class to instantiate is selected based on the configuration class:

                List options
            attn_implementation (`str`, *optional*):
                The attention implementation to use in the model (if relevant). Can be any of `"eager"` (manual implementation of the attention), `"sdpa"` (using [`F.scaled_dot_product_attention`](https://pytorch.org/docs/master/generated/torch.nn.functional.scaled_dot_product_attention.html)), `"flash_attention_2"` (using [Dao-AILab/flash-attention](https://github.com/Dao-AILab/flash-attention)), or `"flash_attention_3"` (using [Dao-AILab/flash-attention/hopper](https://github.com/Dao-AILab/flash-attention/tree/main/hopper)). By default, if available, SDPA will be used for torch>=2.1.1. The default is otherwise the manual `"eager"` implementation.

        Examples:

        ```python
        >>> from transformers import AutoConfig, BaseAutoModelClass

        >>> # Download configuration from huggingface.co and cache.
        >>> config = AutoConfig.from_pretrained("checkpoint_placeholder")
        >>> model = BaseAutoModelClass.from_config(config)
        ```
a™  
        Instantiate one of the model classes of the library from a pretrained model.

        The model class to instantiate is selected based on the `model_type` property of the config object (either
        passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it's missing, by
        falling back to using pattern matching on `pretrained_model_name_or_path`:

        List options

        The model is set in evaluation mode by default using `model.eval()` (so for instance, dropout modules are
        deactivated). To train the model, you should first set it back in training mode with `model.train()`

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

                    - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
                    - A path to a *directory* containing model weights saved using
                      [`~PreTrainedModel.save_pretrained`], e.g., `./my_model_directory/`.
            model_args (additional positional arguments, *optional*):
                Will be passed along to the underlying model `__init__()` method.
            config ([`PreTrainedConfig`], *optional*):
                Configuration for the model to use instead of an automatically loaded configuration. Configuration can
                be automatically loaded when:

                    - The model is a model provided by the library (loaded with the *model id* string of a pretrained
                      model).
                    - The model was saved using [`~PreTrainedModel.save_pretrained`] and is reloaded by supplying the
                      save directory.
                    - The model is loaded by supplying a local directory as `pretrained_model_name_or_path` and a
                      configuration JSON file named *config.json* is found in the directory.
            state_dict (*dict[str, torch.Tensor]*, *optional*):
                A state dictionary to use instead of a state dictionary loaded from saved weights file.

                This option can be used if you want to create a model from a pretrained configuration but load your own
                weights. In this case though, you should check if using [`~PreTrainedModel.save_pretrained`] and
                [`~PreTrainedModel.from_pretrained`] is not a simpler option.
            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 the (re-)download of the model weights and configuration files, overriding the
                cached versions if they exist.
            proxies (`dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'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 or not to only look at local files (e.g., not try downloading the model).
            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.
            trust_remote_code (`bool`, *optional*, defaults to `False`):
                Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
                should only be set to `True` for repositories you trust and in which you have read the code, as it will
                execute code present on the Hub on your local machine.
            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.
            kwargs (additional keyword arguments, *optional*):
                Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
                `output_attentions=True`). Behaves differently depending on whether a `config` is provided or
                automatically loaded:

                    - If a configuration is provided with `config`, `**kwargs` will be directly passed to the
                      underlying model's `__init__` method (we assume all relevant updates to the configuration have
                      already been done)
                    - If a configuration is not provided, `kwargs` will be first passed to the configuration class
                      initialization function ([`~PreTrainedConfig.from_pretrained`]). Each key of `kwargs` that
                      corresponds to a configuration attribute will be used to override said attribute with the
                      supplied `kwargs` value. Remaining keys that do not correspond to any configuration attribute
                      will be passed to the underlying model's `__init__` function.

        Examples:

        ```python
        >>> from transformers import AutoConfig, BaseAutoModelClass

        >>> # Download model and configuration from huggingface.co and cache.
        >>> model = BaseAutoModelClass.from_pretrained("checkpoint_placeholder")

        >>> # Update configuration during loading
        >>> model = BaseAutoModelClass.from_pretrained("checkpoint_placeholder", output_attentions=True)
        >>> model.config.output_attentions
        True
        ```
c                 óæ   • U[        U 5         n[        U[        [        45      (       d  U$ U Vs0 s H  o3R                  U_M     nn[        U S/ 5      nU H  nXd;   d  M
  XF   s  $    US   $ s  snf )NÚarchitecturesr   )ÚtypeÚ
isinstanceÚlistÚtupleÚ__name__Úgetattr)ÚconfigÚmodel_mappingÚsupported_modelsÚmodelÚname_to_modelr   Úarchs          Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/models/auto/auto_factory.pyÚ_get_model_classr*   ³   s€   € Ø$¤T¨&£\Ñ2ÐÜÐ&¬¬u¨×6Ñ6ØÐá8HÓIÒ8H¨u—^‘^ UÒ*Ñ8H€MÐIÜ˜F O°RÓ8€MÛˆØÕ Ø Ñ&Ò&ñ ð ˜AÑÐùò Js   °A.c                   óž   • \ rS rSrSrSS jr\S 5       r\S\S\4S j5       r	\S\
\R                  \
   -  4S	 j5       r\SSS
 jj5       rSrg)Ú_BaseAutoModelClasséÃ   NÚreturnc                 ó¢   • [        U R                  R                   SU R                  R                   SU R                  R                   S35      e)Nz+ is designed to be instantiated using the `z5.from_pretrained(pretrained_model_name_or_path)` or `z.from_config(config)` methods.)ÚOSErrorÚ	__class__r!   )ÚselfÚargsÚkwargss      r)   Ú__init__Ú_BaseAutoModelClass.__init__Ç   sR   € ÜØ�~‰~×&Ñ&Ð'ð (ØŸ.™.×1Ñ1Ð2ð 3Ø—‘×'Ñ'Ð(Ð(FðHó
ð 	
ó    c                 ó®  • UR                  SS 5      n[        US5      =(       a    U R                  UR                  ;   n[	        U5      U R
                  ;   nU=(       a3    [        XR
                  5      R                  R                  S5      (       + nU(       aK  UR                  U R                     nSU;   a  UR                  S5      S   nOS n[        X1R                  XTUS9nU(       a¡  U(       aš  U(       d“  SW;   a  UR                  S5      u  p—OUR                  n	[        Xy40 UD6n
U(       d*  U R                  UR                  U
SS9  U
R!                  U S	9  UR                  S
S 5      n[#        U
5      n
U
R$                  " U40 UD6$ U(       az  [        XR
                  5      n
U
R&                  UR(                  R+                  SS 5      :X  a(  UnUR-                  5       n[/        USS 5      nUb  XÑl        U
R$                  " U40 UD6$ [3        SUR                   SU R                   SSR5                  S U R
                   5       5       S35      e)NÚtrust_remote_codeÚauto_mapútransformers.ú--r   ©Úupstream_repoT©Úexist_ok©Ú
auto_classÚcode_revisionÚtext_configÚquantization_configú!Unrecognized configuration class ú for this kind of AutoModel: ú.
Model type should be one of ú, c              3   ó8   #   • U  H  oR                   v •  M     g 7f©N©r!   ©Ú.0Úcs     r)   Ú	<genexpr>Ú2_BaseAutoModelClass.from_config.<locals>.<genexpr>ÿ   ó   é € Ð4\ÒI[ÀA·Z¶ZÒI[ùó   ‚Ú.)ÚpopÚhasattrr!   r:   r   Ú_model_mappingr*   Ú
__module__Ú
startswithÚsplitr   Ú_name_or_pathÚname_or_pathr
   Úregisterr1   Úregister_for_auto_classÚ$add_generation_mixin_to_remote_modelÚ_from_configÚconfig_classÚsub_configsÚgetÚget_text_configr"   rE   Ú
ValueErrorÚjoin)Úclsr#   r4   r9   Úhas_remote_codeÚhas_local_codeÚexplicit_local_codeÚ	class_refr>   Úrepo_idÚmodel_classÚ_Úparent_configÚparent_quants                 r)   Úfrom_configÚ_BaseAutoModelClass.from_configÎ   s4  € à"ŸJ™JÐ':¸DÓAÐÜ! &¨*Ó5×Y¸#¿,¹,È&Ï/É/Ñ:YˆÜ˜f›¨×);Ñ);Ñ;ˆØ,÷ 1Ô5EØ×&Ñ&ó6
ç
‰*—Z‘Z Ó0ô21Ðö ØŸ™¨¯©Ñ5ˆIØ�yÓ Ø )§¡°Ó 5°aÑ 8‘à $�Ü 9Ø!×#7Ñ#7¸Ðhuñ!Ðö Ö0Ö9LØ�yÓ Ø%.§_¡_°TÓ%:Ñ"�˜à ×-Ñ-�Ü7¸	ÑUÈfÑUˆKö "Ø—‘˜V×-Ñ-¨{ÀT�ÑJØ×3Ñ3¸sÐ3ÑCØ—
‘
˜?¨DÓ1ˆAÜ>¸{ÓKˆKØ×+Ò+¨FÑ=°fÑ=Ð=ÞÜ*¨6×3EÑ3EÓFˆKØ×'Ñ'¨6×+=Ñ+=×+AÑ+AÀ-ÐQUÓ+VÓVð !'�Ø×/Ñ/Ó1�ô  ' }Ð6KÈTÓR�ØÑ+Ø1=Ô.Ø×+Ò+¨FÑ=°fÑ=Ð=äØ/°×0@Ñ0@Ð/AÐA^Ð_b×_kÑ_kÐ^lð m+Ø+/¯9©9Ñ4\È×I[ÒI[Ó4\Ó+\Ð*]Ð]^ð`ó
ð 	
r7   r#   c                 ó   • U$ )z`Additional autoclass-specific config post-loading manipulation. May be overridden in subclasses.© )rg   r#   s     r)   Ú_prepare_config_for_auto_classÚ2_BaseAutoModelClass._prepare_config_for_auto_class  s	   € ð ˆr7   Úpretrained_model_name_or_pathc                 ó*
  • UR                  SS 5      nUR                  S5      nSUS'   / SQnU Vs0 s H  owU;   d  M
  XsR                  U5      _M     nnUR                  SS 5      n	UR                  SS 5      n
UR                  SS 5      nUR                  S	S 5      nUb  XÈS	'   U
cC  [        U[        5      (       d!  [	        U[
        4S
S
S
S.UD6n[        XÚ5      n
O[        USS 5      n
[        5       (       aÊ  Uc  0 nUR                  5       nUb  XËS	'   [        U4SU
0UD6nUb�  [        USSS9 n[        R                  " U5      nXS'   [        R                  R!                  U5      (       aF  [        R                  R!                  [        R                  R#                  U[
        5      5      (       d  US   nS S S 5        [        U[        5      (       dõ  [        R$                  " U5      nUR                  S5      S:X  a  UR                  S5      nUR                  S5      S:X  a  UR                  S5      nUR                  S5      b  UR                  S5      n[&        R(                  " U4SU	U
S.UDUD6u  pCUR                  SS 5      S:X  a  SUS'   UR                  SS 5      S:X  a  SUS'   UR                  SS 5      b  US   US'   [+        US5      =(       a    U R,                  UR.                  ;   n[1        U5      U R2                  ;   nU=(       a3    [5        X@R2                  5      R6                  R9                  S5      (       + nS nU(       a3  UR.                  U R,                     nSU;   a  UR;                  S5      S   n[=        UUUUUS9nXSS'   X³S'   U(       a‡  U(       a€  U(       dy  [?        WU4SU	0UDUD6nUR                  SS 5      nU(       d*  U RA                  URB                  USS9  URE                  U S9  [G        U5      nUR(                  " U/UQ7SU0UDUD6$ U(       a‚  [5        X@R2                  5      nURH                  URJ                  R                  SS 5      :X  a)  UnURM                  5       n[        USS 5      nUb  UUl'        UR(                  " U/UQ7SU0UDUD6$ [Q        SURB                   SU R,                   S S!R#                  S" U R2                   5       5       S#35      es  snf ! , (       d  f       GNO= f)$Nr#   r9   TÚ
_from_auto)Ú	cache_dirÚforce_downloadÚlocal_files_onlyÚproxiesÚrevisionÚ	subfolderÚtokenrC   Ú_commit_hashÚadapter_kwargsr€   F)Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesÚ'_raise_exceptions_for_connection_errorsÚrzutf-8)ÚencodingÚ_adapter_model_pathÚbase_model_name_or_pathÚtorch_dtypeÚautoÚdtyperE   )Úreturn_unused_kwargsrC   r�   r:   r;   r<   r   r=   r?   rA   rD   rF   rG   rH   rI   c              3   ó8   #   • U  H  oR                   v •  M     g 7frK   rL   rM   s     r)   rP   Ú6_BaseAutoModelClass.from_pretrained.<locals>.<genexpr>š  rR   rS   rT   ))rU   rc   r   r	   r   r   r   r"   r   Úcopyr   ÚopenÚjsonÚloadÚosÚpathÚexistsrf   Údeepcopyr   Úfrom_pretrainedrV   r!   r:   r   rW   r*   rX   rY   rZ   r   r
   r]   r1   r^   r_   ra   rb   rd   rE   re   )rg   rw   Ú
model_argsr4   r#   r9   Úhub_kwargs_namesÚnameÚ
hub_kwargsrC   Úcommit_hashr‚   r€   Úresolved_config_fileÚmaybe_adapter_pathÚfÚadapter_configÚkwargs_origrn   rh   ri   rj   r>   rk   rm   ro   rp   s                              r)   r˜   Ú#_BaseAutoModelClass.from_pretrained  sr  € à—‘˜H dÓ+ˆØ"ŸJ™JÐ':Ó;ÐØ#ˆˆ|Ñò
Ðñ :JÓ\Ò9I°ÐU[É^Ó,�dŸJ™J tÓ,Ò,Ñ9Iˆ
Ð\ØŸ
™
 ?°DÓ9ˆØ—j‘j °Ó6ˆØŸ™Ð$4°dÓ;ˆà—‘˜w¨Ó-ˆàÑØ"'�wÑàÑÜ˜fÔ&6×7Ñ7ä'2Ø1Üð(ð 6;Ø:?Ø<Añ(ð !ñ(Ð$ô 2Ð2FÓT‘ä% f¨n¸dÓC�ä×ÑØÑ%Ø!#�Ø+×0Ñ0Ó2ˆNØÑ Ø*/˜wÑ'ä!9Ø-ñ"Ø<Gð"ØKYñ"Ðð "Ñ-ÜÐ,¨c¸GÒDÈÜ%)§Y¢Y¨q£\�Nà<YÐ#8Ñ9ô
 Ÿ7™7Ÿ>™>Ð*G×HÑHÔPR×PWÑPW×P^ÑP^ÜŸ™Ÿ™Ð%BÄKÓP÷Qñ Qð 9GÐG`Ñ8aÐ5÷ Eô ˜&Ô"2×3Ñ3ÜŸ-š-¨Ó/ˆKð �z‰z˜-Ó(¨FÓ2Ø—J‘J˜}Ó-�Ø�z‰z˜'Ó" fÓ,Ø—J‘J˜wÓ'�à�z‰zÐ/Ó0Ñ<Ø—J‘JÐ4Ó5�ä'×7Ò7Ø-ðà%)Ø+Ø(ñ	ð
 ðð ñ‰NˆFð �‰˜}¨dÓ3°vÓ=Ø(.��}Ñ%Ø�‰˜w¨Ó-°Ó7Ø"(��w‘Ø�‰Ð4°dÓ;ÑGØ0;Ð<QÑ0R�Ð,Ñ-ä! &¨*Ó5×Y¸#¿,¹,È&Ï/É/Ñ:YˆÜ˜f›¨×);Ñ);Ñ;ˆØ,÷ 1Ô5EØ×&Ñ&ó6
ç
‰*—Z‘Z Ó0ô21Ðð ˆÞØŸ™¨¯©Ñ5ˆIØ�yÓ Ø )§¡°Ó 5°aÑ 8�Ü5ØØ)ØØØ'ñ
Ðð '8Ð"Ñ#ð $2ÐÑ æÖ0Ö9LÜ7ØÐ8ñØHUðØYcðØgmñˆKð —‘˜°Ó5ˆAö "Ø—‘˜V×-Ñ-¨{ÀT�ÑJØ×3Ñ3¸sÐ3ÑCÜ>¸{ÓKˆKØ×.Ò.Ø-ðØ0:òØCIðØMWðØ[añð ö Ü*¨6×3EÑ3EÓFˆKØ×'Ñ'¨6×+=Ñ+=×+AÑ+AÀ-ÐQUÓ+VÓVð !'�Ø×/Ñ/Ó1�ô  ' }Ð6KÈTÓR�ØÑ+Ø1=�FÔ.Ø×.Ò.Ø-ðØ0:òØCIðØMWðØ[añð ô Ø/°×0@Ñ0@Ð/AÐA^Ð_b×_kÑ_kÐ^lð m+Ø+/¯9©9Ñ4\È×I[ÒI[Ó4\Ó+\Ð*]Ð]^ð`ó
ð 	
ùòG ]÷J EÖDús   ±	S>¾S>Ä1B
TÔ
Tc                 óÚ   • [        US5      (       a@  UR                  R                  UR                  :w  a  [        SUR                   SU S35      eU R                  R                  XUS9  g)zÞ
Register a new model for this class.

Args:
    config_class ([`PreTrainedConfig`]):
        The configuration corresponding to the model to register.
    model_class ([`PreTrainedModel`]):
        The model to register.
ra   z‚The model class you are passing has a `config_class` attribute that is not consistent with the config class you passed (model has z and you passed z!. Fix one of those so they match!r?   N)rV   ra   r!   re   rW   r]   )rg   ra   rm   r@   s       r)   r]   Ú_BaseAutoModelClass.register�  sx   € ô �; ×/Ñ/°K×4LÑ4L×4UÑ4UÐYe×YnÑYnÓ4nÜð6Ø6A×6NÑ6NÐ5OÐO_Ð`lÐ_mð n.ð.óð ð
 	×Ñ×#Ñ# LÈÐ#ÒQr7   rt   ©r.   N©F)r!   rX   Ú__qualname__Ú__firstlineno__rW   r5   Úclassmethodrq   r	   ru   Ústrr”   ÚPathLiker˜   r]   Ú__static_attributes__rt   r7   r)   r,   r,   Ã   sˆ   † à€Nô
ð ñ1
ó ð1
ðf ðÐ4Dð ÐIYó ó ðð ðS
¸CÀ"Ç+Á+ÈcÑBRÑ<Ró S
ó ðS
ðj õRó óRr7   r,   c                   óL   ^ • \ rS rSrSr\U 4S j5       r\U 4S j5       rSrU =r	$ )Ú_BaseAutoBackboneClassi±  Nc                 óÜ  >• [        U SS/5        SSKJn  UR                  SU" 5       5      nUR	                  S5      b  [        S5      eUR	                  SS	5      (       a  [        S
5      eUR                  SUR                  5      nUR                  SUR                  5      nUR                  SUR                  5      nU" UUUUS9nUR                  SS 5        [        T	U ](  " U4SS0UD6$ )NÚvisionÚtimmr   )ÚTimmBackboneConfigr#   Úout_featuresz0Cannot specify `out_features` for timm backbonesÚoutput_loading_infoFz@Cannot specify `output_loading_info=True` when loading from timmÚnum_channelsÚfeatures_onlyÚout_indices)Úbackboner¶   r·   r¸   Úuse_pretrained_backboneÚ
pretrainedT)r   Úmodels.timm_backboner³   rU   rc   re   r¶   r·   r¸   Úsuperrq   )
rg   rw   r™   r4   r³   r#   r¶   r·   r¸   r1   s
            €r)   Ú#_load_timm_backbone_from_pretrainedÚ:_BaseAutoBackboneClass._load_timm_backbone_from_pretrainedµ  så   ø€ ä˜# ¨&Ð1Ô2Ý>à—‘˜HÑ&8Ó&:Ó;ˆà�:‰:�nÓ%Ñ1ÜÐOÓPÐPà�:‰:Ð+¨U×3Ñ3ÜÐ_Ó`Ð`à—z‘z .°&×2EÑ2EÓFˆØŸ
™
 ?°F×4HÑ4HÓIˆØ—j‘j °×0BÑ0BÓCˆÙ#Ø2Ø%Ø'Ø#ñ	
ˆð 	�
‰
Ð,¨dÔ3Ü‰wÒ" 6ÑE°dÐE¸fÑEÐEr7   c                 óœ   >• UR                  SS 5        [        U5      (       d  U R                  " U/UQ70 UD6$ [        TU ]  " U/UQ70 UD6$ )NÚuse_timm_backbone)rU   r   r¾   r½   r˜   )rg   rw   r™   r4   r1   s       €r)   r˜   Ú&_BaseAutoBackboneClass.from_pretrainedÏ  sX   ø€ à�
‰
Ð&¨Ô-ÜÐ8×9Ñ9Ø×:Ò:Ð;XÐpÐ[eÒpÐioÑpÐpä‰wÒ&Ð'DÐ\ÀzÒ\ÐU[Ñ\Ð\r7   rt   )
r!   rX   r¨   r©   rW   rª   r¾   r˜   r­   Ú__classcell__)r1   s   @r)   r¯   r¯   ±  s2   ø† à€NàôFó ðFð2 ô]ó ö]r7   r¯   Úhead_docc                 óp   • [        U5      S:”  a  U R                  SSU S35      $ U R                  SS5      $ )Nr   z(one of the model classes of the library z0one of the model classes of the library (with a z head) z-one of the base model classes of the library )ÚlenÚreplace)Ú	docstringrÄ   s     r)   Úinsert_head_docrÉ   Ø  sK   € Ü
ˆ8ƒ}�qÓØ× Ñ Ø6Ø>¸x¸jÈÐPó
ð 	
ð ×ÑØ2Ð4cóð r7   Úcheckpoint_for_examplec                 óà  • U R                   nU R                  n[        [        US9nUR	                  SU5      U l        [        [        R                  5      n[        [        US9nUR	                  SU5      nUR	                  SU5      nXvl        [        UR                   SS9" U5      n[        U5      U l        [        n[        [        R                  5      n	[        X‚S9nUR	                  SU5      nUR	                  SU5      nUR                  S5      S   R                  S5      S	   n
UR	                  S
U
5      nX‰l        [        UR                   5      " U	5      n	[        U	5      U l        U $ )N)rÄ   ÚBaseAutoModelClassÚcheckpoint_placeholderF)Úuse_model_typesÚ/éÿÿÿÿÚ-r   Úshortcut_placeholder)rW   r!   rÉ   ÚCLASS_DOCSTRINGrÇ   Ú__doc__r   r,   rq   ÚFROM_CONFIG_DOCSTRINGr   rª   ÚFROM_PRETRAINED_TORCH_DOCSTRINGr˜   rZ   )rg   rÊ   rÄ   r$   r›   Úclass_docstringrq   Úfrom_config_docstringÚfrom_pretrained_docstringr˜   Úshortcuts              r)   Úauto_class_updaterÛ   ã  sb  € à×&Ñ&€MØ�<‰<€DÜ%¤oÀÑI€OØ!×)Ñ)Ð*>ÀÓE€C„Kô Ô/×;Ñ;Ó<€KÜ+Ô,AÈHÑUÐØ1×9Ñ9Ð:NÐPTÓUÐØ1×9Ñ9Ð:RÐTjÓkÐØ/ÔÜ3°M×4PÑ4PÐbgÒhÐitÓu€KÜ! +Ó.€C„Oä ?ÐÜÔ 3× CÑ CÓD€OÜ /Ð0IÑ ]ÐØ 9× AÑ AÐBVÐX\Ó ]ÐØ 9× AÑ AÐBZÐ\rÓ sÐØ%×+Ñ+¨CÓ0°Ñ4×:Ñ:¸3Ó?ÀÑB€HØ 9× AÑ AÐBXÐZbÓ cÐØ7ÔÜ7¸×8TÑ8TÔUÐVeÓf€OÜ% oÓ6€CÔØ€Jr7   c                 ó°   • / nU R                  5        H?  n[        U[        [        45      (       a  U[        U5      -  nM.  UR	                  U5        MA     U$ rK   )Úvaluesr   r   r    Úappend)r$   Úresultr&   s      r)   Ú
get_valuesrà     sL   € Ø€FØ×%Ñ%Ö'ˆÜ�eœd¤E˜]×+Ñ+Ø”d˜5“kÑ!ŠFà�M‰M˜%Ö ñ	 (ð €Mr7   c           
      óê  ^ • Uc  g [        U[        5      (       a  [        U 4S jU 5       5      $ [        U[        5      (       a0  UR                  5        VVs0 s H  u  p#U[	        T U5      _M     snn$ [        T U5      (       a  [        T U5      $ [        R                  " S5      nT U:w  a   [	        XA5      $ [        SU SU S35      es  snnf ! [         a    [        SU ST  SU S35      ef = f)Nc              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7frK   )Úgetattribute_from_module)rN   ÚaÚmodules     €r)   rP   Ú+getattribute_from_module.<locals>.<genexpr>  s   øé € ÐGÂ$¸QÔ-¨f°a×8Ð8Â$ùs   ƒÚtransformerszCould not find z neither in z nor in Ú!z in )
r   r    ÚdictÚitemsrã   rV   r"   Ú	importlibÚimport_modulere   )rå   ÚattrÚkÚvÚtransformers_modules   `    r)   rã   rã     s  ø€ Ø�|ØÜ�$œ×ÑÜÔGÁ$ÓGÓGÐGÜ�$œ×ÑØCGÇ:Á:Ä<ÔPÂ<¹4¸1�Ô+¨F°AÓ6Ò6Á<ÒPÐPÜˆv�t×ÑÜ�v˜tÓ$Ð$ô $×1Ò1°.ÓAÐàÐ$Ó$ð	iÜ+Ð,?ÓFÐFô ˜?¨4¨&°Ð5HÐ4IÈÐKÓLÐLùó Qøô ó 	iÜ˜¨t¨f°LÀÀÈÐQdÐPeÐefÐgÓhÐhð	iús   ÁCÂ/
C Ã C2c                 ó�  • S[        U R                  5      ;  a  U $ S[        U R                  5      ;   a  U $ [        U S5      =(       a    S[        [	        U S5      5      ;  n[        U S5      =(       a    S[        [	        U S5      5      ;  nU(       d  U(       a+  [        U R                  U [        40 U R                  E5      nU$ U $ )a•  
Adds `GenerationMixin` to the inheritance of `model_class`, if `model_class` is a PyTorch model.

This function is used for backwards compatibility purposes: in v4.45, we've started a deprecation cycle to make
`PreTrainedModel` stop inheriting from `GenerationMixin`. Without this function, older models dynamically loaded
from the Hub may not have the `generate` method after we remove the inheritance.
ztorch.nn.modules.module.Moduler   ÚgenerateÚprepare_inputs_for_generation)	r«   Ú__mro__Ú	__bases__rV   r"   r   r!   r   Ú__dict__)rm   Úhas_custom_generate_in_classÚhas_custom_prepare_inputsÚ!model_class_with_generation_mixins       r)   r_   r_   "  sÙ   € ð (¬s°;×3FÑ3FÓ/GÓGØÐð œC × 5Ñ 5Ó6Ó6ØÐô $+¨;¸
Ó#C÷ $ÐHYÔadÜ�˜ZÓ(óbñ IÐ ô !(¨Ð5TÓ U÷ !ÐZkÔsvÜ�Ð<Ó=ótñ [Ðö $Ö'@Ü,0Ø× Ñ  ;´Ð"@ÐBZÀ[×EYÑEYÐBZó-
Ð)ð 1Ð0ØÐr7   c                   ó  • \ rS rSrSrSS jrS\4S jrS\\	   S\
4S jrS	 rS\\\	      4S
 jrS\\	   S\S\
\-  4S jrS\4S jrS\\
   4S jrS\\\\	   \
4      4S jrS\\\	      4S jrS\S\4S jrSS\\	   S\
SS4S jjrSrg)Ú_LazyAutoMappingiB  zø
A mapping config to object (model or tokenizer for instance) that will load keys and values when it is accessed.

Args:
    - config_mapping: The map model type to config class
    - model_mapping: The map model type to model (or tokenizer) class
r.   Nc                 ó¸   • Xl         UR                  5        VVs0 s H  u  p4XC_M	     snnU l        X l        X R                  l        0 U l        0 U l        g s  snnf rK   )Ú_config_mappingrê   Ú_reverse_config_mappingrW   Ú_extra_contentÚ_modules)r2   Úconfig_mappingr$   rî   rï   s        r)   r5   Ú_LazyAutoMapping.__init__K  sU   € Ø-ÔØ9G×9MÑ9MÔ9OÔ'PÒ9O±°¨ªÑ9OÒ'PˆÔ$Ø+ÔØ-1×ÑÔ*Ø ˆÔØˆ�ùó	 (Qs   šAc                 óØ   • [        U R                  R                  5       5      R                  U R                  R                  5       5      n[        U5      [        U R                  5      -   $ rK   )Úsetrý   ÚkeysÚintersectionrW   rÆ   rÿ   )r2   Úcommon_keyss     r)   Ú__len__Ú_LazyAutoMapping.__len__S  sP   € Ü˜$×.Ñ.×3Ñ3Ó5Ó6×CÑCÀD×DWÑDW×D\ÑD\ÓD^Ó_ˆÜ�;Ó¤# d×&9Ñ&9Ó":Ñ:Ð:r7   Úkeyc                 óâ  • XR                   ;   a  U R                   U   $ U R                  UR                     nX R                  ;   a   U R                  U   nU R	                  X#5      $ U R
                  R                  5        VVs/ s H  u  pEXQR                  :X  d  M  UPM     nnnU H4  nXpR                  ;   d  M  U R                  U   nU R	                  Xs5      s  $    [        U5      es  snnf rK   )rÿ   rþ   r!   rW   Ú_load_attr_from_modulerý   rê   ÚKeyError)r2   r
  Ú
model_typeÚ
model_namerî   rï   Úmodel_typesÚmtypes           r)   Ú__getitem__Ú_LazyAutoMapping.__getitem__W  sÛ   € Ø×%Ñ%Ó%Ø×&Ñ& sÑ+Ð+Ø×1Ñ1°#·,±,Ñ?ˆ
Ø×,Ñ,Ó,Ø×,Ñ,¨ZÑ8ˆJØ×.Ñ.¨zÓFÐFð &*×%9Ñ%9×%?Ñ%?Ô%AÔWÒ%A™T˜QÀQÏ,É,ÑEV—qÑ%AˆÑWÛ ˆEØ×+Ñ+Õ+Ø!×0Ñ0°Ñ7�
Ø×2Ñ2°5ÓEÒEñ !ô �s‹mÐùó Xs   ÂC+ÂC+c                 ó¶   • [        U5      nX0R                  ;  a'  [        R                  " SU 3S5      U R                  U'   [	        U R                  U   U5      $ )NrT   ztransformers.models)r   r   rë   rì   rã   )r2   r  rí   Úmodule_names       r)   r  Ú'_LazyAutoMapping._load_attr_from_moduleg  sO   € Ü/°
Ó;ˆØŸm™mÓ+Ü)2×)@Ò)@À1À[ÀMÐARÐTiÓ)jˆD�M‰M˜+Ñ&Ü'¨¯©°kÑ(BÀDÓIÐIr7   c                 óö   • U R                   R                  5        VVs/ s H'  u  pXR                  ;   d  M  U R                  X5      PM)     nnnU[	        U R
                  R                  5       5      -   $ s  snnf rK   )rý   rê   rW   r  r   rÿ   r  )r2   r
  r›   Úmapping_keyss       r)   r  Ú_LazyAutoMapping.keysm  st   € ð "×1Ñ1×7Ñ7Ô9ô
â9‘	�Ø×)Ñ)Ñ)ó 3ˆD×'Ñ'¨Ö2Ù9ð 	ñ 
ð
 œd 4×#6Ñ#6×#;Ñ#;Ó#=Ó>Ñ>Ð>ùó
ó
   žA5·A5Údefaultc                 óJ   •  U R                  U5      $ ! [         a    Us $ f = frK   )r  r  )r2   r
  r  s      r)   rc   Ú_LazyAutoMapping.getu  s,   € ð	Ø×#Ñ# CÓ(Ð(øÜó 	ØŠNð	ús   ‚ “"¡"c                 ó4   • [        U R                  5       5      $ rK   )Úboolr  ©r2   s    r)   Ú__bool__Ú_LazyAutoMapping.__bool__{  ó   € Ü�D—I‘I“KÓ Ð r7   c                 óö   • U R                   R                  5        VVs/ s H'  u  pXR                  ;   d  M  U R                  X5      PM)     nnnU[	        U R
                  R                  5       5      -   $ s  snnf rK   )rW   rê   rý   r  r   rÿ   rÝ   )r2   r
  r›   Úmapping_valuess       r)   rÝ   Ú_LazyAutoMapping.values~  st   € ð "×0Ñ0×6Ñ6Ô8ô
â8‘	�Ø×*Ñ*Ñ*ó 3ˆD×'Ñ'¨Ö2Ù8ð 	ñ 
ð
 ¤ T×%8Ñ%8×%?Ñ%?Ó%AÓ BÑBÐBùó
r  c           	      ó&  • U R                    Vs/ s HP  nXR                  ;   d  M  U R                  XR                  U   5      U R                  XR                   U   5      4PMR     nnU[        U R                  R                  5       5      -   $ s  snf rK   )rW   rý   r  r   rÿ   rê   )r2   r
  Úmapping_itemss      r)   rê   Ú_LazyAutoMapping.items†  s—   € ð ×*Ò*ó
ò
 +�Ø×*Ñ*Ñ*óØ×+Ñ+¨C×1EÑ1EÀcÑ1JÓKØ×+Ñ+¨C×1DÑ1DÀSÑ1IÓJóñ +ð 	ð 
ð œt D×$7Ñ$7×$=Ñ$=Ó$?Ó@Ñ@Ð@ùò
s   �B¦A Bc                 ó4   • [        U R                  5       5      $ rK   )Úiterr  r   s    r)   Ú__iter__Ú_LazyAutoMapping.__iter__‘  r#  r7   Úitemc                 óÈ   • XR                   ;   a  g[        US5      (       a  UR                  U R                  ;  a  gU R                  UR                     nX R                  ;   $ )NTr!   F)rÿ   rV   r!   rþ   rW   )r2   r.  r  s      r)   Ú__contains__Ú_LazyAutoMapping.__contains__”  sU   € Ø×&Ñ&Ó&ØÜ�t˜Z×(Ñ(¨D¯M©MÀ×A]ÑA]Ó,]ØØ×1Ñ1°$·-±-Ñ@ˆ
Ø×0Ñ0Ñ0Ð0r7   Úvaluec                 óò   • [        US5      (       aX  UR                  U R                  ;   a>  U R                  UR                     nX@R                  ;   a  U(       d  [	        SU S35      eX R
                  U'   g)z'
Register a new model in this mapping.
r!   Ú'z*' is already used by a Transformers model.N)rV   r!   rþ   rW   re   rÿ   )r2   r
  r2  r@   r  s        r)   r]   Ú_LazyAutoMapping.registerœ  sg   € ô �3˜
×#Ñ#¨¯©¸×8TÑ8TÓ(TØ×5Ñ5°c·l±lÑCˆJØ×0Ñ0Ó0¾Ü  1 S EÐ)SÐ!TÓUÐUà#(×Ñ˜CÒ r7   )rý   rÿ   rW   r   rþ   r¦   r§   )r!   rX   r¨   r©   rÔ   r5   Úintr  r   r	   Ú_LazyAutoMappingValuer  r  r   r  r   rc   r  r!  rÝ   r    rê   r   r,  r0  r]   r­   rt   r7   r)   rû   rû   B  s  † ñôð;˜ô ;ð˜tÐ$4Ñ5ð Ð:Oô ò Jð?�d˜4Ð 0Ñ1Ñ2ô ?ð�tÐ,Ñ-ð ¸ð Ð?TÐWYÑ?Yô ð!˜$ô !ðC˜Ð2Ñ3ô Cð	A�t˜E $Ð'7Ñ"8Ð:OÐ"OÑPÑQô 	Að!˜( 4Ð(8Ñ#9Ñ:ô !ð1 ð 1¨$ô 1ñ	)˜DÐ!1Ñ2ð 	)Ð;Pð 	)Ðei÷ 	)ð 	)r7   rû   rà   )Ú )zgoogle-bert/bert-base-casedr8  )8rÔ   r�   rë   r’   r”   Úcollectionsr   Úcollections.abcr   Útypingr   r   Úhuggingface_hubr   Úconfiguration_utilsr	   Údynamic_module_utilsr
   r   Úutilsr   r   r   r   r   r   r   r   r   Úconfiguration_autor   r   r   Ú
generationr   Ú
get_loggerr!   Úloggerr   r    r   r7  rÓ   rÕ   rÖ   r*   r,   r¯   r«   rÉ   rÛ   rà   rã   r_   rû   Ú__all__rt   r7   r)   Ú<module>rE     s"  ðñ 4ã Û Û Û 	Ý #Ý $ß å 'å 3ß \÷
÷ 
õ 
÷ iÑ hñ ×ÑÝ-ð 
×	Ò	˜HÓ	%€áˆTƒ]€à˜d 3™i¨$Ñ.°°S±	¸DÑ0@Ð@ÑAÐ ð€ðÐ ð4Z#Ð òz÷ kRñ kRô\$]Ð0ô $]ñN¨õ ñ°3ð Ðbeõ ò<òMò,ô@c)�{ 4Ð(8Ñ#9Ð;PÐ#PÑQô c)ðL ˆ.�r7   