§
    [zniõi ã            	       ó¦  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl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mZmZmZmZmZmZ d dlZd dlmZ d dlmZmZ d dlm Z m!Z! d d	l"m#Z# d
dl$m%Z% d
dl&m'Z' d
dl(m)Z) d
dl*m+Z+m,Z, d
dl-m.Z.m/Z/m0Z0 d
dl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 d
dl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZ d
dl[m\Z\m]Z] d
dl^m_Z_m`Z`maZambZb d
dlcmdZdmeZemfZfmgZg d
dlhmiZi ejj         k                    dd¦  «         l                    ¦   «         Zmejj         k                    dd¦  «         l                    ¦   «         Zn eM¦   «         r$d dlompZpmqZqmrZr d dlsmtZt d dlumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}  eV¦   «         rd dl~mZ d dl€m�Z‚ d dl€mƒZ„  eXj…        e†¦  «        Z‡daˆd „ Z‰d!„ ZŠ e`¦   «         r2d dl‹mŒc mZ� d d"lŽm�Z�  ej‘        e�¦  «         ej‘        d#¦  «        k    Z’nd$Z’ eT¦   «         rd
d%l9m“Z“ edUd&„¦   «         Z”d'eej•        e,d(f         fd)„Z–d'eej•        e,d(f         fd*„Z—d'eej•        e,d(f         fd+„Z˜d,„ Z™d-„ Zšd.„ Z›d/eDfd0eeœej        f         d1ee�eœf         d2eœfd3„ZždVd4„ZŸd5eeœej         f         fd6„Z¡d7„ Z¢d8„ Z£d9„ Z¤d:„ Z¥	 	 	 	 	 	 	 	 	 dWd;„Z¦dXd2eœd<eeœ         d=eœfd>„Z§ G d?„ d(¦  «        Z¨ G d@„ dAej•        e¨e,eGe.¦  «        Z© eIe©jª        ¦  «        e©_ª        e©jª        j«        �,e©jª        j«         ¬                    dBdCdD¬E¦  «        e©jª        _«         G dF„ dGej•        ¦  «        Z­ G dH„ dIej•        ¦  «        Z® G dJ„ dKej•        ¦  «        Z¯e G dL„ dMeF¦  «        ¦   «         Z° G dN„ dOej•        ¦  «        Z± G dP„ dQej•        ¦  «        Z²dBej•        d=ej•        fdR„Z³dS„ Z´dT„ ZµdS )Yé    N)Úcontextmanager)Ú	dataclass)ÚpartialÚwraps)ÚAnyÚCallableÚDictÚListÚOptionalÚTupleÚUnion)Úversion)ÚTensorÚnn)ÚCrossEntropyLossÚIdentity)Ú
checkpointé   )Úget_activation)ÚPretrainedConfig)Úcustom_object_save)ÚGenerationConfigÚGenerationMixin)ÚPeftAdapterMixinÚdeepspeed_configÚis_deepspeed_zero3_enabled)ÚConv1DÚapply_chunking_to_forwardÚ find_pruneable_heads_and_indicesÚid_tensor_storageÚprune_conv1d_layerÚprune_layerÚprune_linear_layer)!ÚADAPTER_SAFE_WEIGHTS_NAMEÚADAPTER_WEIGHTS_NAMEÚCONFIG_NAMEÚDUMMY_INPUTSÚFLAX_WEIGHTS_NAMEÚSAFE_WEIGHTS_INDEX_NAMEÚSAFE_WEIGHTS_NAMEÚTF2_WEIGHTS_NAMEÚTF_WEIGHTS_NAMEÚWEIGHTS_INDEX_NAMEÚWEIGHTS_NAMEÚContextManagersÚModelOutputÚPushToHubMixinÚcached_fileÚ	copy_funcÚdownload_urlÚextract_commit_hashÚhas_fileÚis_accelerate_availableÚis_auto_awq_availableÚis_auto_gptq_availableÚis_bitsandbytes_availableÚis_flash_attn_2_availableÚis_offline_modeÚis_optimum_availableÚis_peft_availableÚis_remote_urlÚis_safetensors_availableÚis_torch_tpu_availableÚloggingÚreplace_return_docstringsÚ	strtobool)Úconvert_file_size_to_intÚget_checkpoint_shard_files)ÚENV_VARS_TRUE_VALUESÚis_sagemaker_mp_enabledÚis_torch_fx_proxyÚis_torchdynamo_compiling)Ú	AwqConfigÚBitsAndBytesConfigÚ
GPTQConfigÚQuantizationMethod)Úrequire_version_coreÚXLA_USE_BF16Ú0ÚXLA_DOWNCAST_BF16)Údispatch_modelÚinfer_auto_device_mapÚinit_empty_weights)Úadd_hook_to_module)Ú$check_tied_parameters_on_same_deviceÚfind_tied_parametersÚget_balanced_memoryÚget_max_memoryÚload_offloaded_weightsÚoffload_weightÚsave_offload_indexÚset_module_tensor_to_device)Ú	safe_open)Ú	load_file)Ú	save_fileTc                  ó>  — t           j                             ¦   «         ot           j                             ¦   «         oat	          t
          j                             dd¦  «        ¦  «        dk    o0t	          t
          j                             dd¦  «        ¦  «        dk    S )NÚACCELERATE_USE_FSDPÚFalser   ÚFSDP_CPU_RAM_EFFICIENT_LOADING)ÚtorchÚdistributedÚis_availableÚis_initializedrD   ÚosÚenvironÚget© ó    ú{/var/www/html/cool-property-finder/image-detection-backend/venv/lib/python3.11/site-packages/transformers/modeling_utils.pyÚis_fsdp_enabledrp   ~   s‚   € åÔ×&Ò&Ñ(Ô(ð 	VÝÔ×,Ò,Ñ.Ô.ð	Vå•b”j—n’nÐ%:¸GÑDÔDÑEÔEÈÒJð	Võ •b”j—n’nÐ%EÀwÑOÔOÑPÔPÐTUÒUð	rn   c                  ó€   — t          ¦   «         o0t          t          j                             dd¦  «        ¦  «        dk    S )NÚ
LOCAL_RANKéÿÿÿÿr   )rp   Úintrj   rk   rl   rm   rn   ro   Úis_fsdp_enabled_and_dist_rank_0ru   ‡   s0   € ÝÑÔÐK¥¥R¤Z§^¢^°LÀ"Ñ%EÔ%EÑ!FÔ!FÈ!Ò!KÐKrn   ©Ú__version__z1.10F)Úfind_adapter_config_filec              #   ó<   K  — t           }| rda 	 dV — |a dS # |a w xY w)z¸
    Context manager to globally disable weight initialization to speed up loading large models.

    TODO(Patrick): Delete safety argument `_enable=True` at next major version. .
    FN)Ú_init_weights)Ú_enableÚold_init_weightss     ro   Úno_init_weightsr}   —   sD   è è € õ %ÐØð Øˆð)Øˆˆˆà(ˆˆˆøÐ(ˆÐ(Ð(Ð(Ð(s   � —Ú	parameterÚModuleUtilsMixinc                 ó<  — 	 t          |                      ¦   «         ¦  «        j        S # t          $ ri dt          j        dt          t          t          t          f                  fd„}|  
                    |¬¦  «        }t          |¦  «        }|d         j        cY S w xY w)NÚmoduleÚreturnc                 óL   — d„ | j                              ¦   «         D ¦   «         }|S )Nc                 óD   — g | ]\  }}t          j        |¦  «        ¯||f‘ŒS rm   ©rf   Ú	is_tensor©Ú.0ÚkÚvs      ro   ú
<listcomp>zHget_parameter_device.<locals>.find_tensor_attributes.<locals>.<listcomp>¯   ó0   € ÐWÐWÐW¡  AÅEÄOÐTUÑDVÔDVÐW�q˜!�fÐWÐWÐWrn   ©Ú__dict__Úitems©r�   Útupless     ro   Úfind_tensor_attributesz4get_parameter_device.<locals>.find_tensor_attributes®   ó(   € ØWÐW¨¬×)>Ò)>Ñ)@Ô)@ÐWÑWÔWˆFØˆMrn   ©Úget_members_fnr   )ÚnextÚ
parametersÚdeviceÚStopIterationr   ÚModuler
   r   Ústrr   Ú_named_members©r~   r’   ÚgenÚfirst_tuples       ro   Úget_parameter_devicer    ¨   s¨   € ð%Ý�I×(Ò(Ñ*Ô*Ñ+Ô+Ô2Ð2øÝð 	%ð 	%ð 	%ð	­2¬9ð 	½½eÅCÍÀKÔ>PÔ9Qð 	ð 	ð 	ð 	ð ×&Ò&Ð6LÐ&ÑMÔMˆÝ˜3‘i”iˆØ˜1Œ~Ô$Ð$Ð$Ð$ð	%øøøó   ‚%( ¨A0BÂBc                 ó<  — 	 t          |                      ¦   «         ¦  «        j        S # t          $ ri dt          j        dt          t          t          t          f                  fd„}|  
                    |¬¦  «        }t          |¦  «        }|d         j        cY S w xY w)z`
    Returns the first parameter dtype (can be non-floating) or asserts if none were found.
    r�   r‚   c                 óL   — d„ | j                              ¦   «         D ¦   «         }|S )Nc                 óD   — g | ]\  }}t          j        |¦  «        ¯||f‘ŒS rm   r…   r‡   s      ro   r‹   zMget_first_parameter_dtype.<locals>.find_tensor_attributes.<locals>.<listcomp>Á   rŒ   rn   r�   r�   s     ro   r’   z9get_first_parameter_dtype.<locals>.find_tensor_attributesÀ   r“   rn   r”   r   )r–   r—   Údtyper™   r   rš   r
   r   r›   r   rœ   r�   s       ro   Úget_first_parameter_dtyper¦   ·   s¨   € ð$Ý�I×(Ò(Ñ*Ô*Ñ+Ô+Ô1Ð1øÝð 	$ð 	$ð 	$ð	­2¬9ð 	½½eÅCÍÀKÔ>PÔ9Qð 	ð 	ð 	ð 	ð ×&Ò&Ð6LÐ&ÑMÔMˆÝ˜3‘i”iˆØ˜1Œ~Ô#Ð#Ð#Ð#ð	$øøør¡   c                 ó,  — d}|                       ¦   «         D ]²}|j        }|                     ¦   «         r•t          t          v rt          ¦   «         rt          j        c S t          t          v rTt          ¦   «         rF|j        t          j	        k    rt          j        c S |j        t          j
        k    rt          j        c S |j        c S Œ³|�|S dt          j        dt          t          t           t"          f                  fd„}|                      |¬¦  «        }d}|D ]-}|}|d                              ¦   «         r|d         j        c S Œ.|�|d         j        S |                      ¦   «         D ]&}|j        }|                     ¦   «         r	|j        c S Œ'|S )zz
    Returns the first found floating dtype in parameters if there is one, otherwise returns the last dtype it found.
    Nr�   r‚   c                 óL   — d„ | j                              ¦   «         D ¦   «         }|S )Nc                 óD   — g | ]\  }}t          j        |¦  «        ¯||f‘ŒS rm   r…   r‡   s      ro   r‹   zGget_parameter_dtype.<locals>.find_tensor_attributes.<locals>.<listcomp>ä   s0   € ÐSÐSÐS™T˜Q ÅÄÐPQÑ@RÔ@RÐS�1�a�&ÐSÐSÐSrn   r�   r�   s     ro   r’   z3get_parameter_dtype.<locals>.find_tensor_attributesã   s(   € ØSÐS V¤_×%:Ò%:Ñ%<Ô%<ÐSÑSÔSˆØˆrn   r”   r   )r—   r¥   Úis_floating_pointrP   rG   rA   rf   Úbfloat16rR   ÚfloatÚdoubleÚfloat32r   rš   r
   r   r›   r   rœ   Úbuffers)r~   Ú
last_dtypeÚtr’   rž   Ú
last_tupleÚtuples          ro   Úget_parameter_dtyper´   É   sÍ  € ð €JØ×!Ò!Ñ#Ô#ð ð ˆØ”Wˆ
Ø×ÒÑ Ô ð 	õ
 Õ3Ð3Ð3Õ8NÑ8PÔ8PÐ3Ý”~Ð%Ð%Ð%Ý Õ$8Ð8Ð8Õ=SÑ=UÔ=UÐ8Ø”7�eœkÒ)Ð)Ý œ>Ð)Ð)Ð)Ø”7�eœlÒ*Ð*Ý œ=Ð(Ð(Ð(Ø”7ˆNˆNˆNð	ð ÐàÐð¥r¤yð µT½%ÅÅVÀÔ:LÔ5Mð ð ð ð ð ×
"Ò
"Ð2HÐ
"Ñ
IÔ
I€CØ€JØð "ð "ˆØˆ
Ø�Œ8×%Ò%Ñ'Ô'ð 	"Ø˜”8”>Ð!Ð!Ð!ð	"ð Ðà˜!Œ}Ô"Ð"ð ×ÒÑ Ô ð ð ˆØ”Wˆ
Ø×ÒÑ Ô ð 	Ø”7ˆNˆNˆNð	àÐrn   c                 óˆ   — |                       ¦   «         D ]}|                     ¦   «         r	|j        c S Œ t          d¦  «        ‚)z_
    Returns the first found floating dtype in `state_dict` or asserts if none were found.
    z5couldn't find any floating point dtypes in state_dict)Úvaluesrª   r¥   Ú
ValueError©Ú
state_dictr±   s     ro   Úget_state_dict_float_dtyperº   ú   sT   € ð ×ÒÑ Ô ð ð ˆØ×ÒÑ Ô ð 	Ø”7ˆNˆNˆNð	õ ÐLÑ
MÔ
MÐMrn   c                 ó¶   — |                       ¦   «         D ]}|                     ¦   «         r	|j        c S Œ t          |                       ¦   «         ¦  «        j        S )zt
    Returns the first found floating dtype in `state_dict` if there is one, otherwise returns the first dtype.
    )r¶   rª   r¥   r–   r¸   s     ro   Úget_state_dict_dtyper¼     sb   € ð ×ÒÑ Ô ð /ð /ˆØ×ÒÑ Ô ð 	Ø”7ˆNˆNˆNð	õ
 �J×%Ò%Ñ'Ô'Ñ(Ô(Ô.Ð.rn   c                 óì   — | t           j        k    rdS t          j        dt	          | ¦  «        ¦  «        }|€t          d| › d�¦  «        ‚t          |                     ¦   «         d         ¦  «        }|dz  S )zž
    Returns the size (in bytes) occupied by one parameter of type `dtype`.

    Example:

    ```py
    >>> dtype_byte_size(torch.float32)
    4
    ```
    g      À?z[^\d](\d+)$Nz`dtype` is not a valid dtype: ú.r   é   )rf   ÚboolÚreÚsearchr›   r·   rt   Úgroups)r¥   Ú
bit_searchÚbit_sizes      ro   Údtype_byte_sizerÆ     su   € ð •”
ÒÐØˆuÝ”˜>­3¨u©:¬:Ñ6Ô6€JØÐÝÐB¸%ÐBÐBÐBÑCÔCÐCÝ�:×$Ò$Ñ&Ô& qÔ)Ñ*Ô*€HØ�q‰=Ðrn   Ú10GBr¹   Úmax_shard_sizeÚweights_namec           
      ó€  — t          |¦  «        }i g}d}d}i }|                      ¦   «         D ]Î\  }}t          |t          ¦  «        rŒt	          |¦  «        }	|	|v r||	         }
|||
         |<   ŒB|                     ¦   «         t          |j        ¦  «        z  }||z   |k    r0t          |d         ¦  «        dk    r| 	                    i ¦  «         d}||d         |<   ||z  }||z  }t          |¦  «        dz
  ||	<   ŒÏt          |¦  «        dk    r||d         idfS i }i }t          |¦  «        D ]„\  }}|                     dd|dz   d›dt          |¦  «        d›d�¦  «        }|                     d	d|dz   d›dt          |¦  «        d›d	�¦  «        }|||<   |                     ¦   «         D ]}|||<   ŒŒ…d
|i}||dœ}||fS )a¨  
    Splits a model state dictionary in sub-checkpoints so that the final size of each sub-checkpoint does not exceed a
    given size.

    The sub-checkpoints are determined by iterating through the `state_dict` in the order of its keys, so there is no
    optimization made to make each sub-checkpoint as close as possible to the maximum size passed. For example, if the
    limit is 10GB and we have weights of sizes [6GB, 6GB, 2GB, 6GB, 2GB, 2GB] they will get sharded as [6GB], [6+2GB],
    [6+2+2GB] and not [6+2+2GB], [6+2GB], [6GB].

    <Tip warning={true}>

    If one of the model's weight is bigger than `max_shard_size`, it will end up in its own sub-checkpoint which will
    have a size greater than `max_shard_size`.

    </Tip>

    Args:
        state_dict (`Dict[str, torch.Tensor]`): The state dictionary of a model to save.
        max_shard_size (`int` or `str`, *optional*, defaults to `"10GB"`):
            The maximum size of each sub-checkpoint. If expressed as a string, needs to be digits followed by a unit
            (like `"5MB"`).
        weights_name (`str`, *optional*, defaults to `"pytorch_model.bin"`):
            The name of the model save file.
    r   rs   r   Nú.binú-Ú05dz-of-ú.safetensorsÚ
total_size)ÚmetadataÚ
weight_map)rE   r�   Ú
isinstancer›   r    ÚnumelrÆ   r¥   ÚlenÚappendÚ	enumerateÚreplaceÚkeys)r¹   rÈ   rÉ   Úsharded_state_dictsÚlast_block_sizerÏ   Ústorage_id_to_blockÚkeyÚweightÚ
storage_idÚblock_idÚweight_sizerÑ   ÚshardsÚidxÚshardÚ
shard_filerÐ   Úindexs                      ro   Úshard_checkpointræ   &  sa  € õ6 .¨nÑ=Ô=€Nà˜$ÐØ€OØ€JØÐà!×'Ò'Ñ)Ô)ð Gð G‰ˆˆVõ �f�cÑ"Ô"ð 	3Øå*¨6Ñ2Ô2ˆJð Ð,Ð,Ð,Ø*¨:Ô6ˆHØ17Ð Ô)¨#Ñ.Øà—l’l‘n”n¥°v´|Ñ'DÔ'DÑDˆð ˜[Ñ(¨>Ò9Ð9½cÐBUÐVXÔBYÑ>ZÔ>ZÐ]^Ò>^Ð>^Ø×&Ò& rÑ*Ô*Ð*ØˆOà'-Ð˜BÔ Ñ$Ø˜;Ñ&ˆØ�kÑ!ˆ
Ý*-Ð.AÑ*BÔ*BÀQÑ*FÐ˜JÑ'Ð'õ ÐÑÔ 1Ò$Ð$ØÐ1°!Ô4Ð5°tÐ;Ð;ð €JØ€FÝÐ 3Ñ4Ô4ð )ð )‰
ˆˆUØ!×)Ò)¨&Ð2g°c¸!±eÐ2gÐ2gÐ2gÅSÐI\ÑE]ÔE]Ð2gÐ2gÐ2gÐ2gÑhÔhˆ
Ø×'Ò'ØÐ[  a¡Ð[Ð[Ð[µÐ5HÑ1IÔ1IÐ[Ð[Ð[Ð[ñ
ô 
ˆ
ð #ˆˆzÑØ—:’:‘<”<ð 	)ð 	)ˆCØ(ˆJ�s‰OˆOð	)ð ˜jÐ)€HØ!°Ð<Ð<€EØ�5ˆ=Ðrn   c                 ó¶  ‡‡— t           j                             |t          ¦  «        }t           j                             |t          ¦  «        }t           j                             |¦  «        }t           j                             |¦  «        }|s]|rt          ¦   «         sMt          ¦   «         rt          t          fnt          f}t          dd                     |¦  «        › d|› d�¦  «        ‚d}	|r6|r0t          ¦   «         rd}	n#t           	                    d|› d�¦  «         n|sd}	|	r|n|}
t          |
d	d
¬¦  «        5 }t          j        |¦  «        }ddd¦  «         n# 1 swxY w Y   t          t          |d                              ¦   «         ¦  «        ¦  «        }|d                              ¦   «         Š|                      ¦   «                              ¦   «         Šˆfd„‰D ¦   «         }ˆfd„‰D ¦   «         }|rºt%          |¦  «        dk    st%          |¦  «        dk    r”d| j        j        › �}t%          |¦  «        dk    r(d                     d„ |D ¦   «         ¦  «        }|d|› d�z  }t%          |¦  «        dk    r(d                     d„ |D ¦   «         ¦  «        }|d|› d�z  }t+          |¦  «        ‚|	rt,          nt/          t0          j        d¬¦  «        }|D ]V} |t           j                             ||¦  «        ¦  «        }|                      |d¬¦  «         ~t5          j        ¦   «          ŒWt0          j        j        j                             ||¦  «        S )aé  
    This is the same as
    [`torch.nn.Module.load_state_dict`](https://pytorch.org/docs/stable/generated/torch.nn.Module.html?highlight=load_state_dict#torch.nn.Module.load_state_dict)
    but for a sharded checkpoint.

    This load is performed efficiently: each checkpoint shard is loaded one by one in RAM and deleted after being
    loaded in the model.

    Args:
        model (`torch.nn.Module`): The model in which to load the checkpoint.
        folder (`str` or `os.PathLike`): A path to a folder containing the sharded checkpoint.
        strict (`bool`, *optional`, defaults to `True`):
            Whether to strictly enforce that the keys in the model state dict match the keys in the sharded checkpoint.
        prefer_safe (`bool`, *optional*, defaults to `False`)
            If both safetensors and PyTorch save files are present in checkpoint and `prefer_safe` is True, the
            safetensors files will be loaded. Otherwise, PyTorch files are always loaded when possible.

    Returns:
        `NamedTuple`: A named tuple with `missing_keys` and `unexpected_keys` fields
            - `missing_keys` is a list of str containing the missing keys
            - `unexpected_keys` is a list of str containing the unexpected keys
    zCan't find a checkpoint index (ú or z) in r¾   FTz"Cannot load sharded checkpoint at z+ safely since safetensors is not installed!Úrúutf-8©ÚencodingNrÑ   c                 ó   •— g | ]}|‰v¯|‘Œ	S rm   rm   )rˆ   rÜ   Úloaded_keyss     €ro   r‹   z+load_sharded_checkpoint.<locals>.<listcomp>³  s#   ø€ ÐHÐHÐH˜C°¸KÐ1GÐ1G�CÐ1GÐ1GÐ1Grn   c                 ó   •— g | ]}|‰v¯|‘Œ	S rm   rm   )rˆ   rÜ   Ú
model_keyss     €ro   r‹   z+load_sharded_checkpoint.<locals>.<listcomp>´  s#   ø€ ÐKÐKÐK˜s°SÀ
Ð5JÐ5J�sÐ5JÐ5JÐ5Jrn   r   ú#Error(s) in loading state_dict for ú,c                 ó   — g | ]}d |› d �‘Œ	S ©ú"rm   ©rˆ   r‰   s     ro   r‹   z+load_sharded_checkpoint.<locals>.<listcomp>¸  s    € Ð(HÐ(HÐ(H°a¨¨Q¨¨¨Ð(HÐ(HÐ(Hrn   z
Missing key(s): c                 ó   — g | ]}d |› d �‘Œ	S rô   rm   rö   s     ro   r‹   z+load_sharded_checkpoint.<locals>.<listcomp>»  s    € Ð+NÐ+NÐ+N¸¨H°¨H¨H¨HÐ+NÐ+NÐ+Nrn   Úcpu©Úmap_location)Ústrict) rj   ÚpathÚjoinr-   r)   Úisfiler@   r·   ÚloggerÚwarningÚopenÚjsonÚloadÚlistÚsetr¶   rØ   r¹   rÔ   Ú	__class__Ú__name__ÚRuntimeErrorÚsafe_load_filer   rf   Úload_state_dictÚgcÚcollectr   Úmodulesr�   Ú_IncompatibleKeys)ÚmodelÚfolderrû   Úprefer_safeÚ
index_fileÚsafe_index_fileÚindex_presentÚsafe_index_presentÚ	filenamesÚ	load_safeÚ
load_indexÚfrå   Úshard_filesÚmissing_keysÚunexpected_keysÚerror_messageÚstr_missing_keysÚstr_unexpected_keysÚloaderrä   r¹   rî   rð   s                         @@ro   Úload_sharded_checkpointr!  y  s¹  øø€ õ0 ”—’˜fÕ&8Ñ9Ô9€JÝ”g—l’l 6Õ+BÑCÔC€Oå”G—N’N :Ñ.Ô.€MÝœŸš¨Ñ8Ô8Ðàð cÐ"4ð cÕ9QÑ9SÔ9Sð cå=UÑ=WÔ=WÐrÕÕ!8Ð9Ð9Õ^pÐ]rð 	õ Ða¸6¿;º;ÀyÑ;QÔ;QÐaÐaÐX^ÐaÐaÐaÑbÔbÐbà€IØð 	Øð 	Ý'Ñ)Ô)ð Ø �	�	å—’Øl¸ÐlÐlÐlñô ð ð ð ð 	ØˆIà$-Ð=��°:€Jå	ˆj˜#¨Ð	0Ñ	0Ô	0ð °AÝ”	˜!‘”ˆðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð õ •s˜5 Ô.×5Ò5Ñ7Ô7Ñ8Ô8Ñ9Ô9€Kð ˜Ô%×*Ò*Ñ,Ô,€KØ×!Ò!Ñ#Ô#×(Ò(Ñ*Ô*€JØHÐHÐHÐH :ÐHÑHÔH€LØKÐKÐKÐK kÐKÑKÔK€OØð *•3�|Ñ$Ô$ qÒ(Ð(­C°Ñ,@Ô,@À1Ò,DÐ,DØX¸e¼oÔ>VÐXÐXˆÝˆ|ÑÔ˜qÒ Ð Ø"ŸxšxÐ(HÐ(H¸<Ð(HÑ(HÔ(HÑIÔIÐØÐEÐ2BÐEÐEÐEÑEˆMÝˆÑÔ !Ò#Ð#Ø"%§(¢(Ð+NÐ+N¸oÐ+NÑ+NÔ+NÑ"OÔ"OÐØÐHÐ2EÐHÐHÐHÑHˆMÝ˜=Ñ)Ô)Ð)à(ÐU�^ˆ^­gµe´jÈuÐ.UÑ.UÔ.U€Fà!ð ð ˆ
Ø�V�BœGŸLšL¨°Ñ<Ô<Ñ=Ô=ˆ
Ø×Ò˜j°ÐÑ7Ô7Ð7ð Ý
Œ
‰Œˆˆõ Œ8ÔÔ"×4Ò4°\À?ÑSÔSÐSs   Ä<EÅE!Å$E!Úcheckpoint_filec           	      ó\  — |                       d¦  «        r„t          ¦   «         rvt          | d¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   |                     d¦  «        dvrt          d| › d�¦  «        ‚t          | ¦  «        S 	 t          ¦   «         st          ¦   «         rCt          j
                             ¦   «         r%t          j
                             ¦   «         d	k    rd
}nd}t          j        | |¬¦  «        S # t          $ r�}	 t          | ¦  «        5 }|                     d¦  «        dk    rt          d¦  «        ‚t#          d| › d�¦  «        |‚# 1 swxY w Y   n+# t$          t"          f$ r t          d| › d| › d�¦  «        ‚w xY wY d}~dS d}~ww xY w)z]
    Reads a PyTorch checkpoint file, returning properly formatted errors if they arise.
    rÎ   Úpt©Ú	frameworkNÚformat)r$  ÚtfÚflaxz"The safetensors archive passed at zf does not contain the valid metadata. Make sure you save your model with the `save_pretrained` method.r   Úmetarø   rù   é   r   z¬You seem to have cloned a repository without having git-lfs installed. Please install git-lfs and run `git lfs install` followed by `git lfs pull` in the folder you cloned.zUnable to locate the file z_ which is necessary to load this pretrained model. Make sure you have saved the model properly.z9Unable to load weights from pytorch checkpoint file for 'z' at 'zZ'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.)Úendswithr@   r_   rÐ   rl   ÚOSErrorr	  r   rp   rf   rg   ri   Úget_rankr  Ú	Exceptionr  Úreadr·   ÚUnicodeDecodeError)r"  r  rÐ   rú   Úes        ro   r
  r
  Í  s£  € ð ×Ò Ñ/Ô/ð 	/Õ4LÑ4NÔ4Nð 	/å�°$Ð7Ñ7Ô7ð 	$¸1Ø—z’z‘|”|ˆHð	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$à�<Š<˜Ñ!Ô!Ð)=Ð=Ð=ÝðI°_ð Ið Ið Iñô ð õ ˜oÑ.Ô.Ð.ðå'Ñ)Ô)ð	!Ý-<Ñ->Ô->ð	!åÔ!×0Ò0Ñ2Ô2ð	!õ Ô!×*Ò*Ñ,Ô,¨qÒ0Ð0à!ˆLˆLà ˆLÝŒz˜/¸ÐEÑEÔEÐEøÝð ð ð ð	Ý�oÑ&Ô&ð ¨!Ø—6’6˜!‘9”9 	Ò)Ð)Ý!ð&ñô ð õ %ðN°_ð Nð Nð Nñô ð ððð ð ð øøøð ð ð ð ð øõ #¥JÐ/ð 	ð 	ð 	ÝðjÈOð jð jØ&ðjð jð jñô ð ð	øøøðð ð ð ð ð øøøøðøøøsZ   µAÁAÁAÂA6D Ä
F+ÄE5Ä,=E)Å)E-	Å-E5Å0E-	Å1E5Å4F&Å5(FÆF&Æ&F+c                 ó  ‡— |                       ¦   «         D ]n\  Š}ˆfd„|D ¦   «         }t          t          |                     ¦   «                              ¦   «         ¦  «        t          |¦  «        z
  ¦  «        dk    rd|_        ŒodS )z†
    Sets the `_is_hf_initialized` flag in all submodules of a given model when all its weights are in the loaded state
    dict.
    c                 ór   •— g | ]3}|                      ‰› d �¦  «        ¯|                     ‰› d �d¦  «        ‘Œ4S ©r¾   Ú )Ú
startswithr×   )rˆ   r‰   Úmodule_names     €ro   r‹   z.set_initialized_submodules.<locals>.<listcomp>  sN   ø€ ÐtÐtÐt¸AÐTU×T`ÒT`ÐdoÐarÐarÐarÑTsÔTsÐt�q—y’y KÐ!2Ð!2Ð!2°BÑ7Ô7ÐtÐtÐtrn   r   TN)Únamed_modulesrÔ   r  r¹   rØ   Ú_is_hf_initialized)r  Ústate_dict_keysr�   rî   r8  s       @ro   Úset_initialized_submodulesr<  û  s‘   ø€ ð
  %×2Ò2Ñ4Ô4ð -ð -Ñˆ�VØtÐtÐtÐtÀÐtÑtÔtˆÝ�s�6×$Ò$Ñ&Ô&×+Ò+Ñ-Ô-Ñ.Ô.µ°[Ñ1AÔ1AÑAÑBÔBÀaÒGÐGØ(,ˆFÔ%øð-ð -rn   c                 ó
  ‡‡	‡
— g }g }|                      ¦   «         D ]d}d }d|v r|                     dd¦  «        }d|v r|                     dd¦  «        }|r*|                     |¦  «         |                     |¦  «         Œet          ||¦  «        D ]\  }}|                     |¦  «        ||<   Œt          |dd ¦  «        Š
|                     ¦   «         }‰
�‰
|_        g Šd
dt          j	        fˆˆ	ˆ
fd„Š	 ‰	| ||¬	¦  «         ~‰S )NÚgammarÝ   ÚbetaÚbiasÚ	_metadatar6  r�   c                 óÀ  •‡‡	— ‰€i n‰                      ‰d d…         i ¦  «        }|‰|dg g ‰
f}t          ˆfd„|D ¦   «         ¦  «        dk    rÜt          ¦   «         rÄdd l}t	          |                      ‰d d…         d¬¦  «        ¦  «        Š	ˆ	fd„|                     ¦   «         D ¦   «         }t          |¦  «        dk    r`|j                             |d¬¦  «        5  t          j
                             ¦   «         dk    r
 | j        |Ž  d d d ¦  «         n# 1 swxY w Y   n
 | j        |Ž  | j                             ¦   «         D ]\  }}|� ‰||‰|z   d	z   ¦  «         Œd S )
Nrs   Tc                 ó>   •— g | ]}|                      ‰¦  «        ¯|‘ŒS rm   ©r7  ©rˆ   rÜ   Úprefixs     €ro   r‹   z=_load_state_dict_into_model.<locals>.load.<locals>.<listcomp>%  s*   ø€ ÐDÐDÐD˜¨S¯^ª^¸FÑ-CÔ-CÐD�ÐDÐDÐDrn   r   F)rF  Úrecursec                 ó(   •— g | ]}|‰v ¯‰|         ‘ŒS rm   rm   )rˆ   r‰   Únamed_parameterss     €ro   r‹   z=_load_state_dict_into_model.<locals>.load.<locals>.<listcomp>,  s+   ø€ Ð#lÐ#lÐ#l¸AÐVWÐ[kÐVkÐVkÐ$4°QÔ$7ÐVkÐVkÐVkrn   ©Úmodifier_rankr¾   )rl   rÔ   r   Ú	deepspeedÚdictrI  rØ   ÚzeroÚGatheredParametersrf   rg   r.  Ú_load_from_state_dictÚ_modulesr�   )r�   r¹   rF  Úlocal_metadataÚargsrL  Úparams_to_gatherÚnameÚchildrI  Ú
error_msgsr  rÐ   s     `      @€€€ro   r  z)_load_state_dict_into_model.<locals>.load   sö  øøø€ Ø'Ð/˜˜°X·\²\À&ÈÈ"ÈÄ+ÈrÑ5RÔ5RˆØ˜F N°D¸"¸bÀ*ÐMˆõ ÐDÐDÐDÐD˜zÐDÑDÔDÑEÔEÈÒIÐIÝ)Ñ+Ô+ð 4Ø Ð Ð Ð õ $(¨×(?Ò(?ÀvÈcÈrÈcÄ{Ð\aÐ(?Ñ(bÔ(bÑ#cÔ#cÐ Ø#lÐ#lÐ#lÐ#lÀÇÂÑARÔARÐ#lÑ#lÔ#lÐ ÝÐ'Ñ(Ô(¨1Ò,Ð,ð #œ×:Ò:Ð;KÐ[\Ð:Ñ]Ô]ð @ð @Ý Ô,×5Ò5Ñ7Ô7¸1Ò<Ð<Ø8˜FÔ8¸$Ð?Ð?ð@ð @ð @ñ @ô @ð @ð @ð @ð @ð @ð @øøøð @ð @ð @ð @øð -�Ô,¨dÐ3Ð3à!œ?×0Ò0Ñ2Ô2ð 	=ð 	=‰KˆD�%ØÐ Ø��U˜J¨°©¸Ñ(;Ñ<Ô<Ð<øð	=ð 	=s   Ã-DÄDÄD)rF  ©r6  )
rØ   r×   rÕ   ÚzipÚpopÚgetattrÚcopyrA  r   rš   )Úmodel_to_loadr¹   Ústart_prefixÚold_keysÚnew_keysrÜ   Únew_keyÚold_keyrW  r  rÐ   s           @@@ro   Ú_load_state_dict_into_modelrc    sX  øøø€ à€HØ€HØ�ŠÑ Ô ð %ð %ˆØˆØ�cˆ>ˆ>Ø—k’k '¨8Ñ4Ô4ˆGØ�Sˆ=ˆ=Ø—k’k &¨&Ñ1Ô1ˆGØð 	%Ø�OŠO˜CÑ Ô Ð Ø�OŠO˜GÑ$Ô$Ð$øÝ ¨(Ñ3Ô3ð 6ð 6Ñˆ�Ø(Ÿnšn¨WÑ5Ô5ˆ
�7ÑÐõ �z ;°Ñ5Ô5€HØ—’Ñ"Ô"€JØÐØ'ˆ
Ôà€Jð=ð =•R”Yð =ð =ð =ð =ð =ð =ð =ð =ð6 	€Dˆ˜
¨<Ð8Ñ8Ô8Ð8ð 	àÐrn   c                 ó¶  — t          |¦  «        dk    rE|                     |¦  «        r0d                     |                     d¦  «        dd…         ¦  «        }|                     d¦  «        }| }t          |¦  «        dk    rFt	          ||d         ¦  «        rt          ||d         ¦  «        }|d= nd}nt          |¦  «        dk    °F|| k    rd}||d         fS )z›
    A helper util to find the last sub-module and the param/buffer name. If `start_prefix` is supplied it'll be removed
    from the start of the key
    r   r¾   r   N)rÔ   r7  rý   ÚsplitÚhasattrr[  )r  Úlong_keyr^  Ú	split_keyÚ	submodules        ro   Úfind_submodule_and_param_namerj  C  så   € õ ˆ<ÑÔ˜1ÒÐ ×!4Ò!4°\Ñ!BÔ!BÐØ—8’8˜HŸNšN¨3Ñ/Ô/°°°Ô3Ñ4Ô4ˆà—’˜sÑ#Ô#€IØ€IÝ
ˆi‰.Œ.˜1Ò
Ð
Ý�9˜i¨œlÑ+Ô+ð 	Ý 	¨9°Q¬<Ñ8Ô8ˆIØ˜!��àˆIØõ ˆi‰.Œ.˜1Ò
Ð
ð �EÒÐØˆ	Ø�i ”lÐ"Ð"rn   c                 óL  — |D ] }t          | ||¦  «        \  }}|�ˆt          ||¦  «        }t          |t          j        j        ¦  «        r3t          j                             |                     d¦  «        ¦  «        }n|                     d¦  «        }t          |||¦  «         Œ¡dS )zð
    Moves `loaded_state_dict_keys` in model to meta device which frees up the memory taken by those params.

    `start_prefix` is used for models which insert their name into model keys, e.g. `bert` in
    `bert.pooler.dense.weight`

    Nr*  )rj  r[  rÒ   rf   r   Ú	ParameterÚtoÚsetattr)r  Úloaded_state_dict_keysr^  r‰   ri  Ú
param_nameÚnew_vals          ro   Ú_move_model_to_metarr  Z  s¨   € ð $ð 4ð 4ˆÝ =¸eÀQÈÑ UÔ UÑˆ	�:ØÐ õ ˜i¨Ñ4Ô4ˆGÝ˜'¥5¤8Ô#5Ñ6Ô6ð -åœ(×,Ò,¨W¯ZªZ¸Ñ-?Ô-?Ñ@Ô@��à!Ÿ*š* VÑ,Ô,�Ý�I˜z¨7Ñ3Ô3Ð3øð4ð 4rn   c                 ó¸  ‡— |rddl m} g }g }g }|                     ¦   «         D ]d}d}d|v r|                     dd¦  «        }d|v r|                     dd¦  «        }|r*|                     |¦  «         |                     |¦  «         Œet          ||¦  «        D ]\  }}|                     |¦  «        ||<   Œ|                     ¦   «         D �]Š\  Š}‰|vs‰|vrŒ‰                     |¦  «        r‰t          |¦  «        d…         Š‰}i }|
�²t          j        |¦  «        rž|�‡t          ˆfd„|D ¦   «         ¦  «        rl|
t          j        k    r\|                     t          j        ¦  «        }d	t!          t#          j        t&          ¦  «        j        ¦  «        v rt          j        |d	<   n|                     |
¦  «        }|
€L| }‰                     d
¦  «        }|D ]}t-          ||¦  «        }|€ nŒ|�|                     |j        ¦  «        }||d<   |€d}n‚t          |¦  «        dk    rK||vrGd
                     |                     d
¦  «        dd…         ¦  «        }t          |¦  «        dk    r||v°G|dk    rd|vrt3          ‰› d�¦  «        ‚||         }|dk    r|st5          |‰||¦  «        }�Œé|dk    r|	�t5          |‰||	¦  «        }	�Œ|st'          | ‰|fi |¤Ž �Œ|j        t          j        k    rG‰                     dd¦  «        |                     ¦   «         v r|‰                     dd¦  «                 }nd}d‰vr || ‰|||¬¦  «         �ŒŒ|||	fS )aµ  
    This is somewhat similar to `_load_state_dict_into_model`, but deals with a model that has some or all of its
    params on a `meta` device. It replaces the model params with the data from the `state_dict`, while moving the
    params back to the normal device, but only for `loaded_state_dict_keys`.

    `start_prefix` is used for models which insert their name into model keys, e.g. `bert` in
    `bert.pooler.dense.weight`

    r   ©Ú%set_module_quantized_tensor_to_deviceNr>  rÝ   r?  r@  c              3   óF   •K  — | ]}|‰                      d ¦  «        v V — ŒdS ©r¾   N©re  )rˆ   Úmodule_to_keep_in_fp32rp  s     €ro   ú	<genexpr>z3_load_state_dict_into_meta_model.<locals>.<genexpr>¸  sH   øè è € ð ð ØH^Ð*¨j×.>Ò.>¸sÑ.CÔ.CÐCðð ð ð ð ð rn   r¥   r¾   Úvaluerø   r   rs   r6  z doesn't have any device set.ÚdiskÚSCB)r{  Úfp16_statistics)Úintegrationsru  rØ   r×   rÕ   rY  rZ  r�   r7  rÔ   rf   rª   ÚanyÚfloat16rm  r®   r  ÚinspectÚ	signaturer^   r—   re  r[  r¥   rý   r·   r\   Úint8)r  r¹   ro  r^  Úexpected_keysÚ
device_mapÚoffload_folderÚoffload_indexÚstate_dict_folderÚstate_dict_indexr¥   Úis_quantizedÚis_safetensorsÚkeep_in_fp32_modulesru  rW  r_  r`  rÜ   ra  rb  Úparamr8  Úset_module_kwargsÚ	old_paramÚsplitsre  Úparam_devicer~  rp  s                                @ro   Ú _load_state_dict_into_meta_modelr“  t  sE  ø€ ðB ð HØGÐGÐGÐGÐGÐGà€Jà€HØ€HØ�ŠÑ Ô ð %ð %ˆØˆØ�cˆ>ˆ>Ø—k’k '¨8Ñ4Ô4ˆGØ�Sˆ=ˆ=Ø—k’k &¨&Ñ1Ô1ˆGØð 	%Ø�OŠO˜CÑ Ô Ð Ø�OŠO˜GÑ$Ô$Ð$øÝ ¨(Ñ3Ô3ð 6ð 6Ñˆ�Ø(Ÿnšn¨WÑ5Ô5ˆ
�7ÑÐà'×-Ò-Ñ/Ô/ð Iñ IÑˆ
�EàÐ3Ð3Ð3°zÈÐ7VÐ7VØà× Ò  Ñ.Ô.ð 	9Ø#¥C¨Ñ$5Ô$5Ð$7Ð$7Ô8ˆJà ˆØÐð Ð¥Ô!8¸Ñ!?Ô!?Ðà$Ð0Ýð ð ð ð Øbvðñ ô ñ ô ð 1ð �Uœ]Ò*Ð*àŸš¥¤Ñ/Ô/�ð �d¥7Ô#4Õ5PÑ#QÔ#QÔ#\Ñ]Ô]Ð]Ð]Ý16´Ð% gÑ.øàŸš ™œ�ð ˆ=ØˆIØ×%Ò% cÑ*Ô*ˆFØð ð �Ý# I¨uÑ5Ô5�	ØÐ$Ø�Eð %ð Ð$ØŸš ¤Ñ1Ô1�à%*Ð˜'Ñ"àÐØ ˆLˆLõ �kÑ"Ô" QÒ&Ð&¨;¸jÐ+HÐ+HØ!Ÿhšh {×'8Ò'8¸Ñ'=Ô'=¸c¸r¸cÔ'BÑCÔC�õ �kÑ"Ô" QÒ&Ð&¨;¸jÐ+HÐ+Hà˜bÒ Ð  R¨zÐ%9Ð%9å  JÐ!MÐ!MÐ!MÑNÔNÐNØ% kÔ2ˆLà˜6Ò!Ð!Ø!ð aÝ .¨u°jÀ.ÐR_Ñ `Ô `�ùØ˜UÒ"Ð"Ð'7Ð'CÝ-¨e°ZÐARÐTdÑeÔeÐÑØð 	å'¨¨z¸<Ð]Ð]ÐK\Ð]Ð]Ð]Ñ]àŒ{�eœjÒ(Ð(¨Z×-?Ò-?ÀÈ%Ñ-PÔ-PÐT^×TcÒTcÑTeÔTeÐ-eÐ-eØ",¨Z×-?Ò-?ÀÈ%Ñ-PÔ-PÔ"Q��à"&�à˜JÐ&Ð&Ø5Ð5Ø˜: |¸5ÐRaðñ ô ð ùð �}Ð&6Ð6Ð6rn   Úvariantr‚   c                 ó�   — |�C|                       d¦  «        }|d d…         |gz   |dd …         z   }d                     |¦  «        } | S )Nr¾   rs   )re  rý   )rÉ   r”  r‘  s      ro   Ú_add_variantr–  ö  sS   € ØÐØ×#Ò# CÑ(Ô(ˆØ˜˜˜” ˜yÑ(¨6°"°#°#¬;Ñ6ˆØ—x’x Ñ'Ô'ˆàÐrn   c                   ó¾  — e Zd ZdZed„ ¦   «         Zed„ ¦   «         Zd„ Zd„ Ze	de
j        fd„¦   «         Ze	de
j        fd„¦   «         Zd	edefd
„Zedd„¦   «         Z	 d dedee         de
j        de
j        def
d„Z	 d!dee         dededefd„Zd„ Zd"dededefd„Zdeeee
j        ef         f         defd„Z	 d#deeee
j        ef         f         dedefd„ZdS )$r   zH
    A few utilities for `torch.nn.Modules`, to be used as a mixin.
    c                 óØ   — 	 dd l }n# t          $ r t          d¦  «        ‚w xY w|                     t          j        ¦   «         ¦  «        }|                     ¦   «         }|j        | _        d S )Nr   úFYou need to install psutil (pip install psutil) to use memory tracing.)ÚpsutilÚImportErrorÚProcessrj   ÚgetpidÚmemory_infoÚrssÚmem_rss_pre_forward)r�   rS  Úkwargsrš  ÚprocessÚmems         ro   Ú_hook_rss_memory_pre_forwardz-ModuleUtilsMixin._hook_rss_memory_pre_forward  sz   € ð	hØˆMˆMˆMˆMøÝð 	hð 	hð 	hÝÐfÑgÔgÐgð	høøøð —.’.¥¤¡¤Ñ-Ô-ˆØ×!Ò!Ñ#Ô#ˆØ%(¤WˆÔ"Øˆtó   ‚ ‡!c                 ó8  — 	 dd l }n# t          $ r t          d¦  «        ‚w xY w|                     t          j        ¦   «         ¦  «        }|                     ¦   «         }|j        | _        | j        | j        z
  }|t          | d¦  «        r| j
        ndz   | _
        d S )Nr   r™  Úmem_rss_diff)rš  r›  rœ  rj   r�  rž  rŸ  Úmem_rss_post_forwardr   rf  r§  )r�   rS  r¡  rš  r¢  r£  r§  s          ro   Ú_hook_rss_memory_post_forwardz.ModuleUtilsMixin._hook_rss_memory_post_forward  s°   € ð	hØˆMˆMˆMˆMøÝð 	hð 	hð 	hÝÐfÑgÔgÐgð	høøøð —.’.¥¤¡¤Ñ-Ô-ˆØ×!Ò!Ñ#Ô#ˆØ&)¤gˆÔ#ØÔ2°VÔ5OÑOˆØ*ÅWÈVÐUcÑEdÔEdÐ.k¨fÔ.AÐ.AÐjkÑlˆÔØˆtr¥  c                 óÄ   — |                       ¦   «         D ]6}|                     | j        ¦  «         |                     | j        ¦  «         Œ7|                      ¦   «          dS )a%  
        Add a memory hook before and after each sub-module forward pass to record increase in memory consumption.

        Increase in memory consumption is stored in a `mem_rss_diff` attribute for each module and can be reset to zero
        with `model.reset_memory_hooks_state()`.
        N)r  Úregister_forward_pre_hookr¤  Úregister_forward_hookr©  Úreset_memory_hooks_state©Úselfr�   s     ro   Úadd_memory_hooksz!ModuleUtilsMixin.add_memory_hooks  sf   € ð —l’l‘n”nð 	Mð 	MˆFØ×,Ò,¨TÔ-NÑOÔOÐOØ×(Ò(¨Ô)KÑLÔLÐLÐLØ×%Ò%Ñ'Ô'Ð'Ð'Ð'rn   c                 ó^   — |                       ¦   «         D ]}d|_        d|_        d|_        ŒdS )z€
        Reset the `mem_rss_diff` attribute of each module (see [`~modeling_utils.ModuleUtilsMixin.add_memory_hooks`]).
        r   N)r  r§  r¨  r   r®  s     ro   r­  z)ModuleUtilsMixin.reset_memory_hooks_state*  s@   € ð —l’l‘n”nð 	+ð 	+ˆFØ"#ˆFÔØ*+ˆFÔ'Ø)*ˆFÔ&Ð&ð	+ð 	+rn   r‚   c                 ó    — t          | ¦  «        S )z�
        `torch.device`: The device on which the module is (assuming that all the module parameters are on the same
        device).
        )r    ©r¯  s    ro   r˜   zModuleUtilsMixin.device3  s   € õ $ DÑ)Ô)Ð)rn   c                 ó    — t          | ¦  «        S )zw
        `torch.dtype`: The dtype of the module (assuming that all the module parameters have the same dtype).
        )r´   r³  s    ro   r¥   zModuleUtilsMixin.dtype;  s   € õ
 # 4Ñ(Ô(Ð(rn   Úencoder_attention_maskc                 ó(  — |                      ¦   «         dk    r|dd…ddd…dd…f         }|                      ¦   «         dk    r|dd…dddd…f         }|                     | j        ¬¦  «        }d|z
  t          j        | j        ¦  «        j        z  }|S )zè
        Invert an attention mask (e.g., switches 0. and 1.).

        Args:
            encoder_attention_mask (`torch.Tensor`): An attention mask.

        Returns:
            `torch.Tensor`: The inverted attention mask.
        é   Né   ©r¥   ç      ð?)Údimrm  r¥   rf   ÚfinfoÚmin)r¯  rµ  Úencoder_extended_attention_masks      ro   Úinvert_attention_maskz&ModuleUtilsMixin.invert_attention_maskB  s»   € ð "×%Ò%Ñ'Ô'¨1Ò,Ð,Ø.DÀQÀQÀQÈÈaÈaÈaÐQRÐQRÐQRÀ]Ô.SÐ+Ø!×%Ò%Ñ'Ô'¨1Ò,Ð,Ø.DÀQÀQÀQÈÈdÐTUÐTUÐTUÐEUÔ.VÐ+ð +J×*LÒ*LÐSWÔS]Ð*LÑ*^Ô*^Ð'Ø+.Ð1PÑ+PÕTYÔT_Ð`dÔ`jÑTkÔTkÔToÑ*oÐ'à.Ð.rn   Nc                 ó8  — |�t          j        dt          ¦  «         n|j        }| \  }}t	          j        ||¬¦  «        }|d d d d …f                              ||d¦  «        |d d d …d f         k    }|                     |j        ¦  «        }|j	        d         |j	        d         k     rP|j	        d         |j	        d         z
  }t	          j
        t	          j        |||f||j        ¬¦  «        |gd¬¦  «        }|d d …d d d …d d …f         |d d …d d d d …f         z  }|S )NúNThe `device` argument is deprecated and will be removed in v5 of Transformers.)r˜   r   ©r˜   r¥   rs   )Úaxis)ÚwarningsÚwarnÚFutureWarningr˜   rf   ÚarangeÚrepeatrm  r¥   ÚshapeÚcatÚones)	Úinput_shapeÚattention_maskr˜   Ú
batch_sizeÚ
seq_lengthÚseq_idsÚcausal_maskÚprefix_seq_lenÚextended_attention_masks	            ro   Ú*create_extended_attention_mask_for_decoderz;ModuleUtilsMixin.create_extended_attention_mask_for_decoderZ  se  € àÐÝŒMØ`Õboñô ð ð ð $Ô*ˆFØ!,Ñˆ
�JÝ”,˜z°&Ð9Ñ9Ô9ˆØ˜d D¨!¨!¨!˜mÔ,×3Ò3°JÀ
ÈAÑNÔNÐRYÐZ^Ð`aÐ`aÐ`aÐcgÐZgÔRhÒhˆð "—n’n ^Ô%9Ñ:Ô:ˆàÔ˜QÔ .Ô"6°qÔ"9Ò9Ð9Ø+Ô1°!Ô4°{Ô7HÈÔ7KÑKˆNÝœ)å”J 
¨J¸ÐGÐPVÐ^iÔ^oÐpÑpÔpØðð ðñ ô ˆKð #.¨a¨a¨a°°q°q°q¸!¸!¸!¨mÔ"<¸~ÈaÈaÈaÐQUÐW[Ð]^Ð]^Ð]^ÐN^Ô?_Ñ"_ÐØ&Ð&rn   rÍ  rÌ  r˜   r¥   c                 ó2  — |€| j         }|                     ¦   «         dk    r| j        j        s|�t	          j        dt          ¦  «         |                     ¦   «         dk    r|dd…ddd…dd…f         }nm|                     ¦   «         dk    r:| j        j        rt                               |||¦  «        }n,|dd…dddd…f         }nt          d|› d|j
        › d�¦  «        ‚|                     |¬¦  «        }d	|z
  t          j        |¦  «        j        z  }|S )
aâ  
        Makes broadcastable attention and causal masks so that future and masked tokens are ignored.

        Arguments:
            attention_mask (`torch.Tensor`):
                Mask with ones indicating tokens to attend to, zeros for tokens to ignore.
            input_shape (`Tuple[int]`):
                The shape of the input to the model.

        Returns:
            `torch.Tensor` The extended attention mask, with a the same dtype as `attention_mask.dtype`.
        Nr¸  rÁ  r·  z!Wrong shape for input_ids (shape z) or attention_mask (shape ú)r¹  rº  )r¥   r»  ÚconfigÚ
is_decoderrÄ  rÅ  rÆ  r   rÔ  r·   rÉ  rm  rf   r¼  r½  )r¯  rÍ  rÌ  r˜   r¥   rÓ  s         ro   Úget_extended_attention_maskz,ModuleUtilsMixin.get_extended_attention_maskv  s^  € ð ˆ=Ø”JˆEà×"Ò"Ñ$Ô$¨Ò)Ð)¨d¬kÔ.DÐ)àÐ!Ý”ØdÕfsñô ð ð
 ×ÒÑÔ 1Ò$Ð$Ø&4°Q°Q°Q¸¸a¸a¸aÀÀÀ°]Ô&CÐ#Ð#Ø×ÒÑ!Ô! QÒ&Ð&ð Œ{Ô%ð KÝ*:×*eÒ*eØ °ñ+ô +Ð'Ð'ð +9¸¸¸¸DÀ$ÈÈÈÐ9IÔ*JÐ'Ð'åØs°KÐsÐsÐ\jÔ\pÐsÐsÐsñô ð ð #:×"<Ò"<À5Ð"<Ñ"IÔ"IÐØ#&Ð)@Ñ#@ÅEÄKÐPUÑDVÔDVÔDZÑ"ZÐØ&Ð&rn   FÚ	head_maskÚnum_hidden_layersÚis_attention_chunkedc                 óv   — |�0|                       ||¦  «        }|du r|                     d¦  «        }ndg|z  }|S )aÊ  
        Prepare the head mask if needed.

        Args:
            head_mask (`torch.Tensor` with shape `[num_heads]` or `[num_hidden_layers x num_heads]`, *optional*):
                The mask indicating if we should keep the heads or not (1.0 for keep, 0.0 for discard).
            num_hidden_layers (`int`):
                The number of hidden layers in the model.
            is_attention_chunked (`bool`, *optional*, defaults to `False`):
                Whether or not the attentions scores are computed by chunks or not.

        Returns:
            `torch.Tensor` with shape `[num_hidden_layers x batch x num_heads x seq_length x seq_length]` or list with
            `[None]` for each layer.
        NTrs   )Ú_convert_head_mask_to_5dÚ	unsqueeze)r¯  rÚ  rÛ  rÜ  s       ro   Úget_head_maskzModuleUtilsMixin.get_head_maskª  sR   € ð$ Ð Ø×5Ò5°iÐARÑSÔSˆIØ# tÐ+Ð+Ø%×/Ò/°Ñ3Ô3�	øà˜Ð!2Ñ2ˆIàÐrn   c                 óP  — |                      ¦   «         dk    rh|                     d¦  «                             d¦  «                             d¦  «                             d¦  «        }|                     |dddd¦  «        }nS|                      ¦   «         dk    r;|                     d¦  «                             d¦  «                             d¦  «        }|                      ¦   «         dk    sJ d|                      ¦   «         › �¦   «         ‚|                     | j        ¬¦  «        }|S )zD-> [num_hidden_layers x batch x num_heads x seq_length x seq_length]r   r   rs   r¸  é   zhead_mask.dim != 5, instead r¹  )r»  rß  Úexpandrm  r¥   )r¯  rÚ  rÛ  s      ro   rÞ  z)ModuleUtilsMixin._convert_head_mask_to_5dÅ  s   € à�=Š=‰?Œ?˜aÒÐØ!×+Ò+¨AÑ.Ô.×8Ò8¸Ñ;Ô;×EÒEÀbÑIÔI×SÒSÐTVÑWÔWˆIØ!×(Ò(Ð):¸BÀÀBÈÑKÔKˆIˆIØ�]Š]‰_Œ_ Ò!Ð!Ø!×+Ò+¨AÑ.Ô.×8Ò8¸Ñ<Ô<×FÒFÀrÑJÔJˆIØ�}Š}‰Œ !Ò#Ð#Ð#Ð%UÀIÇMÂMÁOÄOÐ%UÐ%UÑ#Ô#Ð#Ø—L’L t¤z�LÑ2Ô2ˆ	ØÐrn   Úonly_trainableÚexclude_embeddingsc                 óL  ‡— |r?d„ |                       ¦   «         D ¦   «         Šˆfd„|                      ¦   «         D ¦   «         }n!t          |                      ¦   «         ¦  «        }g }t	          | dd¦  «        }|r"t          ¦   «         rddl}nt          d¦  «        ‚|D ]y}|j        s|sn|rEt          ||j
        j        ¦  «        r+|                     |                     ¦   «         dz  ¦  «         ŒR|                     |                     ¦   «         ¦  «         Œzt          |¦  «        S )	aé  
        Get number of (optionally, trainable or non-embeddings) parameters in the module.

        Args:
            only_trainable (`bool`, *optional*, defaults to `False`):
                Whether or not to return only the number of trainable parameters

            exclude_embeddings (`bool`, *optional*, defaults to `False`):
                Whether or not to return only the number of non-embeddings parameters

        Returns:
            `int`: The number of parameters.
        c                 óR   — g | ]$\  }}t          |t          j        ¦  «        ¯|› d �‘Œ%S )z.weight)rÒ   r   Ú	Embedding)rˆ   rU  Úmodule_types      ro   r‹   z3ModuleUtilsMixin.num_parameters.<locals>.<listcomp>à  sJ   € ð %ð %ð %Ù%6 T¨;ÕR\Ð]hÕjlÔjvÑRwÔRwð%ØÐ Ð Ð ð%ð %ð %rn   c                 ó"   •— g | ]\  }}|‰v¯	|‘ŒS rm   rm   )rˆ   rU  r~   Úembedding_param_namess      €ro   r‹   z3ModuleUtilsMixin.num_parameters.<locals>.<listcomp>ã  s/   ø€ ð  ð  ð  Ù-˜d IÈDÐXmÐLmÐLm�	ÐLmÐLmÐLmrn   Úis_loaded_in_4bitFr   Nz´bitsandbytes is not installed but it seems that the model has been loaded in 4bit precision, something went wrong make sure to install bitsandbytes with `pip install bitsandbytes`.r¸  )r9  rI  r  r—   r[  r:   Úbitsandbytesr·   Úrequires_gradrÒ   r   Ú
Params4bitrÕ   rÓ   Úsum)	r¯  rä  rå  Útotal_parametersÚtotal_numelrì  ÚbnbrŽ  rë  s	           @ro   Únum_parameterszModuleUtilsMixin.num_parametersÐ  sq  ø€ ð ð 	7ð%ð %Ø:>×:LÒ:LÑ:NÔ:Nð%ñ %ô %Ð!ð ð  ð  ð  Ø15×1FÒ1FÑ1HÔ1Hð ñ  ô  ÐÐõ  $ D§O¢OÑ$5Ô$5Ñ6Ô6ÐàˆÝ# DÐ*=¸uÑEÔEÐØð 	Ý(Ñ*Ô*ð Ø*Ð*Ð*Ð*Ð*å ðZñô ð ð
 &ð 	6ð 	6ˆEØÔ"ð 6¨.ð 6ð %ð 6­°E¸3¼6Ô;LÑ)MÔ)Mð 6Ø×&Ò& u§{¢{¡}¤}°qÑ'8Ñ9Ô9Ð9Ð9à×&Ò& u§{¢{¡}¤}Ñ5Ô5Ð5øå�;ÑÔÐrn   Ú
input_dictc                 óÞ   — t          | d¦  «        si | _        | j        |v r|| j                                      ¦   «         S d| j        vr$t                               d¦  «         d| j        d<   dS )zÞ
        Helper function to estimate the total number of tokens from the model inputs.

        Args:
            inputs (`dict`): The model inputs.

        Returns:
            `int`: The total number of tokens.
        Úwarnings_issuedÚestimate_tokenszdCould not estimate the number of tokens of the input, floating-point operations will not be computedTr   )rf  r÷  Úmain_input_namerÓ   rÿ   r   )r¯  rõ  s     ro   rø  z ModuleUtilsMixin.estimate_tokensÿ  sƒ   € õ �tÐ.Ñ/Ô/ð 	&Ø#%ˆDÔ ØÔ :Ð-Ð-Ø˜dÔ2Ô3×9Ò9Ñ;Ô;Ð;Ø dÔ&:Ð:Ð:Ý�NŠNØvñô ð ð 7;ˆDÔ Ð!2Ñ3Øˆqrn   Tc                 ó`   — d|                       |¦  «        z  |                      |¬¦  «        z  S )aÞ  
        Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a
        batch with this transformer model. Default approximation neglects the quadratic dependency on the number of
        tokens (valid if `12 * d_model << sequence_length`) as laid out in [this
        paper](https://arxiv.org/pdf/2001.08361.pdf) section 2.1. Should be overridden for transformers with parameter
        re-use e.g. Albert or Universal Transformers, or if doing long-range modeling with very high sequence lengths.

        Args:
            batch_size (`int`):
                The batch size for the forward pass.

            sequence_length (`int`):
                The number of tokens in each line of the batch.

            exclude_embeddings (`bool`, *optional*, defaults to `True`):
                Whether or not to count embedding and softmax operations.

        Returns:
            `int`: The number of floating-point operations.
        é   )rå  )rø  rô  )r¯  rõ  rå  s      ro   Úfloating_point_opsz#ModuleUtilsMixin.floating_point_ops  s4   € ð0 �4×'Ò'¨
Ñ3Ô3Ñ3°d×6IÒ6IÐ]oÐ6IÑ6pÔ6pÑpÐprn   ©N©NN)F©FF©T)r  Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr¤  r©  r°  r­  Úpropertyrf   r˜   r¥   r   r¿  rÔ  r   rt   r¬   rÙ  r   rÀ   rà  rÞ  rô  r	   r›   r   r   rø  rü  rm   rn   ro   r   r   ÿ  sm  € € € € € ðð ð ð	ð 	ñ „\ð	ð ðð ñ „\ðð
(ð 
(ð 
(ð+ð +ð +ð ð*˜œð *ð *ð *ñ „Xð*ð ð)�u”{ð )ð )ð )ñ „Xð)ð/¸Fð /Àvð /ð /ð /ð /ð0 ð'ð 'ð 'ñ „\ð'ð8 rvð2'ð 2'Ø$ð2'Ø38¸´:ð2'ØGLÄ|ð2'ØchÔcnð2'à	ð2'ð 2'ð 2'ð 2'ðj afðð Ø! &Ô)ðØ>AðØY]ðà	ðð ð ð ð6	ð 	ð 	ð- ð - ¨Tð - Ètð - Ð`cð - ð - ð - ð - ð^¨$¨s°E¸%¼,ÈÐ:KÔ4LÐ/LÔ*Mð ÐRUð ð ð ð ð, [_ðqð qØ˜s E¨%¬,¸Ð*;Ô$<Ð<Ô=ðqØSWðqà	ðqð qð qð qð qð qrn   c                   ó¢  ‡ — e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZedeeej        f         fd„¦   «         Zedefd„¦   «         Zd	efˆ fd
„Zd„ Zd„ Zed„ ¦   «         Zedej        dej        fd„¦   «         Z ede!j"        fd„¦   «         Z#ede$fd„¦   «         Z%e	 d^de&ej                 de&e'eeee(f         f                  defd„¦   «         Z)d„ Z*d„ Z+de!j"        fd„Z,de!j"        fd„Z-de!j"        fd„Z.d„ Z/d„ Z0d„ Z1e2de!j"        de!j"        d efd!„¦   «         Z3d"„ Z4defd#„Z5	 d^d$e&e(         d%e&e(         de!j6        fd&„Z7d_d'„Z8	 	 d^d(e!j6        d$e&e(         d%e&e(         de!j6        fd)„Z9	 d`d*e!j:        d$e&e(         d+e&e$         de!j:        fd,„Z;d-„ Z<d.e(fd/„Z=de'e!j6        e>e!j6                 f         fd0„Z?d1„ Z@d2ee(eAe(         f         fd3„ZBd_d4„ZCd5eDfd6e$d7eEfd8„ZFd9„ ZGede$fd:„¦   «         ZHd5dejI        dd;d5ddd5f	d<e'eeJjK        f         d=e$d>e&eL         d?eEd@e$dAe'e(ef         dBe$dCe&e         dDe&e'ee$f                  dEe$fdF„ZMdadG„ZN eOej!        j"        jP        ¦  «        ˆ fdH„¦   «         ZP eOej!        j"        jQ        ¦  «        ˆ fdI„¦   «         ZQˆ fdJ„ZRˆ fdK„ZSedddddddLddMœdNe&e'eeJjK        f                  d	e&e'eeeJjK        f                  dOe&e'eeJjK        f                  dPe$dQe$dRe$dDe&e'ee$f                  dSedTe$fdU„¦   «         ZTe	 	 	 	 	 	 	 	 	 	 dbdV„¦   «         ZUdcdW„ZVe2dddX„¦   «         ZWededZ„¦   «         ZXdfd[„ZYd\„ ZZd]„ Z[ˆ xZ\S )gÚPreTrainedModelaà  
    Base class for all models.

    [`PreTrainedModel`] takes care of storing the configuration of the models and handles methods for loading,
    downloading and saving models as well as a few methods common to all models to:

        - resize the input embeddings,
        - prune heads in the self-attention heads.

    Class attributes (overridden by derived classes):

        - **config_class** ([`PretrainedConfig`]) -- A subclass of [`PretrainedConfig`] to use as configuration class
          for this model architecture.
        - **load_tf_weights** (`Callable`) -- A python *method* for loading a TensorFlow checkpoint in a PyTorch model,
          taking as arguments:

            - **model** ([`PreTrainedModel`]) -- An instance of the model on which to load the TensorFlow checkpoint.
            - **config** ([`PreTrainedConfig`]) -- An instance of the configuration associated to the model.
            - **path** (`str`) -- A path to the TensorFlow checkpoint.

        - **base_model_prefix** (`str`) -- A string indicating the attribute associated to the base model in derived
          classes of the same architecture adding modules on top of the base model.
        - **is_parallelizable** (`bool`) -- A flag indicating whether this model supports model parallelization.
        - **main_input_name** (`str`) -- The name of the principal input to the model (often `input_ids` for NLP
          models, `pixel_values` for vision models and `input_values` for speech models).
    Nr6  Ú	input_idsFr‚   c                 ó8   — dt          j        t          ¦  «        iS )z^
        `Dict[str, torch.Tensor]`: Dummy inputs to do a forward pass in the network.
        r  )rf   Útensorr'   r³  s    ro   Údummy_inputszPreTrainedModel.dummy_inputse  s   € ð
 �Uœ\­,Ñ7Ô7Ð8Ð8rn   c                 ó   — dS )z@
        :str: Identifies that this is a PyTorch model.
        r$  rm   r³  s    ro   r&  zPreTrainedModel.frameworkl  s	   € ð
 ˆtrn   r×  c                 óX  •— t          ¦   «                              ¦   «          t          |t          ¦  «        s*t	          d| j        j        › d| j        j        › d�¦  «        ‚|| _        |j        | _        i | _	        |  
                    ¦   «         rt          j        |¦  «        nd | _        d S )NzParameter config in `zt(config)` should be an instance of class `PretrainedConfig`. To create a model from a pretrained model use `model = z(.from_pretrained(PRETRAINED_MODEL_NAME)`)ÚsuperÚ__init__rÒ   r   r·   r  r  r×  Úname_or_pathr÷  Úcan_generater   Úfrom_model_configÚgeneration_config)r¯  r×  Úinputsr¡  r  s       €ro   r  zPreTrainedModel.__init__s  s¾   ø€ Ý‰Œ×ÒÑÔÐÝ˜&Õ"2Ñ3Ô3ð 	Ýð^¨¬Ô(?ð ^ð ^à œNÔ3ð^ð ^ð ^ñô ð ð ˆŒØ"Ô/ˆÔØ!ˆÔØOS×O`ÒO`ÑObÔObÐ!lÕ!1Ô!CÀFÑ!KÔ!KÐ!KÐhlˆÔÐÐrn   c                 óV   — |                       ¦   «          |                      ¦   «          dS )zÅ
        A method executed at the end of each Transformer model initialization, to execute code that needs the model's
        modules properly initialized (such as weight initialization).
        N)Úinit_weightsÚ._backward_compatibility_gradient_checkpointingr³  s    ro   Ú	post_initzPreTrainedModel.post_init�  s.   € ð
 	×ÒÑÔÐØ×;Ò;Ñ=Ô=Ð=Ð=Ð=rn   c                 óš   — | j         rAt          | j        dd¦  «        r-|                      ¦   «          t	          | j        d¦  «         d S d S d S )NÚgradient_checkpointingF)Úsupports_gradient_checkpointingr[  r×  Úgradient_checkpointing_enableÚdelattrr³  s    ro   r  z>PreTrainedModel._backward_compatibility_gradient_checkpointing‰  sc   € ØÔ/ð 	;µG¸D¼KÐIaÐchÑ4iÔ4ið 	;Ø×.Ò.Ñ0Ô0Ð0å�D”KÐ!9Ñ:Ô:Ð:Ð:Ð:ð	;ð 	;ð 	;ð 	;rn   c                 óŒ  — |                      dd¦  «        }d}|�|                      |¦  «        }t          ¦   «         rgddl}t                               d¦  «         |j                             t          ¦   «         ¬¦  «        5   | |fi |¤Ž}ddd¦  «         n# 1 swxY w Y   n	 | |fi |¤Ž}|�t          j
        |¦  «         |S )zö
        All context managers that the model should be initialized under go here.

        Args:
            torch_dtype (`torch.dtype`, *optional*):
                Override the default `torch.dtype` and load the model under this dtype.
        Útorch_dtypeNr   ú@Detected DeepSpeed ZeRO-3: activating zero.init() for this model©Úconfig_dict_or_path)rZ  Ú_set_default_torch_dtyper   rL  rÿ   ÚinforN  ÚInitr   rf   Úset_default_dtype)Úclsr×  r¡  r  Ú
dtype_origrL  r  s          ro   Ú_from_configzPreTrainedModel._from_config�  s*  € ð —j’j °Ñ5Ô5ˆð ˆ
ØÐ"Ø×5Ò5°kÑBÔBˆJå%Ñ'Ô'ð 		*ØÐÐÐå�KŠKÐZÑ[Ô[Ð[ð ”×$Ò$Õ9IÑ9KÔ9KÐ$ÑLÔLð .ð .Ø˜˜FÐ-Ð- fÐ-Ð-�ð.ð .ð .ñ .ô .ð .ð .ð .ð .ð .ð .øøøð .ð .ð .ð .øð �C˜Ð)Ð) &Ð)Ð)ˆEð Ð!ÝÔ# JÑ/Ô/Ð/àˆs   Â
BÂBÂ Br¥   c                 óä   — |j         st          d| j        › d|› d�¦  «        ‚t                               d| j        › d|› d�¦  «         t          j        ¦   «         }t          j        |¦  «         |S )a�  
        Change the default dtype and return the previous one. This is needed when wanting to instantiate the model
        under specific dtype.

        Args:
            dtype (`torch.dtype`):
                a floating dtype to set to.

        Returns:
            `torch.dtype`: the original `dtype` that can be used to restore `torch.set_default_dtype(dtype)` if it was
            modified. If it wasn't, returns `None`.

        Note `set_default_dtype` currently only works with floating-point types and asserts if for example,
        `torch.int64` is passed. So if a non-float `dtype` is passed this functions will throw an exception.
        zCan't instantiate z model under dtype=z' since it is not a floating point dtypezInstantiating z model under default dtype r¾   )rª   r·   r  rÿ   r$  rf   Úget_default_dtyper&  )r'  r¥   r(  s      ro   r#  z(PreTrainedModel._set_default_torch_dtype°  sˆ   € ð" Ô&ð 	ÝØt S¤\ÐtÐtÀeÐtÐtÐtñô ð õ 	�ŠÐV S¤\ÐVÐVÈeÐVÐVÐVÑWÔWÐWÝÔ,Ñ.Ô.ˆ
ÝÔ Ñ&Ô&Ð&ØÐrn   c                 ó.   — t          | | j        | ¦  «        S )z@
        `torch.nn.Module`: The main body of the model.
        )r[  Úbase_model_prefixr³  s    ro   Ú
base_modelzPreTrainedModel.base_modelË  s   € õ
 �t˜TÔ3°TÑ:Ô:Ð:rn   c                 ób   — dt          | j        ¦  «        v rdt          | j        ¦  «        v rdS dS )z»
        Returns whether this model can generate sequences with `.generate()`.

        Returns:
            `bool`: Whether this model can generate sequences with `.generate()`.
        r   FT)r›   Úprepare_inputs_for_generationÚgenerate)r'  s    ro   r  zPreTrainedModel.can_generateÒ  s<   € ð ¥ CÔ$EÑ FÔ FÐFÐFÐK\Õ`cÐdgÔdpÑ`qÔ`qÐKqÐKqØ�5Øˆtrn   r  r†  c                 óH  — | j         st          d¦  «        ‚t          ¦   «         st          d¦  «        ‚t	          j        t          j                             d¦  «        ¦  «        }|t	          j        d¦  «        k    }|st          d|› �¦  «        ‚t          | dd¦  «        }|rt          d¦  «        ‚|€t           
                    d
¦  «         n/|�-|t          j        t          j        fvrt          d|› d�¦  «        ‚|€Ht          j                             ¦   «         rt           
                    d¦  «         nat          d¦  «        ‚|�Pt!          |t"          ¦  «        r;d|                     ¦   «         v sd|                     ¦   «         v rt          d¦  «        ‚d|_        |S )a  
        If you don't know about Flash Attention, check out the official repository of flash attention:
        https://github.com/Dao-AILab/flash-attention

        For using Flash Attention 1.0 you can do it directly via the `BetterTransformer` API, have a look at this
        specific section of the documentation to learn more about it:
        https://huggingface.co/docs/transformers/main/en/perf_infer_gpu_one#decoder-models

        The method checks if the current setup is compatible with Flash Attention as it requires the model to be in
        half precision and not ran on CPU.

        If all checks pass, the method will create an attribute in the config `_flash_attn_2_enabled` so that the model
        can initialize the correct attention module
        z¾The current architecture does not support Flash Attention 2.0. Please open an issue on GitHub to request support for this architecture: https://github.com/huggingface/transformers/issues/newzµFlash Attention 2 is not available. Please refer to the documentation of https://github.com/Dao-AILab/flash-attention for installing it. Make sure to have at least the version 2.1.0Ú
flash_attnz2.1.0z�You need flash_attn package version to be greater or equal than 2.1. Make sure to have that version installed - detected version Úuse_bettertransformerFz™Flash Attention 2 and BetterTransformer API are not compatible. Please make sure to disable BetterTransformers by doing model.reverse_bettertransformer()NzwYou are attempting to use Flash Attention 2.0 without specifying a torch dtype. This might lead to unexpected behaviourzVFlash Attention 2.0 only supports torch.float16 and torch.bfloat16 dtypes. You passed z*, this might lead to unexpected behaviour.z§You are attempting to use Flash Attention 2.0 with a model initialized on CPU. Make sure to move the model to GPU after initializing it on CPU with `model.to('cuda')`.a)  You are attempting to use Flash Attention 2.0 with a model initialized on CPU and with no GPU available. This is not supported yet. Please make sure to have access to a GPU and either initialise the model on a GPU by passing a device_map or initialising the model on CPU and then moving it to GPU.rø   r|  zÞYou are attempting to use Flash Attention 2.0 with a model dispatched on CPU or disk. This is not supported. Please make sure to initialise the model on a GPU by passing a device_map that contains only GPU devices as keys.T)Ú_supports_flash_attn_2r·   r;   r›  r   ÚparseÚ	importlibrÐ   r[  rÿ   r   rf   r�  r«   Úcudarh   rÒ   rM  r¶   Ú_flash_attn_2_enabled)r'  r×  r  r†  Úflash_attention_versionÚis_flash_greater_than_2Ú_is_bettertransformers          ro   Ú_check_and_enable_flash_attn_2z.PreTrainedModel._check_and_enable_flash_attn_2à  s#  € ð$ Ô)ð 	Ýðpñô ð õ
 )Ñ*Ô*ð 	ÝðOñô ð õ
 '.¤mµIÔ4F×4NÒ4NÈ|Ñ4\Ô4\Ñ&]Ô&]Ð#Ø&=ÅÄÈwÑAWÔAWÒ&WÐ#Ø*ð Ý ð rð  Ypð  rð  rñô ð õ !(¨Ð-DÀeÑ LÔ LÐà ð 	Ýð lñô ð ð ÐÝ�NŠNð Jñô ð ð ð Ð$¨½U¼]ÍEÌNÐ<[Ð)[Ð)[Ýð)Ðitð )ð )ð )ñô ð ð
 ÐÝŒz×&Ò&Ñ(Ô(ð 
Ý—’ðMñô ð ð õ
 !ðRñô ð ð Ð"Ý˜:¥tÑ,Ô,ð #à˜*×+Ò+Ñ-Ô-Ð-Ð-°¸:×;LÒ;LÑ;NÔ;NÐ1NÐ1Nåðpñô ð ð (,ˆÔ$Øˆrn   c                 ód   — d„ }|                       ¦   «                              |¦  «        | _        dS )zŸ
        Enables the gradients for the input embeddings. This is useful for fine-tuning adapter weights while keeping
        the model weights fixed.
        c                 ó0   — |                      d¦  «         d S )NT)Úrequires_grad_)r�   ÚinputÚoutputs      ro   Úmake_inputs_require_gradszMPreTrainedModel.enable_input_require_grads.<locals>.make_inputs_require_grads4  s   € Ø×!Ò! $Ñ'Ô'Ð'Ð'Ð'rn   N)Úget_input_embeddingsr¬  Ú_require_grads_hook)r¯  rC  s     ro   Úenable_input_require_gradsz*PreTrainedModel.enable_input_require_grads.  s<   € ð	(ð 	(ð 	(ð $(×#<Ò#<Ñ#>Ô#>×#TÒ#TÐUnÑ#oÔ#oˆÔ Ð Ð rn   c                 ó8   — | j                              ¦   «          dS )z4
        Removes the `_require_grads_hook`.
        N)rE  Úremover³  s    ro   Údisable_input_require_gradsz+PreTrainedModel.disable_input_require_grads9  s   € ð 	Ô ×'Ò'Ñ)Ô)Ð)Ð)Ð)rn   c                 ól   — t          | | j        | ¦  «        }|| ur|                     ¦   «         S t          ‚)z–
        Returns the model's input embeddings.

        Returns:
            `nn.Module`: A torch module mapping vocabulary to hidden states.
        )r[  r-  rD  ÚNotImplementedError)r¯  r.  s     ro   rD  z$PreTrainedModel.get_input_embeddings?  s;   € õ ˜T 4Ô#9¸4Ñ@Ô@ˆ
Ø˜TÐ!Ð!Ø×2Ò2Ñ4Ô4Ð4å%Ð%rn   r{  c                 ór   — t          | | j        | ¦  «        }|| ur|                     |¦  «         dS t          ‚)z�
        Set model's input embeddings.

        Args:
            value (`nn.Module`): A module mapping vocabulary to hidden states.
        N)r[  r-  Úset_input_embeddingsrK  )r¯  r{  r.  s      ro   rM  z$PreTrainedModel.set_input_embeddingsL  sC   € õ ˜T 4Ô#9¸4Ñ@Ô@ˆ
Ø˜TÐ!Ð!Ø×+Ò+¨EÑ2Ô2Ð2Ð2Ð2å%Ð%rn   c                 ó   — dS )z—
        Returns the model's output embeddings.

        Returns:
            `nn.Module`: A torch module mapping hidden states to vocabulary.
        Nrm   r³  s    ro   Úget_output_embeddingsz%PreTrainedModel.get_output_embeddingsY  s	   € ð ˆtrn   c                 ó   — dS )z\
        Initialize the weights. This method should be overridden by derived class.
        Nrm   r®  s     ro   rz   zPreTrainedModel._init_weightsb  s	   € ð 	ˆrn   c                 ód   — t          |dd¦  «        rdS |                      |¦  «         d|_        dS )zM
        Initialize the weights if they are not already initialized.
        r:  FNT)r[  rz   r:  r®  s     ro   Ú_initialize_weightsz#PreTrainedModel._initialize_weightsh  s@   € õ �6Ð/°Ñ7Ô7ð 	ØˆFØ×Ò˜6Ñ"Ô"Ð"Ø$(ˆÔ!Ð!Ð!rn   c                 ó  — t          | j        dd¦  «        r>|                      ¦   «         }|�(|                      ||                      ¦   «         ¦  «         t          | j        dd¦  «        rft          | j        dd¦  «        rPt          | | j        ¦  «        rt          | | j        ¦  «        } |                      | j        | j	        | j        ¦  «         |  
                    ¦   «         D ]&}t          |d¦  «        r|                     ¦   «          Œ'dS )zç
        Tie the weights between the input embeddings and the output embeddings.

        If the `torchscript` flag is set in the configuration, can't handle parameter sharing so we are cloning the
        weights instead.
        Útie_word_embeddingsTNÚis_encoder_decoderFÚtie_encoder_decoderÚ_tie_weights)r[  r×  rO  Ú_tie_or_clone_weightsrD  rf  r-  Ú_tie_encoder_decoder_weightsÚencoderÚdecoderr  rW  )r¯  Úoutput_embeddingsr�   s      ro   Útie_weightszPreTrainedModel.tie_weightsq  s  € õ �4”;Ð 5°tÑ<Ô<ð 	[Ø $× :Ò :Ñ <Ô <ÐØ Ð,Ø×*Ò*Ð+<¸d×>WÒ>WÑ>YÔ>YÑZÔZÐZå�4”;Ð 4°eÑ<Ô<ð 	bÅÈÌÐVkÐmrÑAsÔAsð 	bÝ�t˜TÔ3Ñ4Ô4ð =Ý˜t TÔ%;Ñ<Ô<�Ø×-Ò-¨d¬l¸D¼LÈ$ÔJ`ÑaÔaÐaà—l’l‘n”nð 	&ð 	&ˆFÝ�v˜~Ñ.Ô.ð &Ø×#Ò#Ñ%Ô%Ð%øð	&ð 	&rn   rZ  r[  r-  c           
      ór  ‡— g }|j         | j         k    r*t                               |j         › d| j         › d�¦  «         	 d
dt          j        dt          j        dt
          dt          t
                   fˆfd„Š ‰|| ||¦  «         t          |¦  «        dk    rt                               d	|› �¦  «         d S d S )Nú and zZ are not equal. In this case make sure that all encoder weights are correctly initialized.r   Údecoder_pointerÚencoder_pointerr8  Úuninitialized_encoder_weightsc           	      ó>  •‡— t          | t          j        ¦  «        rt          |t          j        ¦  «        sJ | › d|› d�¦   «         ‚t          | d¦  «        rNt          |d¦  «        sJ ‚| j        |_        t          | d¦  «        rt          |d¦  «        sJ ‚| j        |_        d S |j        }| j        }t          |¦  «        dk    �rVt          |¦  «        dk    sJ d|› d| › �¦   «         ‚ˆfd„|                     ¦   «         D ¦   «         }d}| 	                    ¦   «         D ]è\  }	}
|	 
                    ¦   «         rqt          t          |	¦  «        |z   ¦  «        }|	}t          ||         t          ||         ¦  «        ¦  «        s&t          |¦  «        t          |¦  «        k    r|d	z  }Œ‰n|	|vrŒ�|d
k    rt          d¦  «        ‚|	x}} ‰||         ||         ‰dz   |	z   ||d	z   ¬¦  «         |                     ‰dz   |z   ¦  «         Œé|t!          |¦  «        z  }d S d S )Nr_  z have to be of type nn.ModulerÝ   r@  r   zEncoder module z does not match decoder module c                 ó    •— h | ]
}‰d z   |z   ’ŒS )ú/rm   )rˆ   Úsub_namer8  s     €ro   ú	<setcomp>zkPreTrainedModel._tie_encoder_decoder_weights.<locals>.tie_encoder_to_decoder_recursively.<locals>.<setcomp>¨  s#   ø€ Ð&kÐ&kÐ&kÈ {°SÑ'8¸8Ñ'CÐ&kÐ&kÐ&krn   r   iô  zžMax depth of recursive function `tie_encoder_to_decoder` reached. It seems that there is a circular dependency between two or more `nn.Modules` of your model.re  )Údepth)rÒ   r   rš   rf  rÝ   r@  rQ  rÔ   rØ   r�   Úisdigitr›   rt   Útyper·   rH  r  )r`  ra  r8  rb  rh  Úencoder_modulesÚdecoder_modulesÚall_encoder_weightsÚencoder_layer_posrU  r�   Úencoder_nameÚdecoder_nameÚ"tie_encoder_to_decoder_recursivelys     `          €ro   rq  zXPreTrainedModel._tie_encoder_decoder_weights.<locals>.tie_encoder_to_decoder_recursively�  sÅ  øø€ õ ˜o­r¬yÑ9Ô9ð W½jØ¥¤ñ?ô ?ð Wð Wà!ÐVÐV¨ÐVÐVÐVñWô Wð õ �¨Ñ1Ô1ð Ý˜°Ñ9Ô9Ð9Ð9Ð9Ø)8Ô)?�Ô&Ý˜?¨FÑ3Ô3ð @Ý" ?°FÑ;Ô;Ð;Ð;Ð;Ø+:Ô+?�OÔ(Ø�à-Ô6ˆOØ-Ô6ˆOÝ�?Ñ#Ô# aÒ'Ñ'å˜Ñ(Ô(¨1Ò,Ð,Ð,Øf _ÐfÐfÐUdÐfÐfñ -Ô,Ð,ð 'lÐ&kÐ&kÐ&kÐTc×ThÒThÑTjÔTjÐ&kÑ&kÔ&kÐ#Ø$%Ð!Ø$3×$9Ò$9Ñ$;Ô$;ð Qð Q‘L�D˜&Ø—|’|‘~”~ð ;Ý'*­3¨t©9¬9Ð7HÑ+HÑ'IÔ'I˜Ø'+˜Ý)¨/¸,Ô*GÍÈoÐ^jÔNkÑIlÔIlÑmÔmð %ÕruØ+ñsô så  Ñ1Ô1òs2ð s2ð .°Ñ2Ð-Ø$øØ _Ð4Ð4Ø Ø š˜Ý(ðeñô ð ð
 7;Ð:˜ |Ø6Ð6Ø'¨Ô5Ø'¨Ô5Ø# cÑ)¨DÑ0Ø5Ø# a™iðñ ô ð ð (×.Ò.¨{¸SÑ/@À<Ñ/OÑPÔPÐPÐPà-µÐ6IÑ1JÔ1JÑJÐ-Ð-Ð-ðK (Ð'rn   z;The following encoder weights were not tied to the decoder )r   )	r  rÿ   r$  r   rš   r›   r
   rÔ   r   )rZ  r[  r-  rb  rq  s       @ro   rY  z,PreTrainedModel._tie_encoder_decoder_weights†  s  ø€ à35Ð%ØÔ Ô 1Ò1Ð1Ý�KŠKØÔ$ð 6ð 6¨7Ô+<ð 6ð 6ð 6ñô ð ð ð9	Kð 9	KÝœYð9	KåœYð9	Kõ ð9	Kõ ,0µ¬9ð	9	Kð 9	Kð 9	Kð 9	Kð 9	Kð 9	Kðx 	+Ð*¨7°GÐ=NÐPmÑnÔnÐnÝÐ,Ñ-Ô-°Ò1Ð1Ý�NŠNØmÐNkÐmÐmñô ð ð ð ð 2Ð1rn   c                 óÐ  — | j         j        r1t          j        |j                             ¦   «         ¦  «        |_        n|j        |_        t          |dd¦  «        �[t          j                             |j	        j
        d|j        j        d         |j	        j        d         z
  fdd¦  «        |j	        _
        t          |d¦  «        rt          |d¦  «        r|j        |_        dS dS dS )zPTie or clone module weights depending of whether we are using TorchScript or notr@  Nr   ÚconstantÚout_featuresÚnum_embeddings)r×  Útorchscriptr   rl  rÝ   Úcloner[  Ú
functionalÚpadr@  ÚdatarÉ  rf  ru  rt  )r¯  r\  Úinput_embeddingss      ro   rX  z%PreTrainedModel._tie_or_clone_weightsÑ  sÿ   € àŒ;Ô"ð 	?Ý')¤|Ð4DÔ4K×4QÒ4QÑ4SÔ4SÑ'TÔ'TÐÔ$Ð$à'7Ô'>ÐÔ$åÐ$ f¨dÑ3Ô3Ð?Ý*,¬-×*;Ò*;Ø!Ô&Ô+àØ%Ô,Ô2°1Ô5Ð8IÔ8NÔ8TÐUVÔ8WÑWðð Øñ+ô +ÐÔ"Ô'õ Ð$ nÑ5Ô5ð 	M½'ÐBRÐTdÑ:eÔ:eð 	MØ-=Ô-LÐÔ*Ð*Ð*ð	Mð 	Mð 	Mð 	Mrn   c                 óÀ  — t          ¦   «         }| g}t          |¦  «        dk    r¬|                     d¦  «        }|j        j        |vrvt          |t          ¦  «        r=|j        €t          |j        j        › d|› d�¦  «        ‚|t          |j        ¦  «        z  }|t          | 
                    ¦   «         ¦  «        z  }t          |¦  «        dk    °¬t          |¦  «        S )a™  
        Get the modules of the model that should not be spit when using device_map. We iterate through the modules to
        get the underlying `_no_split_modules`.

        Args:
            device_map (`str`):
                The device map value. Options are ["auto", "balanced", "balanced_low_0", "sequential"]

        Returns:
            `List[str]`: List of modules that should not be split
        r   rs   Nz does not support `device_map='z_'`. To implement support, the model class needs to implement the `_no_split_modules` attribute.)r  rÔ   rZ  r  r  rÒ   r  Ú_no_split_modulesr·   r  Úchildren)r¯  r†  r}  Úmodules_to_checkr�   s        ro   Ú_get_no_split_modulesz%PreTrainedModel._get_no_split_moduleså  s  € õ  ™EœEÐØ ˜6ÐÝÐ"Ñ#Ô# aÒ'Ð'Ø%×)Ò)¨"Ñ-Ô-ˆFàÔÔ(Ð0AÐAÐAÝ˜f¥oÑ6Ô6ð ^ØÔ/Ð7Ý(Ø%Ô/Ô8ð Zð ZÐYcð Zð Zð Zñô ð ð
 ->ÅÀFÔD\Ñ@]Ô@]Ñ,]Ð)Ø ¥D¨¯ªÑ):Ô):Ñ$;Ô$;Ñ;Ð õ Ð"Ñ#Ô# aÒ'Ð'õ Ð%Ñ&Ô&Ð&rn   Únew_num_tokensÚpad_to_multiple_ofc                 óÌ   — |                       ||¦  «        }|€|€|S |j        j        d         | j        _        |j        j        d         | _        |                      ¦   «          |S )aÏ  
        Resizes input token embeddings matrix of the model if `new_num_tokens != config.vocab_size`.

        Takes care of tying weights embeddings afterwards if the model class has a `tie_weights()` method.

        Arguments:
            new_num_tokens (`int`, *optional*):
                The number of new tokens in the embedding matrix. Increasing the size will add newly initialized
                vectors at the end. Reducing the size will remove vectors from the end. If not provided or `None`, just
                returns a pointer to the input tokens `torch.nn.Embedding` module of the model without doing anything.
            pad_to_multiple_of (`int`, *optional*):
                If set will pad the embedding matrix to a multiple of the provided value.If `new_num_tokens` is set to
                `None` will just pad the embedding to a multiple of `pad_to_multiple_of`.

                This is especially useful to enable the use of Tensor Cores on NVIDIA hardware with compute capability
                `>= 7.5` (Volta), or on TPUs which benefit from having sequence lengths be a multiple of 128. For more
                details about this, or help on choosing the correct value for resizing, refer to this guide:
                https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html#requirements-tc

        Return:
            `torch.nn.Embedding`: Pointer to the input tokens Embeddings Module of the model.
        Nr   )Ú_resize_token_embeddingsrÝ   rÉ  r×  Ú
vocab_sizer]  )r¯  r�  r‚  Úmodel_embedss       ro   Úresize_token_embeddingsz'PreTrainedModel.resize_token_embeddings  so   € ð2 ×4Ò4°^ÐEWÑXÔXˆØÐ!Ð&8Ð&@ØÐð ".Ô!4Ô!:¸1Ô!=ˆŒÔØ&Ô-Ô3°AÔ6ˆŒð 	×ÒÑÔÐàÐrn   c                 óè  — |                       ¦   «         }|                      |||¦  «        }t          |d¦  «        r|j        }t	          ||¦  «         |                      |¦  «         |�pt          ¦   «         rPdd l}|j         	                    |j
        d ¬¦  «        5  |j
        j        d         }d d d ¦  «         n# 1 swxY w Y   n|j
        j        d         }|                      ¦   «         �r| j        j        sf|                      ¦   «         }|                      ||¦  «        }t          |d¦  «        r|j        }t	          ||¦  «         |                      |¦  «         |                       ¦   «         S )NÚ_hf_hookr   rJ  )rD  Ú_get_resized_embeddingsrf  r‰  rV   rM  r   rL  rN  rO  rÝ   rÉ  rO  r×  rT  Ú_get_resized_lm_headÚset_output_embeddings)	r¯  r�  r‚  Úold_embeddingsÚnew_embeddingsÚhookrL  Úold_lm_headÚnew_lm_heads	            ro   r„  z(PreTrainedModel._resize_token_embeddings(  sÈ  € Ø×2Ò2Ñ4Ô4ˆØ×5Ò5°nÀnÐVhÑiÔiˆÝ�> :Ñ.Ô.ð 	5Ø!Ô*ˆDÝ˜~¨tÑ4Ô4Ð4Ø×!Ò! .Ñ1Ô1Ð1ð Ð)Ý)Ñ+Ô+ð @Ø Ð Ð Ð à”^×6Ò6°~Ô7LÐ\`Ð6ÑaÔað Dð DØ%3Ô%:Ô%@ÀÔ%C�NðDð Dð Dñ Dô Dð Dð Dð Dð Dð Dð Døøøð Dð Dð Dð Døð "0Ô!6Ô!<¸QÔ!?�ð ×%Ò%Ñ'Ô'Ð3¸D¼KÔ<[Ð3Ø×4Ò4Ñ6Ô6ˆKØ×3Ò3°KÀÑPÔPˆKÝ�{ JÑ/Ô/ð 6Ø"Ô+�Ý" ;°Ñ5Ô5Ð5Ø×&Ò& {Ñ3Ô3Ð3à×(Ò(Ñ*Ô*Ð*s   ÂB<Â<C ÃC r�  c           	      ó¸  — |�Kt          |t          ¦  «        st          d|› d�¦  «        ‚|€|j        j        d         }||z   dz
  |z  |z  }nt
                               d|› d�¦  «         |€|S t          ¦   «         rZddl}|j	         
                    |j        d¬¦  «        5  |j                             ¦   «         \  }}ddd¦  «         n# 1 swxY w Y   n|j                             ¦   «         \  }}||k    rt          ¦   «         s|S t          |t          j        ¦  «        s:t          d	t          |¦  «        › d
t          j        › dt          j        › d�¦  «        ‚t          j        |||j        j        |j        j        ¬¦  «        }|                      |¦  «         t'          ||¦  «        }t          ¦   «         rrddl}|j        |j        g}	|j	         
                    |	d¬¦  «        5  |j        j        d|…dd…f         |j        j        d|…dd…f<   ddd¦  «         n# 1 swxY w Y   n+|j        j        d|…dd…f         |j        j        d|…dd…f<   |S )aj  
        Build a resized Embedding Module from a provided token Embedding Module. Increasing the size will add newly
        initialized vectors at the end. Reducing the size will remove vectors from the end

        Args:
            old_embeddings (`torch.nn.Embedding`):
                Old embeddings to be resized.
            new_num_tokens (`int`, *optional*):
                New number of tokens in the embedding matrix.

                Increasing the size will add newly initialized vectors at the end. Reducing the size will remove
                vectors from the end. If not provided or `None`, just returns a pointer to the input tokens
                `torch.nn.Embedding` module of the model without doing anything.
            pad_to_multiple_of (`int`, *optional*):
                If set will pad the embedding matrix to a multiple of the provided value. If `new_num_tokens` is set to
                `None` will just pad the embedding to a multiple of `pad_to_multiple_of`.

                This is especially useful to enable the use of Tensor Cores on NVIDIA hardware with compute capability
                `>= 7.5` (Volta), or on TPUs which benefit from having sequence lengths be a multiple of 128. For more
                details about this, or help on choosing the correct value for resizing, refer to this guide:
                https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html#requirements-tc


        Return:
            `torch.nn.Embedding`: Pointer to the resized Embedding Module or the old Embedding Module if
            `new_num_tokens` is `None`
        Nz5Asking to pad the embedding matrix to a multiple of `z@`, which is not and integer. Please make sure to pass an integerr   r   z�You are resizing the embedding layer without providing a `pad_to_multiple_of` parameter. This means that the new embedding dimension will be a.  . This might induce some performance reduction as *Tensor Cores* will not be available. For more details about this, or help on choosing the correct value for resizing, refer to this guide: https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html#requirements-tcrJ  zOld embeddings are of type ú, which is not an instance of zj. You should either use a different resize function or make sure that `old_embeddings` are an instance of r¾   rÂ  )rÒ   rt   r·   rÝ   rÉ  rÿ   r$  r   rL  rN  rO  Úsizer   rè  Ú	TypeErrorrj  r˜   r¥   rz   r½  rz  )
r¯  r�  r�  r‚  rL  Úold_num_tokensÚold_embedding_dimrŽ  ÚnÚparamss
             ro   rŠ  z'PreTrainedModel._get_resized_embeddingsE  s�  € ðD Ð)ÝÐ0µ#Ñ6Ô6ð Ý ð aÐL^ð  að  að  añô ð ð Ð%Ø!/Ô!6Ô!<¸QÔ!?�Ø-Ð0BÑBÀQÑFÐK]Ñ]ÐasÑsˆNˆNå�KŠKðDØ&4ðDð Dð Dñô ð ð Ð!Ø!Ð!å%Ñ'Ô'ð 	MØÐÐÐà”×2Ò2°>Ô3HÐX\Ð2Ñ]Ô]ð Qð QØ4BÔ4I×4NÒ4NÑ4PÔ4PÑ1�Ð 1ðQð Qð Qñ Qô Qð Qð Qð Qð Qð Qð Qøøøð Qð Qð Qð Qøð 1?Ô0E×0JÒ0JÑ0LÔ0LÑ-ˆNÐ-à˜^Ò+Ð+Õ4NÑ4PÔ4PÐ+Ø!Ð!å˜.­"¬,Ñ7Ô7ð 	Ýð$­d°>Ñ.BÔ.Bð $ð $ÕbdÔbnð $ð $å”Lð$ð $ð $ñô ð õ œØØØ!Ô(Ô/Ø Ô'Ô-ð	
ñ 
ô 
ˆð 	×Ò˜>Ñ*Ô*Ð*õ
 � Ñ/Ô/ˆå%Ñ'Ô'ð 	RØÐÐÐà$Ô+¨^Ô-BÐCˆFØ”×2Ò2°6ÈÐ2ÑKÔKð Vð VØ4BÔ4IÔ4NÈrÐPQÈrÐSTÐSTÐSTÈuÔ4U�Ô%Ô*¨2¨A¨2¨q¨q¨q¨5Ñ1ðVð Vð Vñ Vô Vð Vð Vð Vð Vð Vð Vøøøð Vð Vð Vð Vøð 1?Ô0EÔ0JÈ2ÈAÈ2ÈqÈqÈqÈ5Ô0QˆNÔ!Ô& r¨ r¨1¨1¨1 uÑ-àÐs$   Â#CÃCÃCÇ+,H#È#H'È*H'r�  Ú
transposedc           	      ó‚  — |€|S t          ¦   «         r‡ddl}|j                             |j        d¬¦  «        5  |s|j                             ¦   «         n*|j                             ¦   «                              ¦   «         \  }}ddd¦  «         n# 1 swxY w Y   nI|s|j                             ¦   «         n*|j                             ¦   «                              ¦   «         \  }}||k    rt          ¦   «         s|S t          |t          j	        ¦  «        s:t          dt          |¦  «        › dt          j	        › dt          j	        › d�¦  «        ‚|s||fn||f}|j        du}t          j	        |||j        j        |j        j        dœŽ}	|                      |	¦  «         t!          ||¦  «        }
t          ¦   «         rlddl}|j        |j        |	j        |	j        g}|j                             |d¬¦  «        5  |                      |	||
||¦  «         ddd¦  «         n# 1 swxY w Y   n|                      |	||
||¦  «         |	S )	aN  
        Build a resized Linear Module from a provided old Linear Module. Increasing the size will add newly initialized
        vectors at the end. Reducing the size will remove vectors from the end

        Args:
            old_lm_head (`torch.nn.Linear`):
                Old lm head liner layer to be resized.
            new_num_tokens (`int`, *optional*):
                New number of tokens in the linear matrix.

                Increasing the size will add newly initialized vectors at the end. Reducing the size will remove
                vectors from the end. If not provided or `None`, just returns a pointer to the input tokens
                `torch.nn.Linear` module of the model without doing anything. transposed (`bool`, *optional*, defaults
                to `False`): Whether `old_lm_head` is transposed or not. If True `old_lm_head.size()` is `lm_head_dim,
                vocab_size` else `vocab_size, lm_head_dim`.

        Return:
            `torch.nn.Linear`: Pointer to the resized Linear Module or the old Linear Module if `new_num_tokens` is
            `None`
        Nr   rJ  z#Old language model head is of type r“  zg. You should either use a different resize function or make sure that `old_lm_head` are an instance of r¾   )r@  r˜   r¥   )r   rL  rN  rO  rÝ   r”  r±   rÒ   r   ÚLinearr•  rj  r@  r˜   r¥   rz   r½  Ú!_copy_lm_head_original_to_resized)r¯  r�  r�  rš  rL  r–  Úold_lm_head_dimÚnew_lm_head_shapeÚhas_new_lm_head_biasr‘  Únum_tokens_to_copyr™  s               ro   r‹  z$PreTrainedModel._get_resized_lm_head¬  s!  € ð. Ð!ØÐå%Ñ'Ô'ð 
	ØÐÐÐà”×2Ò2°;Ô3EÐUYÐ2ÑZÔZð ð à5?Ðb�KÔ&×+Ò+Ñ-Ô-Ð-À[ÔEW×EYÒEYÑE[ÔE[×E`ÒE`ÑEbÔEbñ 0� ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øð 2<Ð^�Ô"×'Ò'Ñ)Ô)Ð)ÀÔAS×AUÒAUÑAWÔAW×A\ÒA\ÑA^ÔA^ñ ,ˆN˜Oð ˜^Ò+Ð+Õ4NÑ4PÔ4PÐ+ØÐå˜+¥r¤yÑ1Ô1ð 	Ýð!µd¸;Ñ6GÔ6Gð !ð !ÕgiÔgpð !ð !å”Ið!ð !ð !ñô ð ð FPÐv˜_¨nÐ=Ð=ÐVdÐfuÐUvÐØ*Ô/°tÐ;Ðõ ”iØØ%ØÔ%Ô,ØÔ$Ô*ð	
ð 
ð 
ˆð 	×Ò˜;Ñ'Ô'Ð'å  °Ñ@Ô@Ðå%Ñ'Ô'ð 	ØÐÐÐà!Ô(¨+Ô*:¸KÔ<NÐP[ÔP`ÐaˆFØ”×2Ò2°6ÈÐ2ÑKÔKð ð Ø×6Ò6Ø Ð.@À*ÐNbñô ð ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øð
 ×2Ò2Ø˜[Ð*<¸jÐJ^ñô ð ð Ðs$   ¸A
BÂBÂBÇ4HÈHÈ!Hc                 ó  — |s,|j         j        d |…d d …f         |j         j        d |…d d …f<   n+|j         j        d d …d |…f         |j         j        d d …d |…f<   |r%|j        j        d |…         |j        j        d |…<   d S d S rý  )rÝ   rz  r@  )r¯  r‘  r�  r¡  rš  r   s         ro   r�  z1PreTrainedModel._copy_lm_head_original_to_resizedÿ  sÒ   € ð ð 	nØ>IÔ>PÔ>UÐViÐWiÐViÐklÐklÐklÐVlÔ>mˆKÔÔ#Ð$7Ð%7Ð$7¸¸¸Ð$:Ñ;Ð;à>IÔ>PÔ>UÐVWÐVWÐVWÐYlÐZlÐYlÐVlÔ>mˆKÔÔ# A A AÐ':Ð(:Ð':Ð$:Ñ;ð  ð 	dØ9DÔ9IÔ9NÐObÐPbÐObÔ9cˆKÔÔ!Ð"5Ð#5Ð"5Ñ6Ð6Ð6ð	dð 	drn   Únew_num_position_embeddingsc           	      ó\   — t          d| j        › d| j        › d| j        j        › d�¦  «        ‚)Nz4`resize_position_embeddings` is not implemented for úB`. To implement it, you should overwrite this method in the class ú in `modeling_ú.py`©rK  r  r  )r¯  r£  s     ro   Úresize_position_embeddingsz*PreTrainedModel.resize_position_embeddings  sV   € Ý!ðpÀ4Ä>ð pð pØ26´.ðpð pØPTÔP^ÔPiðpð pð pñ
ô 
ð 	
rn   c           	      ó\   — t          d| j        › d| j        › d| j        j        › d�¦  «        ‚)Nz1`get_position_embeddings` is not implemented for r¥  r¦  r§  r¨  r³  s    ro   Úget_position_embeddingsz'PreTrainedModel.get_position_embeddings  sV   € Ý!ðpÀÄð pð pØ26´.ðpð pØPTÔP^ÔPiðpð pð pñ
ô 
ð 	
rn   c                 óÊ   — | j         j        r|                      | j         j        ¦  «         t          r0|                      | j        ¦  «         |                      ¦   «          dS dS )z±
        If needed prunes and maybe initializes weights. If using a custom `PreTrainedModel`, you need to implement any
        initialization logic in `_init_weights`.
        N)r×  Úpruned_headsÚprune_headsrz   ÚapplyrR  r]  r³  s    ro   r  zPreTrainedModel.init_weights  sk   € ð Œ;Ô#ð 	7Ø×Ò˜Tœ[Ô5Ñ6Ô6Ð6åð 	à�JŠJ�tÔ/Ñ0Ô0Ð0ð ×ÒÑÔÐÐÐð	ð 	rn   Úheads_to_prunec                 ó   — |                      ¦   «         D ]^\  }}t          | j        j                             |g ¦  «        ¦  «        t          |¦  «        z  }t          |¦  «        | j        j        |<   Œ_| j                             |¦  «         dS )a   
        Prunes heads of the base model.

        Arguments:
            heads_to_prune (`Dict[int, List[int]]`):
                Dictionary with keys being selected layer indices (`int`) and associated values being the list of heads
                to prune in said layer (list of `int`). For instance {1: [0, 2], 2: [2, 3]} will prune heads 0 and 2 on
                layer 1 and heads 2 and 3 on layer 2.
        N)r�   r  r×  r­  rl   r  r.  Ú_prune_heads)r¯  r°  ÚlayerÚheadsÚunion_headss        ro   r®  zPreTrainedModel.prune_heads)  sˆ   € ð +×0Ò0Ñ2Ô2ð 	@ð 	@‰LˆE�5Ý˜dœkÔ6×:Ò:¸5À"ÑEÔEÑFÔFÍÈUÉÌÑSˆKÝ.2°;Ñ.?Ô.?ˆDŒKÔ$ UÑ+Ð+àŒ×$Ò$ ^Ñ4Ô4Ð4Ð4Ð4rn   c                 óþ   — | j         st          | j        j        › d�¦  «        ‚|€i }t	          j        t          fi |¤Ž}|                      d|¬¦  «         t          | dd¦  «        r|  	                    ¦   «          dS dS )az  
        Activates gradient checkpointing for the current model.

        Note that in other frameworks this feature can be referred to as "activation checkpointing" or "checkpoint
        activations".

        We pass the `__call__` method of the modules instead of `forward` because `__call__` attaches all the hooks of
        the module. https://discuss.pytorch.org/t/any-different-between-model-input-and-model-forward-input/3690/2

        Args:
            gradient_checkpointing_kwargs (dict, *optional*):
                Additional keyword arguments passed along to the `torch.utils.checkpoint.checkpoint` function.
        z) does not support gradient checkpointing.NT)ÚenableÚgradient_checkpointing_funcÚ_hf_peft_config_loadedF)
r  r·   r  r  Ú	functoolsr   r   Ú_set_gradient_checkpointingr[  rF  )r¯  Úgradient_checkpointing_kwargsr¸  s      ro   r  z-PreTrainedModel.gradient_checkpointing_enable:  s¥   € ð Ô3ð 	dÝ ¤Ô 7ÐbÐbÐbÑcÔcÐcà(Ð0Ø,.Ð)å&/Ô&7½
Ð&dÐ&dÐFcÐ&dÐ&dÐ#à×(Ò(°ÐRmÐ(ÑnÔnÐnå�4Ð1°5Ñ9Ô9ð 	.ð
 ×+Ò+Ñ-Ô-Ð-Ð-Ð-ð	.ð 	.rn   Tr·  r¸  c                 óô   — d}t          | d¦  «        r|| _        || _        d}|                      ¦   «         D ]"}t          |d¦  «        r||_        ||_        d}Œ#|st	          | j        j        › d�¦  «        ‚d S )NFr  TzÂ is not compatible with gradient checkpointing. Make sure all the architecture support it by setting a boolean attribute `gradient_checkpointing` to modules of the model that uses checkpointing.)rf  Ú_gradient_checkpointing_funcr  r  r·   r  r  )r¯  r·  r¸  Úis_gradient_checkpointing_setr�   s        ro   r»  z+PreTrainedModel._set_gradient_checkpointingY  s²   € Ø(-Ð%õ �4Ð1Ñ2Ô2ð 	1Ø0KˆDÔ-Ø*0ˆDÔ'Ø,0Ð)à—l’l‘n”nð 	5ð 	5ˆFÝ�vÐ7Ñ8Ô8ð 5Ø6Q�Ô3Ø06�Ô-Ø04Ð-øà,ð 	ÝØ”>Ô*ð ]ð ]ð ]ñô ð ð	ð 	rn   c                 óŽ   — | j         r|                      d¬¦  «         t          | dd¦  «        r|                      ¦   «          dS dS )zÕ
        Deactivates gradient checkpointing for the current model.

        Note that in other frameworks this feature can be referred to as "activation checkpointing" or "checkpoint
        activations".
        F)r·  r¹  N)r  r»  r[  rI  r³  s    ro   Úgradient_checkpointing_disablez.PreTrainedModel.gradient_checkpointing_disableo  s]   € ð Ô/ð 	;Ø×,Ò,°EÐ,Ñ:Ô:Ð:å�4Ð1°5Ñ9Ô9ð 	/Ø×,Ò,Ñ.Ô.Ð.Ð.Ð.ð	/ð 	/rn   c                 óX   — t          d„ |                      ¦   «         D ¦   «         ¦  «        S )zÞ
        Whether gradient checkpointing is activated for this model or not.

        Note that in other frameworks this feature can be referred to as "activation checkpointing" or "checkpoint
        activations".
        c              3   óD   K  — | ]}t          |d ¦  «        o|j        V — ŒdS )r  N)rf  r  )rˆ   Úms     ro   rz  z<PreTrainedModel.is_gradient_checkpointing.<locals>.<genexpr>„  s6   è è € ÐmÐmÐYZ•7˜1Ð6Ñ7Ô7ÐT¸AÔ<TÐmÐmÐmÐmÐmÐmrn   )r€  r  r³  s    ro   Úis_gradient_checkpointingz)PreTrainedModel.is_gradient_checkpointing|  s.   € õ ÐmÐmÐ^b×^jÒ^jÑ^lÔ^lÐmÑmÔmÑmÔmÐmrn   Ú5GBÚsave_directoryÚis_main_processr¹   Úsave_functionÚpush_to_hubrÈ   Úsafe_serializationr”  ÚtokenÚsave_peft_formatc           	      ó"  ‡0— |                      dd¦  «        }|�-t          j        dt          ¦  «         |	�t	          d¦  «        ‚|}	|	�|	|d<   t          | dd¦  «        }t          | dd¦  «        r"t          | d	d¦  «        s|st	          d
¦  «        ‚t          | dd¦  «        r|st          d¦  «        ‚d|v r)t          j        d¦  «         |                      d¦  «        }|rt          ¦   «         st          d¦  «        ‚t          j
                             |¦  «        r t                               d|› d�¦  «         dS t          j        |d¬¦  «         |rw|                      dd¦  «        }|                      d|                     t          j
        j        ¦  «        d         ¦  «        } | j        |fi |¤Ž}|                      |¦  «        }t'          | ¦  «        }t)          |¦  «        }t+          |¦  «                             d¦  «        d         |j        _        |j        j        g|j        _        | j        �t9          | || j        ¬¦  «         |�r|s|j                             |¦  «         |                      ¦   «         r|j                             |¦  «         |rÐt                                d¦  «         | !                    ¦   «         }|
r@t                                d¦  «         i }| "                    ¦   «         D ]\  }}||d|› �<   Œ|}|  #                    ¦   «         }tI          |¦  «        dk    rt	          d¦  «        ‚|d         }| j%        |         }|                     |¦  «         |€| &                    ¦   «         }tN          r'tP          j)        j*        j+        D ]\  }} ||¦  «        }Œ| j,        �#| j,        D ]}|| -                    ¦   «         v r||= Œ|�rœt]          j/        t`          ¦  «        }| "                    ¦   «         D ]p\  Š0}tc          |td          j3        ¦  «        r)|ti          |¦  «                  5                    ‰0¦  «         ŒH|tm          |¦  «                  5                    ‰0¦  «         Œqd„ | "                    ¦   «         D ¦   «         }to          ¦   «         }| 8                    ¦   «         D ]Œ}| j9        �Ud} tu          |¦  «        D ]CŠ0tw          ˆ0fd „| j9        D ¦   «         ¦  «        }!|!r‰0|v r| dz  } | tI          |¦  «        k     r|‰0= ŒDd} |D ])Š0‰0|v r#| dz  } | dk    r|‰0= | <                    ‰0¦  «         Œ*Œ�tI          |¦  «        dk    rt           =                    d!|› d"�¦  «         |s!|rt|          nt~          }"t�          |"|¦  «        }"n|rt‚          nt„          }"t‡          |||"¬#¦  «        \  }#}$t          jD        |¦  «        D �] }%t          j
         E                    ||%¦  «        }&|" F                    d$d%¦  «         F                    d&d%¦  «        }'|% F                    d$d%¦  «         F                    d&d%¦  «        }(t�          jH        d'¦  «        })|% I                    |'¦  «        r`t          j
                             |&¦  «        rA|%|# -                    ¦   «         vr+|r)|) J                    |(¦  «        �t          jK        |&¦  «         �Œ|# "                    ¦   «         D ]d\  }*}+|r3t™          |+t          j
         E                    ||*¦  «        d(d)i¬*¦  «         Œ: ||+t          j
         E                    ||*¦  «        ¦  «         Œe|$€Qt          j
         E                    |t�          t~          |¦  «        ¦  «        },t                                d+|,› �¦  «         nÈ|rtš          ntœ          }-t          j
         E                    |t�          |-|¦  «        ¦  «        }-tŸ          |-d,d-¬.¦  «        5 }.t¡          jQ        |$d/d¬0¦  «        d1z   }/|. R                    |/¦  «         ddd¦  «         n# 1 swxY w Y   t                                d2|› d3tI          |#¦  «        › d4|-› d�¦  «         |r|  S                    |||||	¬5¦  «         dS dS )6aƒ  
        Save a model and its configuration file to a directory, so that it can be re-loaded using the
        [`~PreTrainedModel.from_pretrained`] class method.

        Arguments:
            save_directory (`str` or `os.PathLike`):
                Directory to which to save. Will be created if it doesn't exist.
            is_main_process (`bool`, *optional*, defaults to `True`):
                Whether the process calling this is the main process or not. Useful when in distributed training like
                TPUs and need to call this function on all processes. In this case, set `is_main_process=True` only on
                the main process to avoid race conditions.
            state_dict (nested dictionary of `torch.Tensor`):
                The state dictionary of the model to save. Will default to `self.state_dict()`, but can be used to only
                save parts of the model or if special precautions need to be taken when recovering the state dictionary
                of a model (like when using model parallelism).
            save_function (`Callable`):
                The function to use to save the state dictionary. Useful on distributed training like TPUs when one
                need to replace `torch.save` by another method.
            push_to_hub (`bool`, *optional*, defaults to `False`):
                Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
                repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
                namespace).
            max_shard_size (`int` or `str`, *optional*, defaults to `"5GB"`):
                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 in order for models to be able to run easily on free-tier google colab instances
                without CPU OOM issues.

                <Tip warning={true}>

                If a single weight of the model is bigger than `max_shard_size`, it will be in its own checkpoint shard
                which will be bigger than `max_shard_size`.

                </Tip>

            safe_serialization (`bool`, *optional*, defaults to `True`):
                Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
            variant (`str`, *optional*):
                If specified, weights are saved in the format pytorch_model.<variant>.bin.
            token (`str` or `bool`, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
                the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
            save_peft_format (`bool`, *optional*, defaults to `True`):
                For backward compatibility with PEFT library, in case adapter weights are attached to the model, all
                keys of the state dict of adapters needs to be pre-pended with `base_model.model`. Advanced users can
                disable this behaviours by setting `save_peft_format` to `False`.
            kwargs (`Dict[str, Any]`, *optional*):
                Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
        Ú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`.rÌ  r¹  FÚis_loaded_in_8bitÚis_8bit_serializablezÁYou are calling `save_pretrained` to a 8-bit converted model you may likely encounter unexepected behaviors. If you want to save 8-bit models, make sure to have `bitsandbytes>0.37.2` installed.rì  z]You are calling `save_pretrained` on a 4-bit converted model. This is currently not supportedÚsave_configze`save_config` is deprecated and will be removed in v5 of Transformers. Use `is_main_process` instead.zR`safe_serialization` requires the `safetensors library: `pip install safetensors`.zProvided path (z#) should be a directory, not a fileT©Úexist_okÚcommit_messageÚrepo_idrs   r¾   r   )r×  zhDetected adapters on the model, saving the model in the PEFT format, only adapter weights will be saved.z„To match the expected format of the PEFT library, all keys of the state dict of adapters will be pre-pended with `base_model.model`.zbase_model.model.zßMultiple active adapters detected, saving multiple active adapters is not supported yet. You can save adapters separately one by one by iteratively calling `model.set_adapter(adapter_name)` then `model.save_pretrained(...)`r   c                 ó@   — i | ]\  }}t          |¦  «        d k    ¯||“ŒS ©r   ©rÔ   )rˆ   ÚptrÚnamess      ro   ú
<dictcomp>z3PreTrainedModel.save_pretrained.<locals>.<dictcomp>J  s*   € ÐWÐWÐW©*¨#¨uÍÈEÉ
Ì
ÐUVÊÈ˜3 ÈÈÈrn   c              3   óB   •K  — | ]}t          j        |‰¦  «        V — Œd S rý  ©rÁ   rÂ   )rˆ   ÚpatrU  s     €ro   rz  z2PreTrainedModel.save_pretrained.<locals>.<genexpr>R  s/   øè è € Ð-fÐ-fÀs­b¬i¸¸TÑ.BÔ.BÐ-fÐ-fÐ-fÐ-fÐ-fÐ-frn   zRemoved shared tensor zk while saving. This should be OK, but check by verifying that you don't receive any warning while reloading)rÈ   rÉ   rË   r6  rÎ   z(.*?)-\d{5}-of-\d{5}r'  r$  )rÐ   zModel weights saved in Úwrê   rë   r¸  )ÚindentÚ	sort_keysú
z:The model is bigger than the maximum size per checkpoint (z) and is going to be split in z^ checkpoint shards. You can find where each parameters has been saved in the index located at )r×  rÌ  )TrZ  rÄ  rÅ  rÆ  r·   r[  rK  r@   r›  rj   rü   rþ   rÿ   ÚerrorÚmakedirsre  ÚsepÚ_create_repoÚ_get_files_timestampsÚunwrap_modelr´   r›   r×  r  r  r  ÚarchitecturesÚ_auto_classr   Úsave_pretrainedr  r  r$  Úget_adapter_state_dictr�   Úactive_adaptersrÔ   Úpeft_configr¹   ÚIS_SAGEMAKER_MP_POST_1_10ÚsmpÚstateÚmodule_managerÚtranslate_functionsÚ_keys_to_ignore_on_saverØ   ÚcollectionsÚdefaultdictr  rÒ   rf   r   r    rÕ   Úidr  r¶   Ú_tied_weights_keysÚsortedr€  ÚaddÚwarning_oncer*   r.   r–  r$   r%   ræ   Úlistdirrý   r×   rÁ   Úcompiler7  Ú	fullmatchrH  Úsafe_save_filer)   r-   r  r  ÚdumpsÚwriteÚ_upload_modified_files)1r¯  rÇ  rÈ  r¹   rÉ  rÊ  rÈ   rË  r”  rÌ  rÍ  r¡  rÏ  r¹  r×  rØ  Úfiles_timestampsÚmodel_to_saver¥   Úpeft_state_dictrÜ   r{  Úactive_adapterÚcurrent_peft_configÚ	smp_to_hfÚ_Ú
ignore_keyÚptrsr
  Úshared_ptrsÚ
warn_namesrÝ  ÚfoundÚmatches_patternrÉ   rá   rå   ÚfilenameÚfull_filenameÚweights_no_suffixÚfilename_no_suffixÚregrä   rã   Úpath_to_weightsÚsave_index_filer  ÚcontentrU  s1                                                   @ro   rî  zPreTrainedModel.save_pretrained†  sñ	  ø€ ð~  ŸšÐ$4°dÑ;Ô;ˆàÐ%ÝŒMð EÝñô ð ð Ð Ý Ølñô ð ð #ˆEàÐØ#ˆF�7‰Oå!(¨Ð/GÈÑ!OÔ!OÐõ �DÐ-¨uÑ5Ô5ð	å˜DÐ"8¸%Ñ@Ô@ð	ð +ð	õ
 ðsñô ð õ �4Ð,¨eÑ4Ô4ð 	Ð=Sð 	Ý%Øoñô ð ð ˜FÐ"Ð"ÝŒMØwñô ð ð %Ÿjšj¨Ñ7Ô7ˆOØð 	tÕ&>Ñ&@Ô&@ð 	tÝÐrÑsÔsÐsåŒ7�>Š>˜.Ñ)Ô)ð 	Ý�LŠLÐ^¨>Ð^Ð^Ð^Ñ_Ô_Ð_ØˆFå
Œ�N¨TÐ2Ñ2Ô2Ð2àð 	JØ#ŸZšZÐ(8¸$Ñ?Ô?ˆNØ—j’j ¨N×,@Ò,@ÅÄÄÑ,MÔ,MÈbÔ,QÑRÔRˆGØ'�dÔ'¨Ð:Ð:°6Ð:Ð:ˆGØ#×9Ò9¸.ÑIÔIÐõ % TÑ*Ô*ˆõ $ MÑ2Ô2ˆÝ+.¨u©:¬:×+;Ò+;¸CÑ+@Ô+@ÀÔ+CˆÔÔ(ð /<Ô.EÔ.NÐ-OˆÔÔ*ð ÔÐ'Ý˜t ^¸D¼KÐHÑHÔHÐHð ñ 	DØ)ð EØÔ$×4Ò4°^ÑDÔDÐDØ× Ò Ñ"Ô"ð PØÔ/×?Ò?ÀÑOÔOÐOà%ð DÝ—’Ø~ñô ð ð +×AÒAÑCÔC�
à#ð 1Ý—K’Kð _ñô ð ð ')�OØ&0×&6Ò&6Ñ&8Ô&8ð Kð K™
˜˜UØEJ˜Ð(A¸CÐ(AÐ(AÑBÐBØ!0�Jà!%×!5Ò!5Ñ!7Ô!7�å�~Ñ&Ô&¨Ò*Ð*Ý$ðuñô ð ð "0°Ô!2�à&*Ô&6°~Ô&FÐ#Ø#×3Ò3°NÑCÔCÐCð ÐØ&×1Ò1Ñ3Ô3ˆJõ %ð 	3Ý #¤	Ô 8Ô Lð 3ð 3‘�	˜1Ø&˜Y zÑ2Ô2�
�
ð Ô'Ð3Ø"Ô:ð /ð /�
Ø §¢Ñ!2Ô!2Ð2Ð2Ø" :Ð.øØñ +	õ Ô*­4Ñ0Ô0ˆDØ *× 0Ò 0Ñ 2Ô 2ð 2ð 2‘��fõ ˜f¥e¤lÑ3Ô3ð 2ØÕ*¨6Ñ2Ô2Ô3×:Ò:¸4Ñ@Ô@Ð@Ð@ð �˜F™œÔ$×+Ò+¨DÑ1Ô1Ð1Ð1ð XÐW¸¿
º
¹¼ÐWÑWÔWˆKÝ™œˆJØ$×+Ò+Ñ-Ô-ð 1ð 1�ð Ô*Ð6Ø�EÝ & u¡¤ð 5ð 5˜Ý*-Ð-fÐ-fÐ-fÐ-fÈdÔNeÐ-fÑ-fÔ-fÑ*fÔ*f˜Ø*ð 5¨t°zÐ/AÐ/AØ! Q™J˜EØ$¥s¨5¡z¤zÒ1Ð1Ø$.¨tÐ$4øð �Ø!ð 1ð 1�DØ˜zÐ)Ð)Ø ™
˜Ø  1š9˜9Ø *¨4Ð 0Ø&ŸNšN¨4Ñ0Ô0Ð0øð1õ �:‰Œ Ò"Ð"Ý×#Ò#ð e¨Zð  eð  eð  eñô ð ð
 &ð 	eØ0BÐTÕ,Ð,ÍˆLÝ'¨°gÑ>Ô>ˆLˆLà8JÐdÕ4Ð4ÕPdˆLå(¨ÀNÐamÐnÑnÔn‰ˆ�õ œ
 >Ñ2Ô2ð 	)ñ 	)ˆHÝœGŸLšL¨¸ÑBÔBˆMð !-× 4Ò 4°V¸RÑ @Ô @× HÒ HÈÐY[Ñ \Ô \Ðð "*×!1Ò!1°&¸"Ñ!=Ô!=×!EÒ!EÀnÐVXÑ!YÔ!YÐÝ”*Ð4Ñ5Ô5ˆCð ×#Ò#Ð$5Ñ6Ô6ð)å”G—N’N =Ñ1Ô1ð)ð  F§K¢K¡M¤MÐ1Ð1Ø#ð 2à—M’MÐ"4Ñ5Ô5ÐAå”	˜-Ñ(Ô(Ð(ùð "(§¢¡¤ð 	Oð 	OÑˆJ˜Ø!ð Oõ ˜u¥b¤g§l¢l°>À:Ñ&NÔ&NÐZbÐdhÐYiÐjÑjÔjÐjÐjà�˜e¥R¤W§\¢\°.À*Ñ%MÔ%MÑNÔNÐNÐNàˆ=Ý œgŸlšl¨>½<ÍÐV]Ñ;^Ô;^Ñ_Ô_ˆOÝ�KŠKÐC°/ÐCÐCÑDÔDÐDÐDà9KÐcÕ5Ð5ÕQcˆOÝ œgŸlšl¨>½<ÈÐY`Ñ;aÔ;aÑbÔbˆOå�o s°WÐ=Ñ=Ô=ð !ÀÝœ* U°1ÀÐEÑEÔEÈÑL�Ø—’˜Ñ Ô Ð ð!ð !ð !ñ !ô !ð !ð !ð !ð !ð !ð !øøøð !ð !ð !ð !õ �KŠKð7È^ð 7ð 7Ý ™KœKð7ð 7à$3ð7ð 7ð 7ñô ð ð ð 	Ø×'Ò'ØØØ Ø-Øð (ñ ô ð ð ð ð	ð 	s   ß90`5à5`9à<`9c                 óÀ   — t          d„ |                      ¦   «         D ¦   «         ¦  «        }|r0t          d„ |                      ¦   «         D ¦   «         ¦  «        }||z   }|S )a  
        Get the memory footprint of a model. This will return the memory footprint of the current model in bytes.
        Useful to benchmark the memory footprint of the current model and design some tests. Solution inspired from the
        PyTorch discussions: https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822/2

        Arguments:
            return_buffers (`bool`, *optional*, defaults to `True`):
                Whether to return the size of the buffer tensors in the computation of the memory footprint. Buffers
                are tensors that do not require gradients and not registered as parameters. E.g. mean and std in batch
                norm layers. Please see: https://discuss.pytorch.org/t/what-pytorch-means-by-buffers/120266/2
        c                 ó`   — g | ]+}|                      ¦   «         |                     ¦   «         z  ‘Œ,S rm   ©ÚnelementÚelement_size)rˆ   rŽ  s     ro   r‹   z8PreTrainedModel.get_memory_footprint.<locals>.<listcomp>´  s3   € ÐZÐZÐZ¸u�5—>’>Ñ#Ô# e×&8Ò&8Ñ&:Ô&:Ñ:ÐZÐZÐZrn   c                 ó`   — g | ]+}|                      ¦   «         |                     ¦   «         z  ‘Œ,S rm   r  )rˆ   Úbufs     ro   r‹   z8PreTrainedModel.get_memory_footprint.<locals>.<listcomp>¶  s1   € ÐZÐZÐZÀC˜CŸLšL™NœN¨S×-=Ò-=Ñ-?Ô-?Ñ?ÐZÐZÐZrn   )rð  r—   r¯   )r¯  Úreturn_buffersr£  Úmem_bufss       ro   Úget_memory_footprintz$PreTrainedModel.get_memory_footprint¨  sd   € õ ÐZÐZÈÏÊÑHYÔHYÐZÑZÔZÑ[Ô[ˆØð 	!ÝÐZÐZÈ4Ï<Ê<É>Ì>ÐZÑZÔZÑ[Ô[ˆHØ˜‘.ˆCØˆ
rn   c                 ó’   •— t          | dd ¦  «        t          j        k    rt          d¦  «        ‚ t	          ¦   «         j        |i |¤ŽS )NÚquantization_methodzÈCalling `cuda()` is not supported for `4-bit` or `8-bit` quantized models. Please use the model as it is, since the model has already been set to the correct devices and casted to the correct `dtype`.)r[  rN   ÚBITS_AND_BYTESr·   r  r8  )r¯  rS  r¡  r  s      €ro   r8  zPreTrainedModel.cudaº  sV   ø€ õ �4Ð.°Ñ5Ô5Õ9KÔ9ZÒZÐZÝðhñô ð ð
  •5‘7”7”< Ð0¨Ð0Ð0Ð0rn   c                 óJ  •— t          | dd ¦  «        t          j        k    rt          d¦  «        ‚t          | dd ¦  «        t          j        k    r=d}d|vr$|D ] }t          |t          j        ¦  «        rd} nŒ!nd}|rt          d¦  «        ‚ t          ¦   «         j	        |i |¤ŽS )Nr&  zÀ`.to` is not supported for `4-bit` or `8-bit` bitsandbytes models. Please use the model as it is, since the model has already been set to the correct devices and casted to the correct `dtype`.Fr¥   Tz«You cannot cast a GPTQ model in a new `dtype`. Make sure to load the model using `from_pretrained` using the desired `dtype` by passing the correct `torch_dtype` argument.)
r[  rN   r'  r·   ÚGPTQrÒ   rf   r¥   r  rm  )r¯  rS  r¡  Údtype_present_in_argsÚargr  s        €ro   rm  zPreTrainedModel.toÅ  sã   ø€ õ �4Ð.°Ñ5Ô5Õ9KÔ9ZÒZÐZÝðhñô ð õ �TÐ0°$Ñ7Ô7Õ;MÔ;RÒRÐRð %*Ð!à˜fÐ$Ð$Øð ð �CÝ! #¥u¤{Ñ3Ô3ð Ø04Ð-Ø˜ðøð )-Ð%à$ð Ý ðNñô ð ð �u‰wŒwŒz˜4Ð* 6Ð*Ð*Ð*rn   c                 óp   •— t          | dd¦  «        rt          d¦  «        ‚ t          ¦   «         j        |Ž S )Nr‹  FzŽ`.half()` is not supported for quantized model. Please use the model as it is, since the model has already been casted to the correct `dtype`.)r[  r·   r  Úhalf©r¯  rS  r  s     €ro   r-  zPreTrainedModel.halfá  sD   ø€ å�4˜¨Ñ/Ô/ð 	'ÝðIñô ð ð
  •5‘7”7”< Ð&Ð&rn   c                 óp   •— t          | dd¦  «        rt          d¦  «        ‚ t          ¦   «         j        |Ž S )Nr‹  Fz�`.float()` is not supported for quantized model. Please use the model as it is, since the model has already been casted to the correct `dtype`.)r[  r·   r  r¬   r.  s     €ro   r¬   zPreTrainedModel.floatë  sD   ø€ å�4˜¨Ñ/Ô/ð 	(ÝðIñô ð ð
 !•5‘7”7”= $Ð'Ð'rn   Úmain)r×  Ú	cache_dirÚignore_mismatched_sizesÚforce_downloadÚlocal_files_onlyrÌ  ÚrevisionÚuse_safetensorsÚpretrained_model_name_or_pathr1  r2  r3  r4  r5  r6  c                óB  ‡]‡^‡_‡`— |                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      d	d¦  «        }|                      d
d¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        Š`|                      dd¦  «        }|                      dd¦  «        Š]|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        } |                      dd¦  «        }!|                      di ¦  «        }"|                      dd¦  «        }#|                      d d¦  «        }$t          ¦   «         rd}|�-t          j        d!t          ¦  «         |�t          d"¦  «        ‚|}|�|"�	d#|"vr||"d#<   |	€t          ¦   «         sd}	t          ¦   «         rHt          j	        t          j                             d$¦  «        ¦  «        t          j	        d%¦  «        k    }%nd}%|du rt                               d&¦  «         | €Wt          |t          ¦  «        s1t!          |t"          ||||||||dd¬'¦  «        }&t%          |&| ¦  «        } nt'          |dd¦  «        } t)          ¦   «         r”|"                      d(d¦  «        }'|'€t+          |f|||||| d)œ|"¤Ž}'|'�et,          j                             |'¦  «        rFt3          |'d*d+¬,¦  «        5 }(|}'t5          j        |(¦  «        d-         }ddd¦  «         n# 1 swxY w Y   nd}'t          ‰]t8          j        ¦  «        rd‰]iŠ]n€t          ‰]t<          ¦  «        r=‰]d.vr9	 dt9          j        ‰]¦  «        iŠ]nO# t>          $ r t          d/‰]› d0�¦  «        ‚w xY wt          ‰]t@          ¦  «        r‰]d1k     rt          d2¦  «        ‚d‰]iŠ]‰]�|€d}n|st          d3¦  «        ‚|rK‰]�tC          d4¦  «         tE          ¦   «         rt          d5¦  «        ‚tG          ¦   «         stI          d6¦  «        ‚d})|�:t'          |d7tJ          j&        ¦  «        })|)tJ          j'        k    rt          d8¦  «        ‚|€+|s|r'tJ          j&        })tQ          j)        d·||d9œdd:œ|¤Ž\  }}n^|)tJ          j&        k    rN|j*        }|j+        }d;„ | ,                    ¦   «         D ¦   «         }*t[          |*¦  «        d1k    rt          d<¦  «        ‚|s|rØtG          ¦   «         rt          ¦   «         stI          d=¦  «        ‚‰`€*t           .                    d>‰`› d?�¦  «         t8          j/        Š`‰]€lt8          j0         1                    ¦   «         r!dt8          j0         2                    ¦   «         iŠ]nt?          d@¦  «        ‚t           .                    dA¦  «         |€d}|s|rt          dB¦  «        ‚dCdD|dEœ}+|�||+dF<   tg          ¦   «         r|st           .                    dG¦  «         d}t          |t          ¦  «        s)|�|n|}, | j4        j5        |,f|d|||||||||dHœ|¤Ž\  }}-n|}-d}.d}/tm          |d¦  «        r%|j7         8                    d7tJ          j&        ¦  «        }/|/tJ          j9        k    rV|)�T| :                    ¦   «         }0|0 ,                    ¦   «         D ]\  }1}2|2|j7        |1<   Œd})t                               dI¦  «         |)tJ          j9        k    s|/tJ          j9        k    �rt          j	        t          j                             dJ¦  «        ¦  «        t          j	        dK¦  «        k    }3|3s-t8          j0         1                    ¦   «         st?          dL¦  «        ‚tw          ¦   «         rty          ¦   «         stI          dM¦  «        ‚t          j	        t          j                             dN¦  «        ¦  «        t          j	        dK¦  «        k     rtI          dO¦  «        ‚d1dPl=m>}4 |/tJ          j9        k    r t          j)        |j7        ¦  «        }||_7        ‰`€t8          j/        Š`nt           .                    dQ¦  «         |4 )                    | @                    ¦   «         ¦  «        }.�n|/tJ          j'        k    �rt8          j0         1                    ¦   «         st?          dR¦  «        ‚tƒ          ¦   «         stI          dS¦  «        ‚tG          ¦   «         stI          dT¦  «        ‚‰]€t                               dU¦  «         nR‰]�Pt          ‰]t„          ¦  «        r;dV‰] C                    ¦   «         v sdW‰] C                    ¦   «         v rt          dX¦  «        ‚‰`€t8          j/        Š`nt           .                    dY¦  «         |€d}|%rE|)tJ          j&        k    r5|r3|/tJ          j&        k    rt                               dZ¦  «         ||_7        �n2|%�r|sÿ|/tJ          j&        k    rï|j7        }t          |t„          ¦  «        rtQ          j)        |d¬[¦  «        }n6t          |tP          ¦  «        rn t          d\t‰          |¦  «        › d]�¦  «        ‚|j*        }|r|‰`€t8          j/        Š`‰]€lt8          j0         1                    ¦   «         r!dt8          j0         2                    ¦   «         iŠ]nt?          d@¦  «        ‚t           .                    dA¦  «         |€d}n.|%s,|s*|/tJ          j&        k    rt                               d^¦  «         d}5d}6d}7dŠ^d}8|��÷t=          |¦  «        }t,          j         E                    |¦  «        }9|9�r|rqt,          j                             t,          j         F                    ||tŽ          d_z   ¦  «        ¦  «        r+t,          j         F                    ||tŽ          d_z   ¦  «        }:�n|rkt,          j                             t,          j         F                    ||t�          ¦  «        ¦  «        r(t,          j         F                    ||t�          ¦  «        }:�n£|rkt,          j                             t,          j         F                    ||t’          ¦  «        ¦  «        r(t,          j         F                    ||t’          ¦  «        }:�n6|	dur‡t,          j                             t,          j         F                    ||t•          t–          |!¦  «        ¦  «        ¦  «        r6t,          j         F                    ||t•          t–          |!¦  «        ¦  «        }:�n«|	dur‰t,          j                             t,          j         F                    ||t•          t˜          |!¦  «        ¦  «        ¦  «        r8t,          j         F                    ||t•          t˜          |!¦  «        ¦  «        }:d}5�nt,          j                             t,          j         F                    ||t•          tš          |!¦  «        ¦  «        ¦  «        r6t,          j         F                    ||t•          tš          |!¦  «        ¦  «        }:�n—t,          j                             t,          j         F                    ||t•          tœ          |!¦  «        ¦  «        ¦  «        r8t,          j         F                    ||t•          tœ          |!¦  «        ¦  «        }:d}5�nt,          j                             t,          j         F                    ||tŽ          d_z   ¦  «        ¦  «        sCt,          j                             t,          j         F                    ||t�          ¦  «        ¦  «        r)tŸ          d`t•          tš          |!¦  «        › da|› db�¦  «        ‚t,          j                             t,          j         F                    ||t’          ¦  «        ¦  «        r)tŸ          d`t•          tš          |!¦  «        › da|› dc�¦  «        ‚|	r)tŸ          d`t•          t–          |!¦  «        › da|› d0�¦  «        ‚tŸ          d`t•          tš          |!¦  «        › ddt�          › ddtŽ          d_z   › det’          › da|› d0�¦  «        ‚t,          j                             t,          j         F                    ||¦  «        ¦  «        r|}:d}9�n>t,          j                             t,          j         F                    ||d_z   ¦  «        ¦  «        r?|st          df|d_z   › dg�¦  «        ‚t,          j         F                    ||d_z   ¦  «        }:d}9�n¿t¡          |¦  «        r|};t£          |¦  «        }<�n�|rt�          };n9|rt’          };n/|	durt•          t–          |!¦  «        };nt•          tš          |!¦  «        };	 |||||||+||d| dhœ}=t!          ||;fi |=¤Ž}<|<€ |;t•          t–          |!¦  «        k    r‡t!          |t•          t˜          |!¦  «        fi |=¤Ž}<|<�d}5na|	r<tŸ          dit•          t–          |!¦  «        › det•          t˜          |!¦  «        › dj�¦  «        ‚t•          tš          |!¦  «        };t!          ||;fi |=¤Ž}<|<€>|;t•          tš          |!¦  «        k    r%t!          |t•          tœ          |!¦  «        fi |=¤Ž}<|<�d}5|<€ü|||dkœ}>t¥          |t�          fi |>¤Žr(tŸ          |› dlt•          tš          |!¦  «        › db�¦  «        ‚t¥          |t’          fi |>¤Žr(tŸ          |› dlt•          tš          |!¦  «        › dc�¦  «        ‚|!�>t¥          |tš          fi |>¤Žr+tŸ          |› dlt•          tš          |!¦  «        › dm|!› dn�¦  «        ‚tŸ          |› dlt•          tš          |!¦  «        › ddt�          › ddtŽ          › det’          › d0�
¦  «        ‚n\# tž          $ r ‚ t¦          $ rE tŸ          do|› dp|› dqt•          tš          |!¦  «        › ddt�          › ddtŽ          › det’          › d0�¦  «        ‚w xY w|9r t           .                    dr|:› �¦  «         |:}<n#t           .                    dr|;› ds|<› �¦  «         nd}<|5rt©          ||<|||||||+||| ¬t¦  «        \  }<}6t          ¦   «         �rt          |<t<          ¦  «        rý|< U                    du¦  «        rèt­          |<dv¬w¦  «        5 }(|(                     ¦   «         }?ddd¦  «         n# 1 swxY w Y   |? 8                    dx¦  «        dvk    rn‘|? 8                    dx¦  «        dyk    rd}t           .                    dz¦  «         n[|? 8                    dx¦  «        d{k    rd}t           .                    d|¦  «         n%t          d}|? 8                    dx¦  «        › �¦  «        ‚||z   }@|@�rT|5s|€t¯          |<¦  «        }d}A‰`�àt          ‰`t<          ¦  «        r¶‰`d~k    ržtm          |d¦  «        r-|jX        �&|jX        Š`t           .                    d‰`› d€�¦  «         ns|5rd�|6v r	|6d�         Š`n7|5st³          |¦  «        Š`n%t¯          |<d1         ¦  «        }Bt³          |B¦  «        Š`~Bt           .                    d‚¦  «         nt          dƒ‰`› �¦  «        ‚|  Z                    ‰`¦  «        }A| j[        duo‰`t8          j/        k    p|p|}8|5r	|6d„         }Cn!t¹          | ]                    ¦   «         ¦  «        }C|s|8rtG          ¦   «         rd}||_^        t¿          |¬…¦  «        g}DtE          ¦   «         rJd1dl`}Et           .                    d†¦  «         |Eja         b                    tÇ          ¦   «         ¬‡¦  «        g|Dz   }Dn'|s|s|r!|D d                    tË          ¦   «         ¦  «         |$r|  f                    |‰`‰]¬ˆ¦  «        }tÏ          |D¦  «        5   | |g|
¢R i |-¤Ž}Fddd¦  «         n# 1 swxY w Y   |Fjh        }|8rtG          ¦   «         rd}|Fj[        Š^ng Š^|s|�rÝd‰dŠlimj}Gmk}H |jl        }I|jm        }J|rt           .                    d‹¦  «         nt           .                    dŒ¦  «         |I€ |G|F¦  «        Š_n|IŠ_t          ‰_t¸          ¦  «        s‰_gŠ_‰_ n                    ‰^¦  «         t          ‰]t„          ¦  «        r|t[          ‰] ]                    ¦   «         ¦  «        d‰k    rWd�„ ‰] ,                    ¦   «         D ¦   «         }Kt[          |K¦  «        d1k    r|Jst          dŽ¦  «        ‚‰_ n                    |K¦  «         t          j	        t          j                             d$¦  «        ¦  «        t          j	        d�¦  «        k    }L|r|Lst          d�¦  «        ‚ |H|F‰_|¬‘¦  «        }Ft          j	        t          j                             d$¦  «        ¦  «        t          j	        d’¦  «        k    |F_o        ||_7        |%|F_p        |r‰`€t                               d“¦  «         |/tJ          j9        k    r|. q                    |F¦  «        }Fd|F_o        nr|/tJ          j'        k    rbd‰d”limj}Gmr}M  |G|F¦  «        Š_|€tç          j)        |j7        ¦  «        } |M|F|‰_¬•¦  «        \  }F}Nd|F_o        |Nst                               d–¦  «         |/�|/|F_t        n	|)�|)|F_t        tm          |Fd—¦  «        rd|F_u        ‰`|_v        t          ‰]t<          ¦  «        �rXi }O|s|r4|O w                    ˆ_ˆ`fd˜„|F x                    ¦   «         D ¦   «         ¦  «         |O w                    ˆ^fd™„|F x                    ¦   «         D ¦   «         ¦  «         ‰`}P|rdt          j	        t          j                             dš¦  «        ¦  «        t          j	        d›¦  «        k    rd1dœlymz}Q |Qj{        }Pnt          d�¦  «        ‚|rt8          j|        }P|F }                    ‰]¦  «        }R‰]d.vrt          dž¦  «        ‚dŸ|Ri}Sd tý          j        �t           ¦  «        j�        v r|O|Sd <   n-t[          |O¦  «        d1k    rt                               d¡¦  «         ‰]d¢k    r�t          |Ff|P‰]d£k    |d¤œ|S¤Ž}n�t          |¦  «        }t'          |Fd—d¦  «        tJ          j&        k    rd¥„ | ,                    ¦   «         D ¦   «         }||Sd<   |F „                    ¦   «          �t          |Ffd�|Pi|S¤ŽŠ]|s|r]ˆ]ˆ_fd¦„‰] ]                    ¦   «         D ¦   «         }TdV|T C                    ¦   «         v sdW|T C                    ¦   «         v rt          d§¦  «        ‚~Tn7‰]�5|F „                    ¦   «          �t          |F¦  «        }U�t          |U‰]¦  «         |rx|< U                    d_¦  «        r |  ‡                    |F||<dd¨…         ¦  «        }Fnâ	 d‰d©lˆm‰}V  |V|F|<dd¬ª¦  «        \  }F}7nÈ# tH          $ r t           Š                    d«¦  «         ‚ w xY w|r=	 d‰d¬l‹mŒ}W  |W|F|<¦  «        }Fn‰# tH          $ r t           Š                    d­¦  «         ‚ w xY w|@r^|A�t9          j�        |A¦  «         |  Ž                    |F||C|<|||6||‰]||‰`t'          |Fd—d¦  «        tJ          j&        k    ‰^¬®¦  «        \  }F}X}Y}Z}[}\||F_�        ||F_�        |F „                    ¦   «          |F ‘                    ¦   «          |F ’                    ¦   «         rR|�P	 �t'          j5        |f||||||||||d¯œ
|¤Ž|F_”        n+# �t*          $ r t           .                    d°¦  «         Y nw xY w‰]�?‰]||[d±œ}Sd²tý          j        �t,          ¦  «        j�        v r
|Fj—        |Sd²<   �t-          |Ffi |S¤Ž |)tJ          j9        k    ru|j˜        €||_˜        | j™        d³k    rt?          d´¦  «        ‚|. š                    |F|j˜        ¦  «         t          j›        |. œ                    ¦   «         ¦  «        |_7        d|F_o        |/tJ          j9        k    r|. �                    |F¦  «        }F|'�|F ž                    |'|#||"¬µ¦  «         |r|7€|X|Y|Z|\d¶œ}7|F|7fS |FS )¸aì<  
        Instantiate a pretrained pytorch model from a pre-trained model configuration.

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

        The warning *Weights from XXX not initialized from pretrained model* means that the weights of XXX do not come
        pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tuning
        task.

        The warning *Weights from XXX not used in YYY* means that the layer XXX is not used by YYY, therefore those
        weights are discarded.

        Parameters:
            pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*):
                Can be either:

                    - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
                      Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
                      user or organization name, like `dbmdz/bert-base-german-cased`.
                    - A path to a *directory* containing model weights saved using
                      [`~PreTrainedModel.save_pretrained`], e.g., `./my_model_directory/`.
                    - A path or url to a *tensorflow index checkpoint file* (e.g, `./tf_model/model.ckpt.index`). In
                      this case, `from_tf` should be set to `True` and a configuration object should be provided as
                      `config` argument. This loading path is slower than converting the TensorFlow checkpoint in a
                      PyTorch model using the provided conversion scripts and loading the PyTorch model afterwards.
                    - A path or url to a model folder containing a *flax checkpoint file* in *.msgpack* format (e.g,
                      `./flax_model/` containing `flax_model.msgpack`). In this case, `from_flax` should be set to
                      `True`.
                    - `None` if you are both providing the configuration and state dictionary (resp. with keyword
                      arguments `config` and `state_dict`).
            model_args (sequence of positional arguments, *optional*):
                All remaining positional arguments will be passed to the underlying model's `__init__` method.
            config (`Union[PretrainedConfig, str, os.PathLike]`, *optional*):
                Can be either:

                    - an instance of a class derived from [`PretrainedConfig`],
                    - a string or path valid as input to [`~PretrainedConfig.from_pretrained`].

                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 (`Union[str, 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.
            from_tf (`bool`, *optional*, defaults to `False`):
                Load the model weights from a TensorFlow checkpoint save file (see docstring of
                `pretrained_model_name_or_path` argument).
            from_flax (`bool`, *optional*, defaults to `False`):
                Load the model weights from a Flax checkpoint save file (see docstring of
                `pretrained_model_name_or_path` argument).
            ignore_mismatched_sizes (`bool`, *optional*, defaults to `False`):
                Whether or not to raise an error if some of the weights from the checkpoint do not have the same size
                as the weights of the model (if for instance, you are instantiating a model with 10 labels from a
                checkpoint with 3 labels).
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force the (re-)download of the model weights and configuration files, overriding the
                cached versions if they exist.
            resume_download (`bool`, *optional*, defaults to `False`):
                Whether or not to delete incompletely received files. Will attempt to resume the download if such a
                file exists.
            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 ot 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 (i.e., do not try to download the model).
            token (`str` or `bool`, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, 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.

                <Tip>

                To test a pull request you made on the Hub, you can pass `revision="refs/pr/<pr_number>".

                </Tip>

            mirror (`str`, *optional*):
                Mirror source to accelerate downloads in China. If you are from China and have an accessibility
                problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety.
                Please refer to the mirror site for more information.
            _fast_init(`bool`, *optional*, defaults to `True`):
                Whether or not to disable fast initialization.

                <Tip warning={true}>

                One should only disable *_fast_init* to ensure backwards compatibility with `transformers.__version__ <
                4.6.0` for seeded model initialization. This argument will be removed at the next major version. See
                [pull request 11471](https://github.com/huggingface/transformers/pull/11471) for more information.

                </Tip>

            > Parameters for big model inference

            low_cpu_mem_usage(`bool`, *optional*):
                Tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model.
                This is an experimental feature and a subject to change at any moment.
            torch_dtype (`str` or `torch.dtype`, *optional*):
                Override the default `torch.dtype` and load the model under a specific `dtype`. The different options
                are:

                1. `torch.float16` or `torch.bfloat16` or `torch.float`: load in a specified
                  `dtype`, ignoring the model's `config.torch_dtype` if one exists. If not specified
                  - the model will get loaded in `torch.float` (fp32).

                2. `"auto"` - A `torch_dtype` entry in the `config.json` file of the model will be
                  attempted to be used. If this entry isn't found then next check the `dtype` of the first weight in
                  the checkpoint that's of a floating point type and use that as `dtype`. This will load the model
                  using the `dtype` it was saved in at the end of the training. It can't be used as an indicator of how
                  the model was trained. Since it could be trained in one of half precision dtypes, but saved in fp32.

                <Tip>

                For some models the `dtype` they were trained in is unknown - you may try to check the model's paper or
                reach out to the authors and ask them to add this information to the model's card and to insert the
                `torch_dtype` entry in `config.json` on the hub.

                </Tip>

            device_map (`str` or `Dict[str, Union[int, str, torch.device]]` or `int` or `torch.device`, *optional*):
                A map that specifies where each submodule should go. It doesn't need to be refined to each
                parameter/buffer name, once a given module name is inside, every submodule of it will be sent to the
                same device. If we only pass the device (*e.g.*, `"cpu"`, `"cuda:1"`, `"mps"`, or a GPU ordinal rank
                like `1`) on which the model will be allocated, the device map will map the entire model to this
                device. Passing `device_map = 0` means put the whole model on GPU 0.

                To have Accelerate compute the most optimized `device_map` automatically, set `device_map="auto"`. For
                more information about each option see [designing a device
                map](https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map).
            max_memory (`Dict`, *optional*):
                A dictionary device identifier to maximum memory. Will default to the maximum memory available for each
                GPU and the available CPU RAM if unset.
            offload_folder (`str` or `os.PathLike`, *optional*):
                If the `device_map` contains any value `"disk"`, the folder where we will offload weights.
            offload_state_dict (`bool`, *optional*):
                If `True`, will temporarily offload the CPU state dict to the hard drive to avoid getting out of CPU
                RAM if the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to
                `True` when there is some disk offload.
            load_in_8bit (`bool`, *optional*, defaults to `False`):
                If `True`, will convert the loaded model into mixed-8bit quantized model. To use this feature please
                install `bitsandbytes` (`pip install -U bitsandbytes`).
            load_in_4bit (`bool`, *optional*, defaults to `False`):
                If `True`, will convert the loaded model into 4bit precision quantized model. To use this feature
                install the latest version of `bitsandbytes` (`pip install -U bitsandbytes`).
            quantization_config (`Union[QuantizationConfigMixin,Dict]`, *optional*):
                A dictionary of configuration parameters or a QuantizationConfigMixin object for quantization (e.g
                bitsandbytes, gptq)
            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.
            variant (`str`, *optional*):
                If specified load weights from `variant` filename, *e.g.* pytorch_model.<variant>.bin. `variant` is
                ignored when using `from_tf` or `from_flax`.
            use_safetensors (`bool`, *optional*, defaults to `None`):
                Whether or not to use `safetensors` checkpoints. Defaults to `None`. If not specified and `safetensors`
                is not installed, it will be set to `False`.

            kwargs (remaining dictionary of 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.

        <Tip>

        Activate the special ["offline-mode"](https://huggingface.co/transformers/installation.html#offline-mode) to
        use this method in a firewalled environment.

        </Tip>

        Examples:

        ```python
        >>> from transformers import BertConfig, BertModel

        >>> # Download model and configuration from huggingface.co and cache.
        >>> model = BertModel.from_pretrained("bert-base-uncased")
        >>> # Model was saved using *save_pretrained('./test/saved_model/')* (for example purposes, not runnable).
        >>> model = BertModel.from_pretrained("./test/saved_model/")
        >>> # Update configuration during loading.
        >>> model = BertModel.from_pretrained("bert-base-uncased", output_attentions=True)
        >>> assert model.config.output_attentions == True
        >>> # Loading from a TF checkpoint file instead of a PyTorch model (slower, for example purposes, not runnable).
        >>> config = BertConfig.from_json_file("./tf_model/my_tf_model_config.json")
        >>> model = BertModel.from_pretrained("./tf_model/my_tf_checkpoint.ckpt.index", from_tf=True, config=config)
        >>> # Loading from a Flax checkpoint file instead of a PyTorch model (slower)
        >>> model = BertModel.from_pretrained("bert-base-uncased", from_flax=True)
        ```

        * `low_cpu_mem_usage` algorithm:

        This is an experimental function that loads the model using ~1x model size CPU memory

        Here is how it works:

        1. save which state_dict keys we have
        2. drop state_dict before the model is created, since the latter takes 1x model size CPU memory
        3. after the model has been instantiated switch to the meta device all params/buffers that
        are going to be replaced from the loaded state_dict
        4. load state_dict 2nd time
        5. replace the params/buffers from the state_dict

        Currently, it can't handle deepspeed ZeRO stage 3 and ignores loading errors

        r¹   NÚfrom_tfFÚ	from_flaxÚresume_downloadÚproxiesÚoutput_loading_inforÏ  Útrust_remote_codeÚmirrorÚ_from_pipelineÚ
_from_autoÚ
_fast_initTr  Úlow_cpu_mem_usager†  Ú
max_memoryr‡  Úoffload_state_dictÚload_in_8bitÚload_in_4bitÚquantization_configÚ	subfolderr6  Ú_commit_hashr”  Úadapter_kwargsÚadapter_nameÚdefaultÚuse_flash_attention_2rÐ  rÑ  rÌ  rí  z0.37.2zgThe argument `trust_remote_code` is to be used with Auto classes. It has no effect here and is ignored.)
r1  r3  r;  r<  r4  rÌ  r5  rI  Ú%_raise_exceptions_for_missing_entriesÚ'_raise_exceptions_for_connection_errorsÚ_adapter_model_path)r1  r3  r;  r<  r4  rJ  ré   rê   rë   Úbase_model_name_or_path)ÚautoÚbalancedÚbalanced_low_0Ú
sequentialzœWhen passing device_map as a string, the value needs to be a device name (e.g. cpu, cuda:0) or 'auto', 'balanced', 'balanced_low_0', 'sequential' but found r¾   r   znYou can't pass device_map as a negative int. If you want to put the model on the cpu, pass device_map = 'cpu' z>Passing along a `device_map` requires `low_cpu_mem_usage=True`ztorch>=1.10z`DeepSpeed Zero-3 is not compatible with `low_cpu_mem_usage=True` or with passing a `device_map`.z^Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install accelerate`Úquant_methoda   You cannot pass an `AwqConfig` when loading a model as you can only use AWQ models for inference. To quantize transformers models with AWQ algorithm, please refer to our quantization docs: https://huggingface.co/docs/transformers/main_classes/quantization )rF  rG  )Úconfig_dictÚreturn_unused_kwargsc                 óZ   — i | ](\  }}|t          j        t          ¦  «        j        v ¯%||“Œ)S rm   )r‚  rƒ  rL   r—   r‡   s      ro   rÞ  z3PreTrainedModel.from_pretrained.<locals>.<dictcomp>Ž
  s>   € ð *ð *ð *Ù˜˜A°1½Ô8IÕJ\Ñ8]Ô8]Ô8hÐ3hÐ3h��1Ð3hÐ3hÐ3hrn   z‘You can't pass `load_in_8bit` or any other `BitsAndBytesConfig` argument as a kwarg when passing `quantization_config` argument at the same time.zÈUsing `load_in_8bit=True` requires Accelerate: `pip install accelerate` and the latest version of bitsandbytes `pip install -i https://test.pypi.org/simple/ bitsandbytes` or pip install bitsandbytes` zOverriding torch_dtype=zþ with `torch_dtype=torch.float16` due to requirements of `bitsandbytes` to enable model loading in 8-bit or 4-bit. Pass your own torch_dtype to specify the dtype of the remaining non-linear layers or pass torch_dtype=torch.float16 to remove this warning.z/No GPU found. A GPU is needed for quantization.z¦The device_map was not initialized. Setting device_map to {'':torch.cuda.current_device()}. If you want to use the model for inference, please set device_map ='auto' z‹Converting into 4-bit or 8-bit weights from tf/flax weights is currently not supported, please make sure the weights are in PyTorch format.r  Úpytorch)Ú	file_typer&  Úfrom_auto_classÚusing_pipelinez+Offline mode: forcing local_files_only=True)r1  rY  r3  r;  r<  r4  rÌ  r5  rI  rA  r@  a_  You passed `quantization_config` to `from_pretrained` but the model you're loading already has a `quantization_config` attribute and has already quantized weights. However, loading attributes (e.g. use_exllama, exllama_config, use_cuda_fp16, max_input_length) will be overwritten with the one you passed to `from_pretrained`. The rest will be ignored.z	auto-gptqz0.4.2z2GPU is required to quantize or run quantize model.zwLoading a GPTQ quantized model requires optimum (`pip install optimum`) and auto-gptq library (`pip install auto-gptq`)Ú	auto_gptqzWYou need a version of auto_gptq >= 0.4.2 to use GPTQ: `pip install --upgrade auto-gptq`)ÚGPTQQuantizerzRWe suggest you to set `torch_dtype=torch.float16` for better efficiency with GPTQ.z+GPU is required to run AWQ quantized model.zPLoading an AWQ quantized model requires auto-awq library (`pip install autoawq`)zMLoading an AWQ quantized model requires accelerate (`pip install accelerate`)z�You have loaded an AWQ model on CPU and have a CUDA device available, make sure to set your model on a GPU device in order to run your model.rø   r|  z®You are attempting to load an AWQ model with a device_map that contains a CPU or disk device. This is not supported. Please remove the CPU or disk device from the device_map.zQWe suggest you to set `torch_dtype=torch.float16` for better efficiency with AWQ.zçYou passed `quantization_config` to `from_pretrained` but the model you're loading already has a `quantization_config` attribute. The `quantization_config` attribute will be overwritten with the one you passed to `from_pretrained`.)rY  z(Invalid type for `quantization_config`: z8. Should be a `dict` or a `BitsAndBytesConfig` instance.a  Detected the presence of a `quantization_config` attribute in the model's configuration but you don't have the correct `bitsandbytes` version to support int8 serialization. Please install the latest version of `bitsandbytes` with  `pip install --upgrade bitsandbytes`.z.indexzError no file named z found in directory zf but there is a file for TensorFlow weights. Use `from_tf=True` to load this model from those weights.zb but there is a file for Flax weights. Use `from_flax=True` to load this model from those weights.z, rè   z$We found a TensorFlow checkpoint at z:, please set from_tf to True to load from this checkpoint.)r1  r3  r<  r;  r4  rÌ  Ú
user_agentr5  rI  rO  rJ  ú z¢ and thus cannot be loaded with `safetensors`. Please make sure that the model has been saved with `safe_serialization=True` or do not set `use_safetensors=True`.)r5  r<  rÌ  z& does not appear to have a file named z) but there is a file without the variant z;. Use `variant=None` to load this model from those weights.zCan't load the model for 'zœ'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'z=' is the correct path to a directory containing a file named zloading weights file z from cache at )
r1  r3  r<  r;  r4  rÌ  ra  r5  rI  rJ  rÎ   r$  r%  r'  r(  zAA TensorFlow safetensors file is being loaded in a PyTorch model.r)  z;A Flax safetensors file is being loaded in a PyTorch model.zMIncompatible safetensors file. File metadata is not ['pt', 'tf', 'flax'] but rS  zWill use torch_dtype=z$ as defined in model's config objectr¥   z�Since the `torch_dtype` attribute can't be found in model's config object, will use torch_dtype={torch_dtype} as derived from model's weightszD`torch_dtype` can be either `torch.dtype` or `"auto"`, but received Úall_checkpoint_keys)r{   r   r!  )r  r†  r   )Úget_keys_to_not_convertÚreplace_with_bnb_linearz?Detected 8-bit loading: activating 8-bit loading for this modelz?Detected 4-bit loading: activating 4-bit loading for this modelc                 ó    — g | ]\  }}|d v ¯	|‘ŒS ))r|  rø   rm   )rˆ   rÜ   r{  s      ro   r‹   z3PreTrainedModel.from_pretrained.<locals>.<listcomp>È  s'   € ÐdÐdÐd¡z s¨EÈ5ÐTcÐKcÐKc˜sÐKcÐKcÐKcrn   z¹If you want to offload some keys to `cpu` or `disk`, you need to set `llm_int8_enable_fp32_cpu_offload=True`. Note that these modules will not be  converted to 8-bit but kept in 32-bit.z0.39.0zžYou have a version of `bitsandbytes` that is not compatible with 4bit inference and training make sure you have the latest version of `bitsandbytes` installed)Úmodules_to_not_convertrH  z0.37.0zòYou are loading your model in 8bit but you did not specify a `torch_dtype` attribute. All non-linear modules will be loaded in full precision. If you want to load the other modules in other precision, please specify a `torch_dtype` attribute.)rd  Úreplace_with_awq_linear)rH  rg  z²You are loading an AWQ model but no linear modules were found in your model. Please double check your model architecture, or submit an issue on github if you think this is a bug.r&  c                 óT   •‡— i | ]#\  Š}t          ˆfd „‰D ¦   «         ¦  «        ¯ ‰‰“Œ$S )c              3   ó    •K  — | ]}|‰v V — Œ	d S rý  rm   ©rˆ   rÄ  rU  s     €ro   rz  z=PreTrainedModel.from_pretrained.<locals>.<dictcomp>.<genexpr>  s'   øè è € ÐIÐI¨Q˜q D˜yÐIÐIÐIÐIÐIÐIrn   )r€  )rˆ   r  rU  rg  r  s     @€€ro   rÞ  z3PreTrainedModel.from_pretrained.<locals>.<dictcomp>  sT   øø€ ð ð ð á#˜D !ÝÐIÐIÐIÐIÐ2HÐIÑIÔIÑIÔIðØ˜kðð ð rn   c                 óh   •‡— i | ]-\  Š}t          ˆfd „‰D ¦   «         ¦  «        ¯ ‰t          j        “Œ.S )c              3   ó    •K  — | ]}|‰v V — Œ	d S rý  rm   rk  s     €ro   rz  z=PreTrainedModel.from_pretrained.<locals>.<dictcomp>.<genexpr>  s'   øè è € ÐCÐC¨˜1 ˜9ÐCÐCÐCÐCÐCÐCrn   )r€  rf   r®   )rˆ   r  rU  r�  s     @€ro   rÞ  z3PreTrainedModel.from_pretrained.<locals>.<dictcomp>  sV   øø€ ð ð ð á˜˜aÝÐCÐCÐCÐCÐ.BÐCÑCÔCÑCÔCðØ�%œ-ðð ð rn   Ú
acceleratez0.19.0)ÚCustomDtypeaW  You are using `device_map='auto'` on a 4bit loaded version of the model. To automatically compute the appropriate device map, you should upgrade your `accelerate` library, `pip install --upgrade accelerate` or install it from source to support fp4 auto device map calculation. You may encounter unexpected behavior, or pass your own device mapziIf passing a string for `device_map`, please choose 'auto', 'balanced', 'balanced_low_0' or 'sequential'.Úno_split_module_classesÚspecial_dtypesz¦This model has some weights that should be kept in higher precision, you need to upgrade `accelerate` to properly deal with them (`pip install --upgrade accelerate`).rV  rU  )r¥   Úlow_zerorD  c                 ó    — i | ]\  }}||d z  “ŒS )gÍÌÌÌÌÌì?rm   )rˆ   rÜ   Úvals      ro   rÞ  z3PreTrainedModel.from_pretrained.<locals>.<dictcomp>O  s"   € ÐQÐQÐQ±(°#°s˜c 3¨¡:ÐQÐQÐQrn   c                 ó*   •— i | ]}|‰v¯|‰|         “ŒS rm   rm   )rˆ   rÜ   r†  rg  s     €€ro   rÞ  z3PreTrainedModel.from_pretrained.<locals>.<dictcomp>X  s1   ø€ ð .ð .ð .Ø-0ÈÐTjÐIjÐIj�C˜ CœÐIjÐIjÐIjrn   ad  
                        Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to fit
                        the quantized model. If you want to dispatch the model on the CPU or the disk while keeping
                        these modules in 32-bit, you need to set `load_in_8bit_fp32_cpu_offload=True` and pass a custom
                        `device_map` to `from_pretrained`. Check
                        https://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between-cpu-and-gpu
                        for more details.
                        iúÿÿÿ)Ú$load_tf2_checkpoint_in_pytorch_model)Úallow_missing_keysr=  zÃLoading a TensorFlow model in PyTorch, requires both PyTorch and TensorFlow to be installed. Please see https://pytorch.org/ and https://www.tensorflow.org/install/ for installation instructions.)Ú%load_flax_checkpoint_in_pytorch_modelzËLoading a Flax model in PyTorch, requires both PyTorch and Flax to be installed. Please see https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation instructions.)
r2  Úsharded_metadatarB  rC  r†  r‡  rE  r¥   r‹  r�  )
r1  r3  r;  r<  r4  rÌ  r5  rI  rA  r@  zZGeneration config file not found, using a generation config created from the model config.)r†  Úoffload_dirrˆ  Ú	skip_keysr  z%We can only quantize pure text model.)rL  rÌ  rK  )r  r  Úmismatched_keysrW  rm   )ŸrZ  rp   rÄ  rÅ  rÆ  r·   r@   r:   r   r6  r7  rÐ   rÿ   r   rÒ   r   r2   r&   r5   r[  r>   rx   rj   rü   rþ   r  r  r  rf   r˜   r›   r  rt   rO   r   r7   r›  rN   r'  ÚAWQrL   Ú	from_dictrF  rG  r�   rÔ   r$  r�  r8  rh   Úcurrent_devicer<   Úconfig_classÚfrom_pretrainedrf  rH  rl   r)  Úget_loading_attributesr=   r9   Úoptimum.gptqr`  rM   Úto_dict_optimumr8   rM  r¶   rj  Úisdirrý   r,   r+   r(   r–  r*   r)   r.   r-   ÚEnvironmentErrorr?   r4   r6   r/  rF   r,  r_   r
  r  r¼   r#  Ú_keep_in_fp32_modulesr  rØ   r  r}   rL  rN  r%  r   rÕ   rU   r=  r/   r×  r  rd  re  Úllm_int8_skip_modulesÚ llm_int8_enable_fp32_cpu_offloadÚextendÚ_is_quantized_training_enabledrÓ  Úconvert_modelrh  rK   r&  r‹  Ú_pre_quantization_dtypeÚupdaterI  Úaccelerate.utilsro  ÚINT4r„  r€  r‚  rƒ  rT   r—   rY   rZ   r]  rX   rW   Úload_tf_weightsÚmodeling_tf_pytorch_utilsrv  ræ  Úmodeling_flax_pytorch_utilsrx  r&  Ú_load_pretrained_modelrì  rÒ  Úevalr  r   r  r-  rS   Ú_skip_keys_device_placementÚ	tokenizerrù  Úquantize_modelÚfrom_dict_optimumÚto_dictÚpost_init_modelÚload_adapter)ar'  r7  r×  r1  r2  r3  r4  rÌ  r5  r6  Ú
model_argsr¡  r¹   r9  r:  r;  r<  r=  rÏ  r>  r  Úfrom_pipeliner]  rB  rC  rD  r‡  rE  rF  rG  rH  rI  Úcommit_hashr”  rK  rL  rN  rÓ  Úresolved_config_filerQ  r  Úquantization_method_from_argsÚquantization_config_kwargsra  Úconfig_pathÚmodel_kwargsÚ	quantizerÚquantization_method_from_configÚloading_attr_dictÚattrrt  Úgptq_supports_cpur`  Ú
is_shardedry  Úloading_infoÚuse_keep_in_fp32_modulesÚis_localÚarchive_filer  Úresolved_archive_fileÚcached_file_kwargsÚhas_file_kwargsrÐ   Úfrom_ptr(  Úone_state_dictro  Úinit_contextsrL  r  rd  re  rˆ  Úload_in_8bit_fp32_cpu_offloadÚkeys_on_cpuÚsupports_4bitrh  Úhas_been_replacedrq  Útarget_dtypero  Úno_split_modulesÚdevice_map_kwargsÚdevice_map_without_lm_headÚtied_paramsrv  rx  r  r  r|  rˆ  rW  r†  r�  rg  r  sa                                                                                                @@@@ro   r�  zPreTrainedModel.from_pretrainedõ  sâ(  øøøø€ ðj —Z’Z ¨dÑ3Ô3ˆ
Ø—*’*˜Y¨Ñ.Ô.ˆØ—J’J˜{¨EÑ2Ô2ˆ	Ø Ÿ*š*Ð%6¸Ñ>Ô>ˆØ—*’*˜Y¨Ñ-Ô-ˆØ$ŸjšjÐ)>ÀÑFÔFÐØŸšÐ$4°dÑ;Ô;ˆØ"ŸJšJÐ':¸DÑAÔAÐØ�JŠJ�x Ñ&Ô&ˆØŸ
š
Ð#3°TÑ:Ô:ˆØ Ÿ*š* \°5Ñ9Ô9ˆØ—Z’Z ¨dÑ3Ô3ˆ
Ø—j’j °Ñ5Ô5ˆØ"ŸJšJÐ':¸DÑAÔAÐØ—Z’Z ¨dÑ3Ô3ˆ
Ø—Z’Z ¨dÑ3Ô3ˆ
ØŸšÐ$4°dÑ;Ô;ˆØ#ŸZšZÐ(<¸eÑDÔDÐØ—z’z .°%Ñ8Ô8ˆØ—z’z .°%Ñ8Ô8ˆØ$ŸjšjÐ)>ÀÑEÔEÐØ—J’J˜{¨BÑ/Ô/ˆ	Ø—j’j °Ñ6Ô6ˆØ—*’*˜Y¨Ñ-Ô-ˆØŸšÐ$4°bÑ9Ô9ˆØ—z’z .°)Ñ<Ô<ˆØ &§
¢
Ð+BÀEÑ JÔ JÐåÑÔð 	%Ø $ÐàÐ%ÝŒMð EÝñô ð ð Ð Ý Ølñô ð ð #ˆEàÐ Ð!;ÀÈ~Ð@]Ð@]Ø&+ˆN˜7Ñ#àÐ"Õ+CÑ+EÔ+EÐ"Ø#ˆOå$Ñ&Ô&ð 	)Ý#*¤=µÔ1C×1KÒ1KÈNÑ1[Ô1[Ñ#\Ô#\Õ_fÔ_lÐmuÑ_vÔ_vÒ#vÐ Ð à#(Ð à Ð$Ð$Ý�NŠNðñô ð ð
 ÐÝ˜fÕ&6Ñ7Ô7ð Då'2Ø1ÝØ'Ø#1Ø$3Ø#Ø%5ØØ%Ø'Ø:?Ø<Að(ñ (ô (Ð$õ 2Ð2FÈÑTÔT��å% f¨n¸dÑCÔC�åÑÔð 	'Ø"0×"4Ò"4Ð5JÈDÑ"QÔ"QÐà"Ð*Ý&>Ø1ð	'à'Ø#1Ø$3Ø#Ø%5Ø!,ð	'ð 	'ð %ð	'ð 	'Ð#ð #Ð.µ2´7·>²>ÐBUÑ3VÔ3VÐ.ÝÐ-¨s¸WÐEÑEÔEð \ÈØ*GÐ'Ý48´I¸a±L´LÐAZÔ4[Ð1ð\ð \ð \ñ \ô \ð \ð \ð \ð \ð \ð \øøøð \ð \ð \ð \øð #'Ðõ �j¥%¤,Ñ/Ô/ð 	.Ø˜jÐ)ˆJˆJÝ˜
¥CÑ(Ô(ð 	.¨ZÐ?sÐ-sÐ-sðØ ¥%¤,¨zÑ":Ô":Ð;�
�
øÝð ð ð Ý ðbØT^ðbð bð bñô ð ðøøøõ
 ˜
¥CÑ(Ô(ð 	.Ø˜AŠ~ˆ~Ý ð Eñô ð ð ! *Ð-�
àÐ!Ø Ð(Ø$(Ð!Ð!Ø&ð cÝ Ð!aÑbÔbÐbàð 	ØÐ%å$ ]Ñ3Ô3Ð3å)Ñ+Ô+ð Ý Øvñô ð õ -Ñ.Ô.ð Ý!Øtñô ð ð )-Ð%ØÐ*Ý,3Ø# ^Õ5GÔ5Vñ-ô -Ð)ð -Õ0BÔ0FÒFÐFÝ ðnñô ð ð Ð&¨LÐ&¸LÐ&Ý,>Ô,MÐ)Ý*<Ô*Fð +Ø-9È<ÐXÐXØ%)ð+ð +ð ð+ð +Ñ'Ð  ð
 +Õ.@Ô.OÒOÐOØ.Ô;ˆLØ.Ô;ˆLð*ð *Ø!'§¢¡¤ð*ñ *ô *Ð&õ Ð-Ñ.Ô.°Ò2Ð2Ý ðGñô ð ð
 ð #	˜<ð #	Ý+Ñ-Ô-ð Õ2KÑ2MÔ2Mð Ý!ð2ñô ð ð Ð"å—’ðI¨kð Ið Ið Iñô ð õ $œm�àÐ!Ý”:×*Ò*Ñ,Ô,ð ZØ"$¥e¤j×&?Ò&?Ñ&AÔ&AÐ!B�J�Jå&Ð'XÑYÔYÐYÝ—’ðañô ð ð
 %Ð,Ø(,Ð%àð ˜)ð Ý ð?ñô ð ð
 $+¸ÐWfÐgÐgˆ
ØÐ$Ø+8ˆJÐ'Ñ(åÑÔð 	$Ð%5ð 	$Ý�KŠKÐEÑFÔFÐFØ#Ðõ ˜&Õ"2Ñ3Ô3ð 	"Ø$*Ð$6˜&˜&Ð<YˆKØ#C 3Ô#3Ô#CØð$à#Ø%)Ø-Ø /ØØ!1ØØ!Ø#Ø*Ø,ð$ð $ð ð$ð $Ñ ˆF�L�Lð  "ˆLàˆ	Ø*.Ð'Ý�6Ð0Ñ1Ô1ð 	Ø.4Ô.H×.LÒ.LØÕ 2Ô Añ/ô /Ð+ð +Õ.@Ô.EÒEÐEÐJgÐJsØ 3× JÒ JÑ LÔ LÐØ.×4Ò4Ñ6Ô6ð 7ð 7‘	��cØ36�Ô*¨4Ñ0Ð0Ø,0Ð)Ý�NŠNðsñô ð ð *Õ-?Ô-DÒDÐDØ.Õ2DÔ2IÒIÑIå '¤­iÔ.@×.HÒ.HÈÑ.UÔ.UÑ VÔ VÕY`ÔYfÐgnÑYoÔYoÒ oÐØ$ð 7­U¬Z×-DÒ-DÑ-FÔ-Fð 7Ý"Ð#WÑXÔXÐXÝ*Ñ,Ô,ð 
7Õ1GÑ1IÔ1Ið 
7Ý!ð Nñô ð õ ”�yÔ1×9Ò9¸+ÑFÔFÑGÔGÍ'Ì-ÐX_ÑJ`ÔJ`Ò`Ð`Ý!Ømñô ð ð
 7Ð6Ð6Ð6Ð6Ð6Ø.Õ2DÔ2IÒIÐIÝ&0Ô&:¸6Ô;UÑ&VÔ&VÐ#Ø-@�Ô*ØÐ"Ý#œm��å—’ÐpÑqÔqÐqØ%×/Ò/Ð0C×0SÒ0SÑ0UÔ0UÑVÔVˆI‰IØ,Õ0BÔ0FÒFÑFÝ”:×*Ò*Ñ,Ô,ð RÝ"Ð#PÑQÔQÐQå(Ñ*Ô*ð vÝ!Ð"tÑuÔuÐuå*Ñ,Ô,ð sÝ!Ð"qÑrÔrÐràÐ!Ý—’ðMñô ð ð ð Ð'Ý˜j­$Ñ/Ô/ð °U¸j×>OÒ>OÑ>QÔ>QÐ5QÐ5QÐU[Ð_i×_pÒ_pÑ_rÔ_rÐUrÐUrÝ$ðlñô ð ð
 Ð"Ý#œm��å—’ÐoÑpÔpÐpð !Ð(Ø$(Ð!ð !ð7	à-Õ1CÔ1RÒRÐRØð Sð /Õ2DÔ2SÒSÐSÝ—’ð<ñô ð ð
 *=ˆFÔ&Ñ&à ñ+	à ð+	ð 0Õ3EÔ3TÒTÐTà"(Ô"<ÐÝÐ-­tÑ4Ô4ð Ý&8Ô&BÐCVÐmrÐ&sÑ&sÔ&sÐ#Ð#ÝÐ/Õ1CÑDÔDð Øå ð6½tÐDWÑ?XÔ?Xð 6ð 6ð 6ñô ð ð
 /Ô;ˆLàð 1ØÐ&Ý"'¤-�KØÐ%Ý”z×.Ò.Ñ0Ô0ð ^Ø&(­%¬*×*CÒ*CÑ*EÔ*EÐ%F˜
˜
å*Ð+\Ñ]Ô]Ð]Ý—K’Kðeñô ð ð
 )Ð0Ø,0Ð)øð %ð		à ð		ð 0Õ3EÔ3TÒTÐTå�NŠNð9ñô ð ð ˆ
ØÐàˆð  $ÐØ#(Ð à(Ñ4Ý,/Ð0MÑ,NÔ,NÐ)Ý”w—}’}Ð%BÑCÔCˆHØñ @Øð H�rœwŸ~š~Ý”G—L’LÐ!>À	Í?Ð]eÑKeÑfÔfñ ô  ð Hõ $&¤7§<¢<Ð0MÈyÕZiÐltÑZtÑ#uÔ#u�L‘LØð C¥¤§¢Ý”G—L’LÐ!>À	ÕK[Ñ\Ô\ñ"ô "ð Cõ $&¤7§<¢<Ð0MÈyÕZjÑ#kÔ#k�L‘LØð >¥2¤7§>¢>Ý”G—L’LÐ!>À	ÕK\Ñ]Ô]ñ$ô $ð >õ $&¤7§<¢<Ð0MÈyÕZkÑ#lÔ#l�L‘LØ$¨EÐ1Ð1µb´g·n²nÝ”G—L’LÐ!>À	Í<ÕXiÐkrÑKsÔKsÑtÔtñ7ô 7Ð1õ $&¤7§<¢<Ø5°yÅ,ÕO`ÐbiÑBjÔBjñ$ô $�L‘Lð %¨EÐ1Ð1µb´g·n²nÝ”G—L’LØ5°yÅ,ÕOfÐhoÑBpÔBpñô ñ7ô 7Ð1õ $&¤7§<¢<Ø5°yÅ,ÕOfÐhoÑBpÔBpñ$ô $�Lð "&�J‘JÝ”W—^’^Ý”G—L’LÐ!>À	Í<ÕXdÐfmÑKnÔKnÑoÔoñô ð (õ $&¤7§<¢<Ø5°yÅ,Í|Ð]dÑBeÔBeñ$ô $�L‘Lõ ”W—^’^Ý”G—L’LÐ!>À	Í<ÕXjÐlsÑKtÔKtÑuÔuñô ð !õ $&¤7§<¢<Ø5°yÅ,ÕOaÐcjÑBkÔBkñ$ô $�Lð "&�J‘Jå”W—^’^Ý”G—L’LÐ!>À	Í?Ð]eÑKeÑfÔfñô ð å”W—^’^¥B¤G§L¢LÐ1NÐPYÕ[kÑ$lÔ$lÑmÔmðõ +ðQ­|½LÈ'Ñ/RÔ/Rð Qð QØ9ðQð Qð Qñô ð õ
 ”W—^’^¥B¤G§L¢LÐ1NÐPYÕ[lÑ$mÔ$mÑnÔnð Ý*ðB­|½LÈ'Ñ/RÔ/Rð Bð BØ9ðBð Bð Bñô ð ð
 %ð 
Ý*ð=­|Õ<MÈwÑ/WÔ/Wð =ð =Ø9ð=ð =ð =ñô ð õ
 +ð=­|½LÈ'Ñ/RÔ/Rð =ð =ÕVfð =ð =Ý+¨hÑ6ð=ð =Ý<Mð=ð =à9ð=ð =ð =ñô ð õ
 ”—’¥¤§¢¨YÐ8UÑ VÔ VÑWÔWð vØ<�Ø�‘Ý”—’¥¤§¢¨YÐ8UÐX`Ñ8`Ñ aÔ aÑbÔbð sØð Ý$ðHÐ?\Ð_gÑ?gð Hð Hð Hñô ð õ  "œwŸ|š|¨IÐ7TÐW_Ñ7_Ñ`Ô`�Ø�‘ÝÐ<Ñ=Ô=ð kØ8�Ý(4Ð5RÑ(SÔ(SÐ%Ñ%ð ð CÝ/�H�HØð CÝ0�H�HØ$¨EÐ1Ð1Ý+Õ,=¸wÑGÔG�H�Hå+­L¸'ÑBÔB�Hð]ð &/Ø*8Ø#*Ø+:Ø,<Ø!&Ø&0Ø$,Ø%.ØAFØ(3ð*ð *Ð&õ -8Ð8UÐW_Ð,vÐ,vÐcuÐ,vÐ,vÐ)ð -Ð4¸Å\ÕRcÐelÑEmÔEmÒ9mÐ9må0;Ø9Ý(Õ)@À'ÑJÔJð1ð 1ð 1ð1ð 1Ð-ð
 1Ð<Ø)-˜J˜JØ,ð 	Ý"2ð !e¥LÕ1BÀGÑ$LÔ$Lð  !eð  !eÕR^Õ_vÐxñ  SAô  SAð  !eð  !eð  !eñ#ô #ð õ
 (4µLÀ'Ñ'JÔ'J˜HÝ4?Ø =¸xð5ð 5ØK]ð5ð 5Ð1ð -Ð4¸Å\ÕR^Ð`gÑEhÔEhÒ9hÐ9hå0;Ø9Ý(Õ);¸WÑEÔEð1ð 1ð 1ð1ð 1Ð-ð
 1Ð<Ø)-˜JØ,Ð4ð )1Ø'.Ø%*ð+ð +˜õ
 $Ð$AÕCSÐgÐgÐWfÐgÐgð Ý"2Ø#@ð !]ð !]Ý$0µ¸wÑ$GÔ$Gð!]ð !]ð !]ñ#ô #ð õ
 &Ð&CÕEVÐjÐjÐZiÐjÐjð Ý"2Ø#@ð ![ð ![Ý$0µ¸wÑ$GÔ$Gð![ð ![ð ![ñ#ô #ð ð
 %Ð0µXØ9½<ð6ð 6ØKZð6ð 6Ð0õ #3Ø#@ð !ið !iÝ$0µ¸wÑ$GÔ$Gð!ið !ià$+ð!ið !ið !iñ#ô #ð õ #3Ø#@ð !9ð !9Ý$0µ¸wÑ$GÔ$Gð!9ð !9ÝK[ð!9ð !9Ý_nð!9ð !9å$5ð!9ð !9ð !9ñ#ô #ð ð; 5øõD (ð ð ð ð Ý ð ð ð å*ðZÐ5Rð Zð Zà=ZðZð Zõ ?KÍ<ÐY`Ñ>aÔ>aðZð Zõ -ð	Zð Zõ 1@ð	Zð Zõ FWð	Zð Zð Zñô ð ðøøøð ð fÝ—’ÐB°LÐBÐBÑCÔCÐCØ(4Ð%Ð%å—’Ðd°HÐdÐdÐMbÐdÐdÑeÔeÐeÐeà$(Ð!ð ð 	å6PØ-Ø%Ø#Ø-ØØ /Ø!1ØØ%Ø!Ø#Ø(ð7ñ 7ô 7Ñ3Ð!Ð#3õ  %Ñ&Ô&ñ	åÐ0µ#Ñ6Ô6ð	ð &×.Ò.¨~Ñ>Ô>ð	õ
 Ð0¸DÐAÑAÔAð (ÀQØŸ:š:™<œ<�ð(ð (ð (ñ (ô (ð (ð (ð (ð (ð (ð (øøøð (ð (ð (ð (ð �|Š|˜HÑ%Ô%¨Ò-Ð-ØØ—’˜hÑ'Ô'¨4Ò/Ð/Ø�Ý—’Ð_Ñ`Ô`Ð`Ð`Ø—’˜hÑ'Ô'¨6Ò1Ð1Ø �	Ý—’ÐYÑZÔZÐZÐZå Ø|Ðdl×dpÒdpÐqyÑdzÔdzÐ|Ð|ñô ð ð  Ñ*Ð+ˆð ñ 2	"Øð D *Ð"4å,Ð-BÑCÔC�
ð ˆJàÐ&Ý˜k­3Ñ/Ô/ð Ø" fÒ,Ð,Ý" 6¨=Ñ9Ô9ð ¸fÔ>PÐ>\Ø*0Ô*<˜KÝ"ŸKšKÐ(qÀÐ(qÐ(qÐ(qÑrÔrÐrÐrà)ð 3¨gÐ9IÐ.IÐ.IØ.>¸wÔ.G  Ø%/ð 3Ý.BÀ:Ñ.NÔ.N  å1@ÐAVÐWXÔAYÑ1ZÔ1Z Ý.BÀ>Ñ.RÔ.R Ø$2Ý"ŸKšKð!eñô ð ð õ
 )ØpÐcnÐpÐpñô ð ð !×9Ò9¸+ÑFÔF�
ð ),Ô(AÈÐ(Mð (Ø�uœ}Ò,ÐL°ÐLÀð %ð ð AØ)9Ð:OÔ)PÐ&Ð&å)-¨j¯oªoÑ.?Ô.?Ñ)@Ô)@Ð&Ø ð "Ð%=ð "ÕBYÑB[ÔB[ð "ð "�
à;ˆÔõ )°Ð<Ñ<Ô<Ð=ˆå%Ñ'Ô'ð 	7ØÐÐÐå�KŠKÐZÑ[Ô[Ð[Ø&œ^×0Ò0ÕEUÑEWÔEWÐ0ÑXÔXÐYÐ\iÑiˆMˆMØð 	7˜\ð 	7Ð->ð 	7Ø× Ò Õ!3Ñ!5Ô!5Ñ6Ô6Ð6à ð 	pØ×7Ò7¸ÈKÐdnÐ7ÑoÔoˆFå˜]Ñ+Ô+ð 	=ð 	=Ø�C˜Ð< Ð<Ð<Ð<¨|Ð<Ð<ˆEð	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð 	=ð 	=ð 	=ð 	=ð 	=øøøð 	=ð 	=ð 	=ð 	=ð ”ˆð $ð 	&Ý&Ñ(Ô(ð )Ø$(Ð!Ø#(Ô#>Ð Ð à#%Ð àð 3	>˜<ñ 3	>ØVÐVÐVÐVÐVÐVÐVÐVà$7Ô$MÐ!Ø,?Ô,`Ð)Øð _Ý—’Ð]Ñ^Ô^Ð^Ð^å—’Ð]Ñ^Ô^Ð^ð %Ð,Ø)@Ð)@ÀÑ)GÔ)GÐ&Ð&à)>Ð&åÐ4µdÑ;Ô;ð BØ*@Ð)AÐ&à"×)Ò)Ð*>Ñ?Ô?Ð?õ ˜*¥dÑ+Ô+ð 
;µ°J·O²OÑ4EÔ4EÑ0FÔ0FÈÒ0JÐ0JØdÐd°Z×5EÒ5EÑ5GÔ5GÐdÑdÔd�å�{Ñ#Ô# aÒ'Ð'Ð0MÐ'Ý$ðBñô ð ð '×-Ò-¨kÑ:Ô:Ð:å#œM­)Ô*<×*DÒ*DÀ^Ñ*TÔ*TÑUÔUÕY`ÔYfÐgoÑYpÔYpÒpˆMàð  Mð Ý ðYñô ð ð
 ,Ð+ØÐ.DÐZmðñ ô ˆEõ 4;´=ÝÔ"×*Ò*¨>Ñ:Ô:ñ4ô 4å”˜xÑ(Ô(ò4)ˆEÔ0ð *=ˆFÔ&Ø)=ˆEÔ&àð 	˜KÐ/Ý�NŠNðwñô ð ð
 +Õ.@Ô.EÒEÐEØ×+Ò+¨EÑ2Ô2ˆEØ37ˆEÔ0Ð0Ø,Õ0BÔ0FÒFÐFØVÐVÐVÐVÐVÐVÐVÐVà%<Ð%<¸UÑ%CÔ%CÐ"à"Ð*Ý&/Ô&9¸&Ô:TÑ&UÔ&UÐ#à'>Ð'>ØÐ+>ÐWmð(ñ (ô (Ñ$ˆEÐ$ð 49ˆEÔ0à$ð Ý—’ðñô ð ð +Ð6Ø(GˆEÔ%Ð%Ø*Ð6Ø(EˆEÔ%Ý�5Ð/Ñ0Ô0ð 	9Ø!%ˆEÔð .9ˆFÔ*å�j¥#Ñ&Ô&ñ \	JØˆNØð ˜|ð Ø×%Ò%ðð ð ð ð à',×'=Ò'=Ñ'?Ô'?ðñ ô ñô ð ð ×!Ò!ðð ð ð à#(×#9Ò#9Ñ#;Ô#;ðñ ô ñô ð ð 'ˆLàð *Ý”=¥Ô!3×!;Ò!;¸LÑ!IÔ!IÑJÔJÍWÌ]Ð[cÑMdÔMdÒdÐdØ<Ð<Ð<Ð<Ð<Ð<à#.Ô#3�L�Lå$ðjñô ð ð ð *Ý$œz�à$×:Ò:¸:ÑFÔFÐØÐ!UÐUÐUÝ ð$ñô ð ð
 ";Ð<LÐ MÐØ¥7Ô#4Ö5JÑ#KÔ#KÔ#VÐVÐVØ6DÐ!Ð"2Ñ3Ð3Ý�^Ñ$Ô$ qÒ(Ð(Ý—’ðdñô ð ð ˜\Ò)Ð)Þ0Øðà&Ø(Ð,<Ò<Ø)ð	ð ð
 (ðð �
�
ö ,¨JÑ7Ô7�
Ý�uÐ3°TÑ:Ô:Õ>PÔ>_Ò_Ð_àQÐQ¸j×>NÒ>NÑ>PÔ>PÐQÑQÔQ�
Ø.8Ð˜lÑ+ð ×ÒÑÔÐÞ.¨uÐ^Ð^¸LÐ^ÐL]Ð^Ð^ˆJàð /˜|ð /ð.ð .ð .ð .ð .Ø4>·O²OÑ4EÔ4Eð.ñ .ô .Ð*ð Ð6×=Ò=Ñ?Ô?Ð?Ð?À6ÐMg×MnÒMnÑMpÔMpÐCpÐCpÝ$ðñ	ô 	ð 	ð /øàÐ#Ø×ÒÑÔÐÞ.¨uÑ5Ô5ˆKæ0°¸jÑIÔIÐIàð :	Ø$×-Ò-¨hÑ7Ô7ð à×+Ò+¨E°6Ð;PÐQTÐRTÐQTÔ;UÑVÔV��ðØ_Ð_Ð_Ð_Ð_Ð_à*NÐ*NØÐ4ÈÐcgð+ñ +ô +Ñ'�E˜<˜<øõ #ð ð ð Ý—L’Lð)ñô ð ð
 ðøøøð ð '	ð
Ø^Ð^Ð^Ð^Ð^Ð^à=Ð=¸eÐEZÑ[Ô[��øÝð ð ð Ý—’ð2ñô ð ð
 ðøøøð ð 	àÐ%ÝÔ'¨
Ñ3Ô3Ð3ð ×*Ò*ØØØ&Ø%Ø-Ø(?Ø!1Ø%Ø"3Ø%Ø-Ø#5Ø!Ý% eÐ-BÀDÑIÔIÕM_ÔMnÒnØ%9ð +ñ ô ñØØØØØØð& #/ˆÔØ".ˆÔð 	×ÒÑÔÐð 	�
Š
‰Œˆð ×ÒÑÔð 	Ð$AÐ$MðÞ*:Ô*JØ1ð+à'Ø#1Ø$3Ø#Ø%5ØØ%Ø'Ø.Ø#0ð+ð +ð ð+ð +�Ô'Ð'øö ð ð ð Ý—’Øpñô ð ð �ð	øøøð Ð!à(Ø-Ø!.ð!ð !Ðð
 �gÔ/¶Ñ?Ô?ÔJÐJÐJØ16Ô1RÐ! +Ñ.Þ˜5Ð6Ð6Ð$5Ð6Ð6Ð6à(Õ,>Ô,CÒCÐCØ"Ô,Ð4Ø0MÐ#Ô-ØÔ" kÒ1Ð1Ý"Ð#JÑKÔKÐKØ×$Ò$ UÐ,?Ô,IÑJÔJÐJÝ)3Ô)EÀi×FWÒFWÑFYÔFYÑ)ZÔ)ZˆFÔ&Ø37ˆEÔ0Ø*Õ.@Ô.EÒEÐEØ×-Ò-¨eÑ4Ô4ˆEàÐ*Ø×ÒØ#Ø)ØØ-ð	 ñ ô ð ð ð 	'ØÐ#à$0Ø'6Ø'6Ø",ð	 ð  �ð ˜,Ð&Ð&àˆs˜   Ï1PÐPÐ!PÑ!Q8 Ñ8RÁI>G<AQ; ÁQ;AASÁVAV'ÁV'AV+ÁV.AV+Áa:AbÁbAbÁbAbÁy.Az Áz&Az-Áz3A{ Á{&A{,Á~#A  Á %A(Á'A(c                 óV  ‡ ‡5‡6‡7‡8‡9‡:‡;‡<‡=‡>‡?‡@‡A‡B— d}|rddl m} |
�€d|
                     ¦   «         v rjt          |t          t
          f¦  «        r|d         n|Š7‰7                     d¦  «        }|€|st          d¦  «        ‚|�t          j	        |d¬	¦  «         |€d}|o|d u}| 
                    ¦   «          |                     ¦   «         }t	          |                     ¦   «         ¦  «        }|j        ŠAd
„ Š5|}ˆ5fd„|D ¦   «         }t          ‰A¦  «        dk    r7t          ˆAfd„|D ¦   «         ¦  «        }t          ˆAfd„|D ¦   «         ¦  «        }nd}d}| o|}|o| }|r"‰A› d�Š6ˆ6fd„|D ¦   «         Š9ˆ6fd„|D ¦   «         }n|rˆAfd„|D ¦   «         }t	          t!          |¦  «        t!          |¦  «        z
  ¦  «        }t!          |¦  «        t!          |¦  «        z
  }d„ |                     ¦   «         D ¦   «         }|rˆ6fd„|D ¦   «         }n|rˆAfd„|D ¦   «         }t	          ||z
  ¦  «        }| 
                    ¦   «          |
€œt%          ¦   «         sŽt'          j        t          ¦  «        }|                     ¦   «                              ¦   «         D ]/\  Š>}t-          |¦  «        }||                              ‰>¦  «         Œ0d„ |                     ¦   «         D ¦   «         } nt1          |¦  «        } | D ]rŠ;|rˆ6fd„‰;D ¦   «         Š;n|rˆAfd„‰;D ¦   «         Š;ˆ;fd„|D ¦   «         Š=t          ‰=¦  «        dk    r.t          ‰=¦  «        t          ‰;¦  «        k     rˆ=fd„|D ¦   «         }Œs‰ j        �‰ j        D ]Š@ˆ@fd„|D ¦   «         }Œ‰ j        �‰ j        D ]Š@ˆ@fd„|D ¦   «         }Œ|	�r¹|D �]µŠ<‰<t	          |                     ¦   «         ¦  «        v r‰<Š<nÆ‰A› d‰<› �t	          |                     ¦   «         ¦  «        v r‰A› d‰<› �Š<n–‰<                     ‰A¦  «        r�d                     ‰<                     d¦  «        dd …         ¦  «        t	          |                     ¦   «         ¦  «        v r0d                     ‰<                     d¦  «        dd …         ¦  «        Š<|‰<         }!|}"|�7|t<          j        k    r't          ˆ<fd„|D ¦   «         ¦  «        rt<          j         }"|!j!        t=          j!        d¦  «        k    rf|s5tE          |‰<dt=          j#        |! $                    ¦   «         d|"iŽ¦  «         �Œ† ||‰<dt=          j#        |! $                    ¦   «         d|"iŽ¦  «         �Œ·|rN|rˆAfd „|D ¦   «         }#n|rˆAfd!„|D ¦   «         }#n|}#tK          ||#¦  «         | &                    |j'        ¦  «         |�^| (                    ¦   «         D ]I\  Š>}!t          ˆ>fd"„|D ¦   «         ¦  «        r)|!j)         *                    t<          j         ¦  «        |!_)        ŒJd#}$|}%t          ‰ j        ¦  «        dk    r!tW          |‰ j        ¦  «        s|r
‰ j        dz   }$t          ‰ j        ¦  «        dk    r¬tW          |‰ j        ¦  «        r—|s•tY          |‰ j        ¦  «        }%t	          |%                     ¦   «                              ¦   «         ¦  «        Š8t          ˆ8ˆ9fd$„|D ¦   «         ¦  «        rt          d%¦  «        ‚|
� ˆ fd&„|
                     ¦   «         D ¦   «         }
ˆAfd'„}&|�Ut          j-        j.                             |d                              t          j-        j.        ¦  «        d d(…         ¦  «        Š:nd Š:|
�·|rµt_          |
|¦  «        Š?|�#ta          |¦  «         1                    d)d#¦  «        nd*ŠB|€5t          |t          t
          f¦  «        r|d         n|Š7ˆ7fd+„|D ¦   «         }'n&ˆ:fd,„|d-                              ¦   «         D ¦   «         }'ˆ?ˆBfd.„|'                     ¦   «         D ¦   «         }(|�% |&||||||¦  «        })te          |%||$¦  «        }*d }(�nËt          |t          ¦  «        s|g}g }*g })|s|
�d|
                     ¦   «         v ri nd }(|rtg          j4        ¦   «         }+i },nd }+d },|r tk          |
|¬/¦  «        }-ˆ:fd0„|-D ¦   «         }-ng }-t          |¦  «        dk    rtm          j7        |d1¬2¦  «        }|D �]F}.|.|-v rŒtq          |.¦  «        }|) |&||||||¦  «        z  })|	ròt%          ¦   «         rts          ¦   «         r'tu          |%|||$||
||(|+|,||||¬3¦  «        \  }/}(},|*|/z  }*nÃ|%                     ¦   «                              ¦   «         D ]‡\  Š<}!|!j!        t=          j!        d¦  «        k    re|s4tE          |%‰<dt=          j#        |! $                    ¦   «         d|iŽ¦  «         ŒX ||%‰<dt=          j#        |! $                    ¦   «         d|iŽ¦  «         Œˆn|*te          |%||$¦  «        z  }*~tw          j<        ¦   «          �ŒH|(�µt          |(¦  «        dk    r¢||%k    rˆ‰ j        ŠA|s_|(D ]\}0t{          j>        t          j-                             ||0› d4�¦  «        t          j-                             |‰A› d|0› d4�¦  «        ¦  «         Œ]ˆAfd5„|(                     ¦   «         D ¦   «         }(|st          |(|¦  «         d }(|r%t�          |%|,|+¦  «         t{          jA        |+¦  «         t          |*¦  «        dk    r=d6                     |*¦  «        }1d7|1v r|1d8z  }1t…          d9|jC        jD        › d:|1› �¦  «        ‚|rd;„ |D ¦   «         }d<„ |D ¦   «         }t          |¦  «        dk    rz|jE        jF        €g n|jE        jF        }2|jC        jD        |2v rtŽ          jH        ntŽ          jI        }3 |3d=|› d>|jC        jD        › d?|› d@|jC        jD        › dA|jC        jD        › dB�¦  «         n(tŽ           I                    dC|jC        jD        › dD�¦  «         t          |¦  «        dk    r/tŽ           H                    dE|jC        jD        › dF|› dG|› dH�¦  «         nKt          |)¦  «        dk    r8tŽ           I                    dI|jC        jD        › dJ|› dK|jC        jD        › dL�¦  «         t          |)¦  «        dk    rMdM                     dN„ |)D ¦   «         ¦  «        }4tŽ           H                    dE|jC        jD        › dF|› dO|4› dH�¦  «         ||||)|(|*fS )PNFr   rt  r|  r   rÎ   zàThe current `device_map` had weights offloaded to the disk. Please provide an `offload_folder` for them. Alternatively, make sure you have `safetensors` installed if the model you are using offers the weights in this format.TrÕ  c                 ón   — d| v r|                       dd¦  «        S d| v r|                       dd¦  «        S | S )Nr?  r@  r>  rÝ   )r×   )rÜ   s    ro   Ú_fix_keyz8PreTrainedModel._load_pretrained_model.<locals>._fix_key%  sA   € Ø˜ˆ}ˆ}Ø—{’{ 6¨6Ñ2Ô2Ð2Ø˜#ˆ~ˆ~Ø—{’{ 7¨HÑ5Ô5Ð5ØˆJrn   c                 ó&   •— g | ]} ‰|¦  «        ‘ŒS rm   rm   )rˆ   rÜ   rÀ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>-  s!   ø€ Ð<Ð<Ð<¨�x�x ‘}”}Ð<Ð<Ð<rn   c              3   óB   •K  — | ]}|                      ‰¦  «        V — Œd S rý  rD  ©rˆ   ÚsrF  s     €ro   rz  z9PreTrainedModel._load_pretrained_model.<locals>.<genexpr>0  s/   øè è € Ð#NÐ#N¸Q A§L¢L°Ñ$8Ô$8Ð#NÐ#NÐ#NÐ#NÐ#NÐ#Nrn   c              3   óB   •K  — | ]}|                      ‰¦  «        V — Œd S rý  rD  rÃ  s     €ro   rz  z9PreTrainedModel._load_pretrained_model.<locals>.<genexpr>1  s/   øè è € Ð'TÐ'TÀ¨¯ª°VÑ(<Ô(<Ð'TÐ'TÐ'TÐ'TÐ'TÐ'Trn   r¾   c                 ó>   •— g | ]}|                      ‰¦  «        °|‘ŒS rm   rD  ©rˆ   rÄ  Ú_prefixs     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>=  s+   ø€ Ð)`Ð)`Ð)`°È!Ï,Ê,ÐW^ÑJ_ÔJ_Ð)`¨!Ð)`Ð)`Ð)`rn   c                 ól   •— g | ]0}|                      ‰¦  «        r|t          ‰¦  «        d …         n|‘Œ1S rý  ©r7  rÔ   rÇ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>>  s?   ø€ ÐfÐfÐfÐST°!·,²,¸wÑ2GÔ2GÐN˜Q�s 7™|œ|˜~˜~Ô.Ð.ÈQÐfÐfÐfrn   c                 ó>   •— g | ]}d                       ‰|g¦  «        ‘ŒS ©r¾   ©rý   rÃ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>@  s)   ø€ ÐJÐJÐJ°q˜SŸXšX v¨q kÑ2Ô2ÐJÐJÐJrn   c                 ó   — h | ]\  }}|’ŒS rm   rm   )rˆ   r˜  r  s      ro   rg  z9PreTrainedModel._load_pretrained_model.<locals>.<setcomp>F  s   € Ð=Ð=Ð=™t˜q !˜Ð=Ð=Ð=rn   c                 ól   •— h | ]0}|                      ‰¦  «        r|t          ‰¦  «        d …         n|’Œ1S rý  rÊ  ©rˆ   rÜ   rÈ  s     €ro   rg  z9PreTrainedModel._load_pretrained_model.<locals>.<setcomp>H  s@   ø€ ÐnÐnÐnÐY\°C·N²NÀ7Ñ4KÔ4KÐT˜S¥ W¡¤  Ô0Ð0ÐQTÐnÐnÐnrn   c                 ó>   •— h | ]}d                       ‰|g¦  «        ’ŒS rÌ  rÍ  rE  s     €ro   rg  z9PreTrainedModel._load_pretrained_model.<locals>.<setcomp>J  s)   ø€ ÐNÐNÐN¸˜SŸXšX v¨s mÑ4Ô4ÐNÐNÐNrn   c                 ó>   — g | ]\  }}t          |¦  «        d k    ¯|‘ŒS rÚ  rÛ  )rˆ   r  rÝ  s      ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>U  s'   € ÐPÐPÐP¡X Q¨ÅÀUÁÄÈaÂÀ˜5ÀÀÀrn   c                 ól   •— g | ]0}|                      ‰¦  «        r|t          ‰¦  «        d …         n|‘Œ1S rý  rÊ  rÐ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>\  s?   ø€ ÐbÐbÐbÐUX°·²¸wÑ0GÔ0GÐP˜�S ™\œ\˜^˜^Ô,Ð,ÈSÐbÐbÐbrn   c                 ó>   •— g | ]}d                       ‰|g¦  «        ‘ŒS rÌ  rÍ  rE  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>^  s)   ø€ ÐBÐBÐB°S˜Ÿš 6¨3 -Ñ0Ô0ÐBÐBÐBrn   c                 ó   •— g | ]}|‰v ¯|‘Œ	S rm   rm   )rˆ   r‰   Úgroups     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>_  s   ø€ ÐFÐFÐF a¸1À¸:¸: ¸:¸:¸:rn   c                 ó   •— g | ]}|‰v¯|‘Œ	S rm   rm   )rˆ   r‰   Úmissing_in_groups     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>a  s$   ø€ ÐUÐUÐU a¸1ÐDTÐ;TÐ;T Ð;TÐ;TÐ;Trn   c                 ó>   •— g | ]}t          j        ‰|¦  «        ­|‘ŒS rý  rà  ©rˆ   r‰   rá  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>g  s*   ø€ ÐUÐUÐU a½2¼9ÀSÈ!Ñ;LÔ;LÐ;T Ð;TÐ;TÐ;Trn   c                 ó>   •— g | ]}t          j        ‰|¦  «        ­|‘ŒS rý  rà  rÚ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>k  s+   ø€ Ð"[Ð"[Ð"[¨ÅÄÈ3ÐPQÑARÔARÐAZ 1ÐAZÐAZÐAZrn   c              3   óF   •K  — | ]}|‰                      d ¦  «        v V — ŒdS rw  rx  )rˆ   ry  rÜ   s     €ro   rz  z9PreTrainedModel._load_pretrained_model.<locals>.<genexpr>~  sD   øè è € ð ð ØE[Ð.°#·)²)¸C±.´.Ð@ðð ð ð ð ð rn   r*  rø   r¥   c                 ó   •— g | ]	}‰› d |› �‘Œ
S rÌ  rm   ©rˆ   r‰   rF  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>�  s#   ø€ ÐEÐEÐE°A 6  ¨A  ÐEÐEÐErn   c                 óD   •— g | ]}|t          ‰¦  «        d z   d…         ‘ŒS )r   NrÛ  rÞ  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>‘  s.   ø€ ÐJÐJÐJ¸ ¥# f¡+¤+°¡/Ð"3Ð"3Ô 4ÐJÐJÐJrn   c              3   óF   •K  — | ]}|‰                      d ¦  «        v V — ŒdS rw  rx  )rˆ   ry  rU  s     €ro   rz  z9PreTrainedModel._load_pretrained_model.<locals>.<genexpr>›  s4   øè è € ÐtÐtÐE[Ð-°·²¸C±´Ð@ÐtÐtÐtÐtÐtÐtrn   r6  c              3   ó(   •K  — | ]}|‰v o|‰vV — Œd S rý  rm   )rˆ   rÜ   Úbase_model_expected_keysÚexpected_keys_not_prefixeds     €€ro   rz  z9PreTrainedModel._load_pretrained_model.<locals>.<genexpr>§  s5   øè è € ÐtÐtÐad�3Ð4Ð4Ð\¸ÐD\Ð9\ÐtÐtÐtÐtÐtÐtrn   zjThe state dictionary of the model you are trying to load is corrupted. Are you sure it was properly saved?c                 óT   •— i | ]$\  }}|                      ‰j        › d �d¦  «        |“Œ%S r5  )r×   r-  )rˆ   r‰   rŠ   r'  s      €ro   rÞ  z:PreTrainedModel._load_pretrained_model.<locals>.<dictcomp>­  s<   ø€ ÐkÐkÐkÑPTÐPQÐST˜aŸiši¨3Ô+@Ð(CÐ(CÐ(CÀRÑHÔHÈ!ÐkÐkÐkrn   c                 óB  •— g }|r™|D ]–}|| vrŒ|}|r‰	› d|› �}n2|r0d                      |                     d¦  «        dd …         ¦  «        }||v rM| |         j        ||         j        k    r1|                     || |         j        ||         j        f¦  «         | |= Œ—|S )Nr¾   r   )rý   re  rÉ  rÕ   )
r¹   Úmodel_state_dictrî   Úadd_prefix_to_modelÚremove_prefix_from_modelr2  r|  Úcheckpoint_keyÚ	model_keyrF  s
            €ro   Ú_find_mismatched_keyszEPreTrainedModel._load_pretrained_model.<locals>._find_mismatched_keys¯  só   ø€ ð !ˆOØ&ð 7Ø&1ð 7ð 7�Nà%¨ZÐ7Ð7Ø Ø .�IØ/ð Là'-Ð$@Ð$@°Ð$@Ð$@˜	˜	Ø,ð Là$'§H¢H¨^×-AÒ-AÀ#Ñ-FÔ-FÀqÀrÀrÔ-JÑ$KÔ$K˜	ð "Ð%5Ð5Ð5Ø& ~Ô6Ô<Ð@PÐQZÔ@[Ô@aÒaÐaà'×.Ò.Ø+¨Z¸Ô-GÔ-MÐO_Ð`iÔOjÔOpÐqñô ð ð ' ~Ð6øØ"Ð"rn   rs   ztorch.r®   c                 ó   •— i | ]}|‰“ŒS rm   rm   )rˆ   Úpr®  s     €ro   rÞ  z:PreTrainedModel._load_pretrained_model.<locals>.<dictcomp>Ý  s   ø€ ÐLÐLÐL°!˜a ÐLÐLÐLrn   c                 óX   •— i | ]&\  }}|t           j                             ‰|¦  «        “Œ'S rm   ©rj   rü   rý   )rˆ   rí  r  r  s      €ro   rÞ  z:PreTrainedModel._load_pretrained_model.<locals>.<dictcomp>ß  s/   ø€ ÐlÐlÐl¹T¸QÀ˜a¥¤§¢¨f°aÑ!8Ô!8ÐlÐlÐlrn   rÑ   c                 ó<   •— i | ]\  }}‰|         d k    ¯|||‰dœ“ŒS )r|  )Úsafetensors_fileÚweight_namer¥   rm   )rˆ   rí  r  Úparam_device_mapÚ	str_dtypes      €€ro   rÞ  z:PreTrainedModel._load_pretrained_model.<locals>.<dictcomp>à  sC   ø€ ð ð ð á�A�qØ# AÔ&¨&Ò0Ð0ð ¨¸!ÀiÐPÐPà0Ð0Ð0rn   )ry  c                 óP   •— g | ]"}t           j                             ‰|¦  «        ‘Œ#S rm   rï  )rˆ   r  r  s     €ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>  s)   ø€ Ð(`Ð(`Ð(`ÀQ­¬¯ª°f¸aÑ)@Ô)@Ð(`Ð(`Ð(`rn   zLoading checkpoint shards)Údesc)	r†  r‡  rˆ  r‰  rŠ  r¥   r‹  rŒ  r�  z.datc                 ó&   •— i | ]\  }}‰› d |› �|“ŒS rÌ  rm   )rˆ   rÜ   r{  rF  s      €ro   rÞ  z:PreTrainedModel._load_pretrained_model.<locals>.<dictcomp>K  s-   ø€ Ð$fÐ$fÐ$fÁ*À#Àu¨Ð%6Ð%6°Ð%6Ð%6¸Ð$fÐ$fÐ$frn   z
	zsize mismatchz_
	You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.rñ   z:
	c                 ó   — g | ]}d |v¯|‘Œ	S ©r}  rm   ©rˆ   Úelems     ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>^  s#   € ÐUÐUÐU¨À5ÐPTÐCTÐCT˜tÐCTÐCTÐCTrn   c                 ó   — g | ]}d |v¯|‘Œ	S rù  rm   rú  s     ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>_  s"   € ÐOÐOÐO T¸UÈ$Ð=NÐ=N˜DÐ=NÐ=NÐ=Nrn   z(Some weights of the model checkpoint at z! were not used when initializing z: z,
- This IS expected if you are initializing zß from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing z¨ from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).z9All model checkpoint weights were used when initializing z.
zSome weights of z3 were not initialized from the model checkpoint at z and are newly initialized: zo
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.zAll the weights of z/ were initialized from the model checkpoint at zf.
If your task is similar to the task the model of the checkpoint was trained on, you can already use z* for predictions without further training.rå  c           	      ó.   — g | ]\  }}}d |› d|› d|› d�‘ŒS )z- z: found shape z in the checkpoint and z in the model instantiatedrm   )rˆ   rÜ   Úshape1Úshape2s       ro   r‹   z:PreTrainedModel._load_pretrained_model.<locals>.<listcomp>~  sJ   € ð ð ð á+˜˜V Vð n˜ÐmÐm¨FÐmÐmÈ6ÐmÐmÐmðð ð rn   z= and are newly initialized because the shapes did not match:
)Jr  ru  r¶   rÒ   r  r³   r,  r·   rj   rç  r]  r¹   rØ   r-  rÔ   r€  r  Únamed_buffersrp   rø  rù  r�   r    rÕ   rX   Ú_keys_to_ignore_on_load_missingÚ"_keys_to_ignore_on_load_unexpectedr7  rý   re  rf   r�  r®   r˜   r^   Úemptyr”  r<  r¯  rR  rI  rz  rm  rf  r[  rü   rè  Úexpand_device_mapr›   r×   rc  ÚtempfileÚmkdtempÚget_disk_only_shard_filesrB   Útqdmr
  ru   r“  r  r  ÚshutilÚmover]   r[   Úrmtreer  r  r  r×  rì  rÿ   r   r$  )Cr'  r  r¹   rî   r¯  r7  r2  ry  rB  rC  r†  r‡  rE  r¥   r‹  r�  rŒ  ru  Úis_sharded_safetensorsræ  r…  Úoriginal_loaded_keysÚhas_prefix_moduleÚexpects_prefix_modulerè  rç  r  r  Úmodel_buffersr  r
  Ú	id_tensorr½  rŽ  r¹  Ú_loaded_keysr^  r]  rë  rÑ   rˆ  r|  rW  r‰  rŠ  Údisk_only_shard_filesrä   Únew_error_msgsrò  Ú	error_msgÚarchsÚwarnerÚmismatched_warningrÀ  rÈ  r®  râ  rã  r  rÖ  rÜ   rØ  rU  ró  rá  rF  rô  sC   `                                                    @@@@@@@@@@@@@@ro   r”  z&PreTrainedModel._load_pretrained_modelô  s0  øøøøøøøøøøøøøøø€ ð& ˆØð 	LØKÐKÐKÐKÐKÐKàÐ! f°
×0AÒ0AÑ0CÔ0CÐ&CÐ&Cå,6Ð7LÍtÕUZÈmÑ,\Ô,\ÐwÐ% aÔ(Ð(Ðbwð ð *×2Ò2°>ÑBÔBˆNØÐ%¨nÐ%Ý ð:ñô ð ð
 Ð)Ý”˜N°TÐ:Ñ:Ô:Ð:Ø!Ð)Ø%)Ð"à!/Ð!PÐ4DÈDÐ4PÐð 	×ÒÑÔÐð !×+Ò+Ñ-Ô-ÐÝÐ-×2Ò2Ñ4Ô4Ñ5Ô5ˆØÔ(ˆð	ð 	ð 	ð  +ÐØ<Ð<Ð<Ð<°Ð<Ñ<Ô<ˆåˆv‰;Œ;˜Š?ˆ?Ý #Ð#NÐ#NÐ#NÐ#NÀ+Ð#NÑ#NÔ#NÑ NÔ NÐÝ$'Ð'TÐ'TÐ'TÐ'TÀmÐ'TÑ'TÔ'TÑ$TÔ$TÐ!Ð!à %ÐØ$)Ð!ð (9Ð#8Ð#RÐ=RÐ Ø/ÐMÐ8MÐ4MÐà#ð 	KØ�l�l�lˆGØ)`Ð)`Ð)`Ð)`°]Ð)`Ñ)`Ô)`Ð&ØfÐfÐfÐfÐXeÐfÑfÔfˆMˆMØ ð 	KØJÐJÐJÐJ¸MÐJÑJÔJˆMå�C Ñ.Ô.µ°[Ñ1AÔ1AÑAÑBÔBˆÝ˜kÑ*Ô*­S°Ñ-?Ô-?Ñ?ˆð >Ð= u×':Ò':Ñ'<Ô'<Ð=Ñ=Ô=ˆØ#ð 	OØnÐnÐnÐnÐ`mÐnÑnÔnˆMˆMØ ð 	OØNÐNÐNÐNÀÐNÑNÔNˆMÝ˜°Ñ>Ñ?Ô?ˆà×ÒÑÔÐØÐ¥oÑ&7Ô&7ÐÝÔ*­4Ñ0Ô0ˆDØ %× 0Ò 0Ñ 2Ô 2× 8Ò 8Ñ :Ô :ð -ð -‘��fÝ-¨fÑ5Ô5�	Ø�Y”×&Ò& tÑ,Ô,Ð,Ð,ð QÐP°·²±´ÐPÑPÔPˆKˆKõ /¨uÑ5Ô5ˆKà ð 	Vð 	VˆEØ'ð CØbÐbÐbÐbÐ\aÐbÑbÔb��Ø$ð CØBÐBÐBÐB¸EÐBÑBÔB�ØFÐFÐFÐF¨<ÐFÑFÔFÐÝÐ#Ñ$Ô$ qÒ(Ð(­SÐ1AÑ-BÔ-BÅSÈÁZÄZÒ-OÐ-OØUÐUÐUÐU¨<ÐUÑUÔU�øð Ô.Ð:ØÔ:ð Vð V�ØUÐUÐUÐU¨<ÐUÑUÔU��àÔ1Ð=ØÔ=ð \ð \�Ø"[Ð"[Ð"[Ð"[¨oÐ"[Ñ"[Ô"[��ð ñ 	Ø#ð ñ �Ø�$Ð/×4Ò4Ñ6Ô6Ñ7Ô7Ð7Ð7Ø�C�CØÐ&Ð& Ð&Ð&­$Ð/?×/DÒ/DÑ/FÔ/FÑ*GÔ*GÐGÐGØ#Ð+Ð+ cÐ+Ð+�C�CØ—^’^ FÑ+Ô+ð 7°·²¸¿ºÀ3¹¼ÈÈÈÔ9KÑ0LÔ0LÕPTÐUe×UjÒUjÑUlÔUlÑPmÔPmÐ0mÐ0mØŸ(š( 3§9¢9¨S¡>¤>°!°"°"Ô#5Ñ6Ô6�CØ(¨Ô-�ð  %�à(Ð4Ø¥¤Ò.Ð.Ýð ð ð ð Ø_sðñ ô ñ ô ð /õ
 $)¤=�Là”<¥5¤<°Ñ#7Ô#7Ò7Ð7Ø(ð Ý3°E¸3ÀÅuÄ{ÐTY×T^ÒT^ÑT`ÔT`ÐGuÐhtÐGuÐGuÑvÔvÐvÑvà=Ð=Ø! 3¨­u¬{¸E¿JºJ¹L¼LÐ/]ÐP\Ð/]Ð/]ñô ð ùð
 ð 		3Ø'ð +ØEÐEÐEÐE¸ÐEÑEÔE��Ø$ð +ØJÐJÐJÐJ¸kÐJÑJÔJ��à*�Ý& u¨lÑ;Ô;Ð;à�KŠK˜Ô1Ñ2Ô2Ð2ð  Ð+Ø$×5Ò5Ñ7Ô7ð >ð >‘��eÝÐtÐtÐtÐtÐ_sÐtÑtÔtÑtÔtð >à!&¤§¢­u¬}Ñ!=Ô!=�E”Jøð ˆØˆÝˆsÔ$Ñ%Ô%¨Ò)Ð)µ'¸%ÀÔAVÑ2WÔ2WÐ)Ð\mÐ)ØÔ0°3Ñ6ˆLÝˆsÔ$Ñ%Ô%¨Ò)Ð)­g°e¸SÔ=RÑ.SÔ.SÐ)Ð\mÐ)Ý# E¨3Ô+@ÑAÔAˆMÝ'+¨M×,DÒ,DÑ,FÔ,F×,KÒ,KÑ,MÔ,MÑ'NÔ'NÐ$ÝÐtÐtÐtÐtÐtÐhsÐtÑtÔtÑtÔtð Ý ð&ñô ð ð Ð%ØkÐkÐkÐkÐXb×XhÒXhÑXjÔXjÐkÑkÔk�
ð	#ð 	#ð 	#ð 	#ð 	#ð@ !Ð,Ý”W”[×%Ò%Ð&;¸AÔ&>×&DÒ&DÅRÄWÄ[Ñ&QÔ&QÐRUÐSUÐRUÔ&VÑWÔWˆFˆFàˆFØÐ! nÐ!Ý0°Ð=QÑRÔRÐà<AÐ<M�˜E™
œ
×*Ò*¨8°RÑ8Ô8Ð8ÐS\ˆIØÐ'õ "Ð"7½$Å¸ÑGÔGð/Ð)¨!Ô,Ð,à.ð ð
 MÐLÐLÐLÐ7KÐLÑLÔL�
�
àlÐlÐlÐlÐEUÐVbÔEc×EiÒEiÑEkÔEkÐlÑlÔl�
ðð ð ð ð à&×,Ò,Ñ.Ô.ðñ ô ˆMð Ð!à3Ð3ØØ Ø$Ø#Ø(Ø'ñô ˆOõ 5°]ÀJÐP\Ñ]Ô]ˆJØ ˆM‰Mõ
 Ð3µTÑ:Ô:ð @Ø)>Ð(?Ð%àˆJØ ˆOØ!ð iØ&0Ð&<ÀÈ:×K\ÒK\ÑK^ÔK^ÐA^ÐA^  Ðdh�Ø!ð (Ý$,Ô$4Ñ$6Ô$6Ð!Ø#%Ð Ð à$(Ð!Ø#'Ð à%ð +Ý(AÀ*Ð_oÐ(pÑ(pÔ(pÐ%Ø(`Ð(`Ð(`Ð(`ÐJ_Ð(`Ñ(`Ô(`Ð%Ð%à(*Ð%åÐ(Ñ)Ô)¨AÒ-Ð-Ý(/¬Ð5JÐQlÐ(mÑ(mÔ(mÐ%Ø3ð 3ñ 3�
àÐ!6Ð6Ð6ØÝ,¨ZÑ8Ô8�
ð  Ð#8Ð#8ØØ$Ø(Ø'Ø,Ø+ñ$ô $ñ �ð %ð gÝ*Ñ,Ô,ð &Õ0OÑ0QÔ0Qð &ÝJjØ)Ø&Ø'Ø(Ø)Ø'1Ø+9Ø*7Ø.?Ø-=Ø"'Ø)5Ø+9Ø1EðKñ Kô KÑG˜¨Ð7Gð  # nÑ4˜
˜
à*7×*BÒ*BÑ*DÔ*D×*JÒ*JÑ*LÔ*Lð 	&ð 	&™J˜C Ø$œ|­u¬|¸FÑ/CÔ/CÒCÐCØ(4ð !&Ý$?Ø(5°s¸EÅ5Ä;ÐPU×PZÒPZÑP\ÔP\ÐCjÐdiÐCjÐCjñ%&ô %&ð %&ð %&ð %JÐ$IØ(5°s¸EÅ5Ä;ÐPU×PZÒPZÑP\ÔP\ÐCjÐdiÐCjÐCjñ%&ô %&ð %&øð	&ð Õ"=¸mÈZÐYeÑ"fÔ"fÑf�Jð Ý”
‘”�‘àÐ(­S°Ñ-?Ô-?À!Ò-CÐ-CØ˜MÒ)Ð)à Ô2�FØ)ð Ø+8ð ð ˜KÝ"œKÝ "¤§¢¨^ÀÐ=QÐ=QÐ=QÑ RÔ RÝ "¤§¢¨^ÀÐ=ZÐ=ZÈÐ=ZÐ=ZÐ=ZÑ [Ô [ñô ð ð ð %gÐ$fÐ$fÐ$fÐP]×PcÒPcÑPeÔPeÐ$fÑ$fÔ$f�MØ%ð )Ý& }°nÑEÔEÐEØ$(�Mà!ð 1å& }Ð6FÐHYÑZÔZÐZÝ”Ð/Ñ0Ô0Ð0åˆz‰?Œ?˜QÒÐØŸš JÑ/Ô/ˆIØ )Ð+Ð+ØØwñ�	õ ÐoÀUÄ_ÔE]ÐoÐoÐdmÐoÐoÑpÔpÐpàð 	PØUÐU°ÐUÑUÔUˆOØOÐO¨\ÐOÑOÔOˆLåˆÑÔ !Ò#Ð#Øœ,Ô4Ð<�B�BÀ%Ä,ÔB\ˆEØ',¤Ô'?À5Ð'HÐ'H•V”^�^ÍfÌkˆFØˆFðtÐ;Xð tð tØ!&¤Ô!9ðtð tØ=Lðtð tà!&¤Ô!9ðtð tð
 ”OÔ,ðtð tð tñô ð ð õ �KŠKÐqÐTYÔTcÔTlÐqÐqÐqÑrÔrÐrÝˆ|ÑÔ˜qÒ Ð Ý�NŠNðn 5¤?Ô#;ð nð nØ1ðnð nØO[ðnð nð nñô ð ð õ
 �Ñ!Ô! QÒ&Ð&Ý�KŠKð e¤oÔ&>ð ð Ø1ðð à8=¼Ô8Pðð ð ñô ð õ ˆÑÔ !Ò#Ð#Ø!%§¢ðð à/>ðñ ô ñ"ô "Ðõ �NŠNð< 5¤?Ô#;ð <ð <Ø1ð<ð <à.ð<ð <ð <ñô ð ð �l O°_ÀmÐU_Ð_Ð_rn   c                 ó¬  — d„ |D ¦   «         }|                      d„ |D ¦   «         ¦  «        }g }|                      ¦   «         D ]‘\  }}|r9| j        › d�}|                     |¦  «        r|t	          |¦  «        d …         n|}n8|r6t	          |¦  «        dk    rd                     | j        |g¦  «        n| j        }||v r|                     |¦  «         Œ’|S )Nc                 ón   — h | ]2}d                       |                     d ¦  «        dd…         ¦  «        ’Œ3S )r¾   Nrs   )rý   re  ©rˆ   rÜ   s     ro   rg  z>PreTrainedModel.retrieve_modules_from_names.<locals>.<setcomp>�  s7   € ÐFÐFÐF¸�s—x’x §	¢	¨#¡¤¨s°¨sÔ 3Ñ4Ô4ÐFÐFÐFrn   c                 óÈ   — h | ]_}t          |¦  «        d k    ¯|d                              ¦   «         ¯/d                     |                     d¦  «        dd…         ¦  «        ’Œ`S )r   rs   r¾   Néþÿÿÿ)rÔ   ri  rý   re  r  s     ro   rg  z>PreTrainedModel.retrieve_modules_from_names.<locals>.<setcomp>’  sY   € ÐbÐbÐb¨s½sÀ3¹x¼xÈ!º|¸|ÐPSÐTVÔPW×P_ÒP_ÑPaÔPa¸|ˆS�XŠX�c—i’i ‘n”n S b SÔ)Ñ*Ô*¸|¸|¸|rn   r¾   r   )Úunionr9  r-  r7  rÔ   rý   rÕ   )	r¯  rÝ  Ú
add_prefixÚremove_prefixÚmodule_keysÚretrieved_modulesrU  r�   rÈ  s	            ro   Úretrieve_modules_from_namesz+PreTrainedModel.retrieve_modules_from_namesŒ  s	  € ØFÐFÀÐFÑFÔFˆð "×'Ò'ØbÐb°eÐbÑbÔbñ
ô 
ˆð Ðà ×.Ò.Ñ0Ô0ð 	1ð 	1‰LˆD�&Øð mØ!Ô3Ð6Ð6Ð6�Ø/3¯ª¸wÑ/GÔ/GÐQ�t�C ™LœL˜N˜NÔ+Ð+ÈT��Øð mÝCFÀtÁ9Ä9ÈqÂ=À=�s—x’x Ô!7¸Ð >Ñ?Ô?Ð?ÐVZÔVl�à�{Ð"Ð"Ø!×(Ò(¨Ñ0Ô0Ð0øà Ð rn   c                 ój   — t          | ||¦  «         t          |¦  «        }t          | |||¦  «        }|S )a~  
        This is an experimental function that loads the model using ~1.x model size CPU memory

        Before you call it do:

        1. save which state_dict keys are available
        2. drop state_dict before model is created, since the latter takes 1x model size memory

        Here then we continue:

        3. switch to the meta device all params/buffers that are going to be replaced from the loaded state_dict
        4. load state_dict 2nd time
        5. replace the params/buffers from the state_dict

        Currently, it doesn't handle missing_keys, unexpected_keys, mismatched_keys. It can't handle deepspeed.
        )rr  r
  r“  )r  ro  r¯  r^  r¹   rW  s         ro   Ú_load_pretrained_model_low_memz.PreTrainedModel._load_pretrained_model_low_mem£  s@   € õ& 	˜EÐ#9¸<ÑHÔHÐHÝ$Ð%:Ñ;Ô;ˆ
Ý5°e¸ZÐI_ÐamÑnÔnˆ
ØÐrn   Ú	AutoModelc                 ó¢   — t          |t          ¦  «        s|j        }ddlmc m} t          ||¦  «        st          |› d�¦  «        ‚|| _        dS )aã  
        Register this class with a given auto class. This should only be used for custom models as the ones in the
        library are already mapped with an auto class.

        <Tip warning={true}>

        This API is experimental and may have some slight breaking changes in the next releases.

        </Tip>

        Args:
            auto_class (`str` or `type`, *optional*, defaults to `"AutoModel"`):
                The auto class to register this new model with.
        r   Nz is not a valid auto class.)	rÒ   r›   r  Útransformers.models.autoÚmodelsrS  rf  r·   rí  )r'  Ú
auto_classÚauto_modules      ro   Úregister_for_auto_classz'PreTrainedModel.register_for_auto_class»  sn   € õ  ˜*¥cÑ*Ô*ð 	-Ø#Ô,ˆJà6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6å�{ JÑ/Ô/ð 	IÝ 
ÐGÐGÐGÑHÔHÐHà$ˆŒˆˆrn   c                 óø   — t          ¦   «         st          d¦  «        ‚ddlm} t	          j        |¦  «        t	          j        d¦  «        k     rt          d|› d�¦  «        ‚ddlm} |                     | ¦  «        S )a(  
        Converts the model to use [PyTorch's native attention
        implementation](https://pytorch.org/docs/stable/generated/torch.nn.MultiheadAttention.html), integrated to
        Transformers through [Optimum library](https://huggingface.co/docs/optimum/bettertransformer/overview). Only a
        subset of all Transformers models are supported.

        PyTorch's attention fastpath allows to speed up inference through kernel fusions and the use of [nested
        tensors](https://pytorch.org/docs/stable/nested.html). Detailed benchmarks can be found in [this blog
        post](https://medium.com/pytorch/bettertransformer-out-of-the-box-performance-for-huggingface-transformers-3fbe27d50ab2).

        Returns:
            [`PreTrainedModel`]: The model converted to BetterTransformer.
        ú<The package `optimum` is required to use Better Transformer.r   rv   ú1.7.0úEPlease install optimum>=1.7.0 to use Better Transformer. The version ú was found.©ÚBetterTransformer)	r=   r›  Úoptimum.versionrw   r   r6  Úoptimum.bettertransformerr3  Ú	transform©r¯  Úoptimum_versionr3  s      ro   Úto_bettertransformerz$PreTrainedModel.to_bettertransformerÕ  s�   € õ $Ñ%Ô%ð 	^ÝÐ\Ñ]Ô]Ð]àBÐBÐBÐBÐBÐBåŒ=˜Ñ)Ô)­G¬M¸'Ñ,BÔ,BÒBÐBÝØtÐXgÐtÐtÐtñô ð ð 	@Ð?Ð?Ð?Ð?Ð?à ×*Ò*¨4Ñ0Ô0Ð0rn   c                 óø   — t          ¦   «         st          d¦  «        ‚ddlm} t	          j        |¦  «        t	          j        d¦  «        k     rt          d|› d�¦  «        ‚ddlm} |                     | ¦  «        S )a  
        Reverts the transformation from [`~PreTrainedModel.to_bettertransformer`] so that the original modeling is
        used, for example in order to save the model.

        Returns:
            [`PreTrainedModel`]: The model converted back to the original modeling.
        r.  r   rv   r/  r0  r1  r2  )	r=   r›  r4  rw   r   r6  r5  r3  Úreverser7  s      ro   Úreverse_bettertransformerz)PreTrainedModel.reverse_bettertransformerñ  s�   € õ $Ñ%Ô%ð 	^ÝÐ\Ñ]Ô]Ð]àBÐBÐBÐBÐBÐBåŒ=˜Ñ)Ô)­G¬M¸'Ñ,BÔ,BÒBÐBÝØtÐXgÐtÐtÐtñô ð ð 	@Ð?Ð?Ð?Ð?Ð?à ×(Ò(¨Ñ.Ô.Ð.rn   c           
      óh  — t          |¦  «        s,t          j                             ¦   «         st	          ¦   «         rdS |€| j        j        €dS | j        j        |dd…ddgf         v rÊd}| j        j        �| j        j        | j        j        k    sL| j        j        �| j        j        | j        j        k    s&| j        j	        �T| j        j	        | j        j        k    r:|d| j        j        › d| j        j        › d| j        j        › d| j        j	        › d	�	z  }t                               |¦  «         dS dS )
zv
        Shows a one-time warning if the input_ids appear to contain padding and no attention mask was given.
        Nrs   r   zÈWe strongly recommend passing in an `attention_mask` since your input_ids may be padded. See https://huggingface.co/docs/transformers/troubleshooting#incorrect-output-when-padding-tokens-arent-masked.z5
You may ignore this warning if your `pad_token_id` (z&) is identical to the `bos_token_id` (z), `eos_token_id` (z), or the `sep_token_id` (z ), and your input is not padded.)rI   rf   ÚjitÚ
is_tracingrJ   r×  Úpad_token_idÚbos_token_idÚeos_token_idÚsep_token_idrÿ   rþ  )r¯  r  rÍ  Úwarn_strings       ro   Ú%warn_if_padding_and_no_attention_maskz5PreTrainedModel.warn_if_padding_and_no_attention_mask  sn  € õ ˜YÑ'Ô'ð 	­5¬9×+?Ò+?Ñ+AÔ+Að 	ÕE]ÑE_ÔE_ð 	ØˆFàÐ&¨D¬KÔ,DÐ,LØˆFð Œ;Ô# y°°°°R¸°G°Ô'<Ð<Ð<ðFð ð ”Ô)Ð5¸$¼+Ô:RÐVZÔVaÔVnÒ:nÐ:nØ”KÔ,Ð8¸T¼[Ô=UÐY]ÔYdÔYqÒ=qÐ=qØ”KÔ,Ð8¸T¼[Ô=UÐY]ÔYdÔYqÒ=qÐ=qàðiÈTÌ[ÔMeð ið iØ.2¬kÔ.Fðið iØ[_Ô[fÔ[sðið ià.2¬kÔ.Fðið ið iñ�õ ×Ò Ñ,Ô,Ð,Ð,Ð,ð) =Ð<rn   rþ  rý  )NFr   )
FNTFNNNNFNrÿ  rX  )r&  )r‚   r  )]r  r  r  r  r€  r-  rù  rí  r}  r–  r‡  r  r  r÷  rû  Úis_parallelizabler  r5  r  r	   r›   rf   r   r  r&  r   r  r  r  Úclassmethodr)  r¥   r#  r   rš   r.  rÀ   r  r   r   rt   r=  rF  rI  rD  rM  rO  rz   rR  r]  r  rY  rX  r€  rè  r‡  r„  rŠ  rœ  r‹  r�  r©  r   r«  r  r
   r®  r  r   r   r»  rÁ  rÅ  Úsaverj   ÚPathLikerM  rî  r$  r   r8  rm  r-  r¬   r�  r”  r#  r%  r,  r9  r<  rE  Ú__classcell__©r  s   @ro   r  r  /  s¯  ø€ € € € € ðð ð4 €LØÐØ!€OØ€KØÐØ"&ÐØ Ðð '+Ð#ð *.Ð&ð #ÐàÐàÐØ&+Ð#ð #Ðàð9˜d 3¨¬Ð#4Ô5ð 9ð 9ð 9ñ „Xð9ð ð˜3ð ð ð ñ „XððmÐ/ð mð mð mð mð mð mð>ð >ð >ð;ð ;ð ;ð ðð ñ „[ðð@ ð¨U¬[ð ¸U¼[ð ð ð ñ „[ðð4 ð;˜BœIð ;ð ;ð ;ñ „Xð;ð ð˜Tð ð ð ñ „[ðð àswðKð KØ"*¨5¬;Ô"7ðKØLTÐUZÐ[^Ð`dÐehÐjmÐemÔ`nÐ[nÔUoÔLpðKà	ðKð Kð Kñ „[ðKðZ	pð 	pð 	pð*ð *ð *ð& b¤ið &ð &ð &ð &ð&¨"¬)ð &ð &ð &ð &ð r¤yð ð ð ð ðð ð ð)ð )ð )ð&ð &ð &ð* ðH¨b¬ið HÀ"Ä)ð HÐ`cð Hð Hð Hñ „\ðHðTMð Mð Mð('°ð 'ð 'ð 'ð 'ð< Y]ð$ð $Ø& sœmð$ØHPÐQTÌð$à	Œð$ð $ð $ð $ðL+ð +ð +ð +ð@ )-Ø,0ð	eð eàœðeð ! œðeð % SœMð	eð
 
Œðeð eð eð eðP joðQð QØœ9ðQØ6>¸s´mðQØX`ÐaeÔXfðQà	ŒðQð Qð Qð Qðfdð dð dð
Àcð 
ð 
ð 
ð 
ð
¨¨r¬|¸UÀ2Ä<Ô=PÐ/PÔ)Qð 
ð 
ð 
ð 
ðð ð ð"5¨$¨s°D¸´I¨~Ô*>ð 5ð 5ð 5ð 5ð".ð .ð .ð .ð> :>Ðgqð ð °$ð Ð\dð ð ð ð ð,/ð /ð /ð ðn¨4ð nð nð nñ „Xðnð !%Ø%)Ø"'¤*Ø!Ø*/Ø#'Ø!%Ø,0Ø!%ð`ð `à˜c 2¤;Ð.Ô/ð`ð ð`ð ˜T”Nð	`ð
  ð`ð ð`ð ˜c 3˜hœð`ð !ð`ð ˜#”ð`ð ˜˜c 4˜iÔ(Ô)ð`ð ð`ð `ð `ð `ðD	ð ð ð ð$ €Uˆ5Œ8Œ?ÔÑ Ô ð1ð 1ð 1ð 1ñ !Ô ð1ð €Uˆ5Œ8Œ?ÔÑÔð+ð +ð +ð +ñ Ôð+ð6'ð 'ð 'ð 'ð 'ð(ð (ð (ð (ð (ð ð
 GKØ7;Ø(-Ø$Ø!&Ø,0ØØ $ð|ð |ð |à'/°°c¸2¼;Ð6FÔ0GÔ'Hð|ð ˜Ð/°°b´kÐAÔBÔCð	|ð
 ˜E # r¤{Ð"2Ô3Ô4ð|ð "&ð|ð ð|ð ð|ð ˜˜c 4˜iÔ(Ô)ð|ð ð|ð ð|ð |ð |ñ „[ð|ð|' ð !&ØØØØØØØØØ!ð!U`ð U`ð U`ñ „[ðU`ðn!ð !ð !ð !ð. ðð ð ñ „\ðð. ð%ð %ð %ñ „[ð%ð21ð 1ð 1ð 1ð8/ð /ð /ð,!-ð !-ð !-ð !-ð !-ð !-ð !-rn   r  r  r&  z
model file)ÚobjectÚobject_classÚobject_filesc                   ój   ‡ — e Zd ZdZdefˆ fd„Z	 d	dej        deej                 dej        fd„Z	ˆ xZ
S )
ÚPoolerStartLogitszÒ
    Compute SQuAD start logits from sequence hidden states.

    Args:
        config ([`PretrainedConfig`]):
            The config used by the model, will be used to grab the `hidden_size` of the model.
    r×  c                 ó†   •— t          ¦   «                              ¦   «          t          j        |j        d¦  «        | _        d S )Nr   )r  r  r   rœ  Úhidden_sizeÚdense©r¯  r×  r  s     €ro   r  zPoolerStartLogits.__init__;  s3   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ1°1Ñ5Ô5ˆŒ
ˆ
ˆ
rn   NÚhidden_statesÚp_maskr‚   c                 óÎ   — |                       |¦  «                             d¦  «        }|�:t          | ¦  «        t          j        k    r|d|z
  z  d|z  z
  }n|d|z
  z  d|z  z
  }|S )aì  
        Args:
            hidden_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`):
                The final hidden states of the model.
            p_mask (`torch.FloatTensor` of shape `(batch_size, seq_len)`, *optional*):
                Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
                should be masked.

        Returns:
            `torch.FloatTensor`: The start logits for SQuAD.
        rs   Nr   éÜÿ  çêŒ 9Y>)F)rS  Úsqueezer´   rf   r�  )r¯  rU  rV  Úxs       ro   ÚforwardzPoolerStartLogits.forward?  ss   € ð �JŠJ�}Ñ%Ô%×-Ò-¨bÑ1Ô1ˆàÐÝ" 4Ñ(Ô(­E¬MÒ9Ð9Ø˜˜V™Ñ$ u¨v¡~Ñ5��à˜˜V™Ñ$ t¨f¡}Ñ4�àˆrn   rý  )r  r  r  r  r   r  rf   ÚFloatTensorr   r\  rJ  rK  s   @ro   rP  rP  2  s•   ø€ € € € € ðð ð6Ð/ð 6ð 6ð 6ð 6ð 6ð 6ð
 W[ðð Ø"Ô.ðØ8@ÀÔARÔ8Sðà	Ô	ðð ð ð ð ð ð ð rn   rP  c                   ó¢   ‡ — e Zd ZdZdefˆ fd„Z	 	 	 ddej        deej                 deej	                 deej                 d	ej        f
d
„Z
ˆ xZS )ÚPoolerEndLogitszü
    Compute SQuAD end logits from sequence hidden states.

    Args:
        config ([`PretrainedConfig`]):
            The config used by the model, will be used to grab the `hidden_size` of the model and the `layer_norm_eps`
            to use.
    r×  c                 óN  •— t          ¦   «                              ¦   «          t          j        |j        dz  |j        ¦  «        | _        t          j        ¦   «         | _        t          j        |j        |j	        ¬¦  «        | _        t          j        |j        d¦  «        | _
        d S )Nr¸  )Úepsr   )r  r  r   rœ  rR  Údense_0ÚTanhÚ
activationÚ	LayerNormÚlayer_norm_epsÚdense_1rT  s     €ro   r  zPoolerEndLogits.__init__b  sz   ø€ Ý‰Œ×ÒÑÔÐÝ”y Ô!3°aÑ!7¸Ô9KÑLÔLˆŒÝœ'™)œ)ˆŒÝœ fÔ&8¸fÔ>SÐTÑTÔTˆŒÝ”y Ô!3°QÑ7Ô7ˆŒˆˆrn   NrU  Ústart_statesÚstart_positionsrV  r‚   c                 óZ  — |€|€
J d¦   «         ‚|�a|j         dd…         \  }}|dd…ddf                              dd|¦  «        }|                     d|¦  «        }|                     d|d¦  «        }|                      t	          j        ||gd¬¦  «        ¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «         	                    d¦  «        }|�:t          | ¦  «        t          j        k    r|d|z
  z  d|z  z
  }n|d|z
  z  d|z  z
  }|S )	aë  
        Args:
            hidden_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`):
                The final hidden states of the model.
            start_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`, *optional*):
                The hidden states of the first tokens for the labeled span.
            start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                The position of the first token for the labeled span.
            p_mask (`torch.FloatTensor` of shape `(batch_size, seq_len)`, *optional*):
                Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
                should be masked.

        <Tip>

        One of `start_states` or `start_positions` should be not `None`. If both are set, `start_positions` overrides
        `start_states`.

        </Tip>

        Returns:
            `torch.FloatTensor`: The end logits for SQuAD.
        Nú7One of start_states, start_positions should be not Noner  rs   ©r»  r   rX  rY  )rÉ  rã  Úgatherrb  rf   rÊ  rd  re  rg  rZ  r´   r�  )r¯  rU  rh  ri  rV  ÚslenÚhszr[  s           ro   r\  zPoolerEndLogits.forwardi  sB  € ð< Ð$¨Ð(CÐ(CØDñ )DÔ(CÐCàÐ&Ø%Ô+¨B¨C¨CÔ0‰IˆD�#Ø-¨a¨a¨a°°t¨mÔ<×CÒCÀBÈÈCÑPÔPˆOØ(×/Ò/°°OÑDÔDˆLØ'×.Ò.¨r°4¸Ñ<Ô<ˆLà�LŠL�œ M°<Ð#@ÀbÐIÑIÔIÑJÔJˆØ�OŠO˜AÑÔˆØ�NŠN˜1ÑÔˆØ�LŠL˜‰OŒO×#Ò# BÑ'Ô'ˆàÐÝ" 4Ñ(Ô(­E¬MÒ9Ð9Ø˜˜V™Ñ$ u¨v¡~Ñ5��à˜˜V™Ñ$ t¨f¡}Ñ4�àˆrn   ©NNN©r  r  r  r  r   r  rf   r]  r   Ú
LongTensorr\  rJ  rK  s   @ro   r_  r_  X  sÁ   ø€ € € € € ðð ð8Ð/ð 8ð 8ð 8ð 8ð 8ð 8ð 59Ø6:Ø.2ð1ð 1àÔ(ð1ð ˜uÔ0Ô1ð1ð " %Ô"2Ô3ð	1ð
 ˜Ô*Ô+ð1ð 
Ô	ð1ð 1ð 1ð 1ð 1ð 1ð 1ð 1rn   r_  c                   óœ   ‡ — e Zd ZdZˆ fd„Z	 	 	 d
dej        deej                 deej                 deej                 dej        f
d	„Z	ˆ xZ
S )ÚPoolerAnswerClasszí
    Compute SQuAD 2.0 answer class from classification and start tokens hidden states.

    Args:
        config ([`PretrainedConfig`]):
            The config used by the model, will be used to grab the `hidden_size` of the model.
    c                 ó  •— t          ¦   «                              ¦   «          t          j        |j        dz  |j        ¦  «        | _        t          j        ¦   «         | _        t          j        |j        dd¬¦  «        | _        d S )Nr¸  r   F)r@  )	r  r  r   rœ  rR  rb  rc  rd  rg  rT  s     €ro   r  zPoolerAnswerClass.__init__¦  sc   ø€ Ý‰Œ×ÒÑÔÐÝ”y Ô!3°aÑ!7¸Ô9KÑLÔLˆŒÝœ'™)œ)ˆŒÝ”y Ô!3°Q¸UÐCÑCÔCˆŒˆˆrn   NrU  rh  ri  Ú	cls_indexr‚   c                 ó`  — |j         d         }|€|€
J d¦   «         ‚|�K|dd…ddf                              dd|¦  «        }|                     d|¦  «                             d¦  «        }|�L|dd…ddf                              dd|¦  «        }|                     d|¦  «                             d¦  «        }n|dd…ddd…f         }|                      t          j        ||gd¬¦  «        ¦  «        }|                      |¦  «        }|                      |¦  «                             d¦  «        }|S )a¸  
        Args:
            hidden_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`):
                The final hidden states of the model.
            start_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`, *optional*):
                The hidden states of the first tokens for the labeled span.
            start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                The position of the first token for the labeled span.
            cls_index (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                Position of the CLS token for each sentence in the batch. If `None`, takes the last token.

        <Tip>

        One of `start_states` or `start_positions` should be not `None`. If both are set, `start_positions` overrides
        `start_states`.

        </Tip>

        Returns:
            `torch.FloatTensor`: The SQuAD 2.0 answer class.
        rs   Nrk  r  rl  )	rÉ  rã  rm  rZ  rb  rf   rÊ  rd  rg  )r¯  rU  rh  ri  rv  ro  Úcls_token_stater[  s           ro   r\  zPoolerAnswerClass.forward¬  s>  € ð: Ô! "Ô%ˆàÐ$¨Ð(CÐ(CØDñ )DÔ(CÐCàÐ&Ø-¨a¨a¨a°°t¨mÔ<×CÒCÀBÈÈCÑPÔPˆOØ(×/Ò/°°OÑDÔD×LÒLÈRÑPÔPˆLàÐ Ø! ! ! ! T¨4 -Ô0×7Ò7¸¸BÀÑDÔDˆIØ+×2Ò2°2°yÑAÔA×IÒIÈ"ÑMÔMˆOˆOà+¨A¨A¨A¨r°1°1°1¨HÔ5ˆOà�LŠL�œ L°/Ð#BÈÐKÑKÔKÑLÔLˆØ�OŠO˜AÑÔˆØ�LŠL˜‰OŒO×#Ò# BÑ'Ô'ˆàˆrn   rp  )r  r  r  r  r  rf   r]  r   rr  r\  rJ  rK  s   @ro   rt  rt  �  s¹   ø€ € € € € ðð ðDð Dð Dð Dð Dð 59Ø6:Ø04ð/ð /àÔ(ð/ð ˜uÔ0Ô1ð/ð " %Ô"2Ô3ð	/ð
 ˜EÔ,Ô-ð/ð 
Ô	ð/ð /ð /ð /ð /ð /ð /ð /rn   rt  c                   óì   — e Zd ZU dZdZeej                 ed<   dZ	eej                 ed<   dZ
eej                 ed<   dZeej                 ed<   dZeej                 ed<   dZeej                 ed<   dS )	ÚSquadHeadOutputaÜ  
    Base class for outputs of question answering models using a [`~modeling_utils.SQuADHead`].

    Args:
        loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned if both `start_positions` and `end_positions` are provided):
            Classification loss as the sum of start token, end token (and is_impossible if provided) classification
            losses.
        start_top_log_probs (`torch.FloatTensor` of shape `(batch_size, config.start_n_top)`, *optional*, returned if `start_positions` or `end_positions` is not provided):
            Log probabilities for the top config.start_n_top start token possibilities (beam-search).
        start_top_index (`torch.LongTensor` of shape `(batch_size, config.start_n_top)`, *optional*, returned if `start_positions` or `end_positions` is not provided):
            Indices for the top config.start_n_top start token possibilities (beam-search).
        end_top_log_probs (`torch.FloatTensor` of shape `(batch_size, config.start_n_top * config.end_n_top)`, *optional*, returned if `start_positions` or `end_positions` is not provided):
            Log probabilities for the top `config.start_n_top * config.end_n_top` end token possibilities
            (beam-search).
        end_top_index (`torch.LongTensor` of shape `(batch_size, config.start_n_top * config.end_n_top)`, *optional*, returned if `start_positions` or `end_positions` is not provided):
            Indices for the top `config.start_n_top * config.end_n_top` end token possibilities (beam-search).
        cls_logits (`torch.FloatTensor` of shape `(batch_size,)`, *optional*, returned if `start_positions` or `end_positions` is not provided):
            Log probabilities for the `is_impossible` label of the answers.

    NÚlossÚstart_top_log_probsÚstart_top_indexÚend_top_log_probsÚend_top_indexÚ
cls_logits)r  r  r  r  r{  r   rf   r]  Ú__annotations__r|  r}  rr  r~  r  r€  rm   rn   ro   rz  rz  Þ  s°   € € € € € € ðð ð* )-€Dˆ(�5Ô$Ô
%Ð,Ð,Ñ,Ø7;Ð˜ %Ô"3Ô4Ð;Ð;Ñ;Ø26€O�X˜eÔ.Ô/Ð6Ð6Ñ6Ø59Ð�x Ô 1Ô2Ð9Ð9Ñ9Ø04€M�8˜EÔ,Ô-Ð4Ð4Ñ4Ø.2€J�˜Ô*Ô+Ð2Ð2Ñ2Ð2Ð2rn   rz  c                   ó  ‡ — e Zd ZdZˆ fd„Z eee¬¦  «        	 	 	 	 	 	 ddej	        de
ej                 de
ej                 d	e
ej                 d
e
ej                 de
ej	                 dedeeeej	                 f         fd„¦   «         Zˆ xZS )Ú	SQuADHeadzæ
    A SQuAD head inspired by XLNet.

    Args:
        config ([`PretrainedConfig`]):
            The config used by the model, will be used to grab the `hidden_size` of the model and the `layer_norm_eps`
            to use.
    c                 óð   •— t          ¦   «                              ¦   «          |j        | _        |j        | _        t	          |¦  «        | _        t          |¦  «        | _        t          |¦  «        | _	        d S rý  )
r  r  Ústart_n_topÚ	end_n_toprP  Ústart_logitsr_  Ú
end_logitsrt  Úanswer_classrT  s     €ro   r  zSQuADHead.__init__  sc   ø€ Ý‰Œ×ÒÑÔÐØ!Ô-ˆÔØÔ)ˆŒå-¨fÑ5Ô5ˆÔÝ)¨&Ñ1Ô1ˆŒÝ-¨fÑ5Ô5ˆÔÐÐrn   )Úoutput_typer€  NFrU  ri  Úend_positionsrv  Úis_impossiblerV  Úreturn_dictr‚   c                 ó¾  — |                       ||¬¦  «        }|�Ø|�Ö||||fD ]1}	|	�-|	                     ¦   «         dk    r|	                     d¦  «         Œ2|                      |||¬¦  «        }
t	          ¦   «         } |||¦  «        } ||
|¦  «        }||z   dz  }|�A|�?|                      |||¬¦  «        }t          j        ¦   «         } |||¦  «        }||dz  z  }|rt          |¬	¦  «        n|fS | 	                    ¦   «         \  }}}t          j
                             |d¬
¦  «        }t          j        || j        d¬
¦  «        \  }}|                     d¦  «                             dd|¦  «        }t          j        |d|¦  «        }|                     d¦  «                             d|dd¦  «        }|                     d¦  «                             |¦  «        }|�|                     d¦  «        nd}|                      |||¬¦  «        }
t          j
                             |
d¬
¦  «        }t          j        || j        d¬
¦  «        \  }}|                     d| j        | j        z  ¦  «        }|                     d| j        | j        z  ¦  «        }t          j        d||¦  «        }|                      |||¬¦  «        }|s|||||fS t          |||||¬¦  «        S )a÷  
        Args:
            hidden_states (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`):
                Final hidden states of the model on the sequence tokens.
            start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                Positions of the first token for the labeled span.
            end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                Positions of the last token for the labeled span.
            cls_index (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                Position of the CLS token for each sentence in the batch. If `None`, takes the last token.
            is_impossible (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
                Whether the question has a possible answer in the paragraph or not.
            p_mask (`torch.FloatTensor` of shape `(batch_size, seq_len)`, *optional*):
                Mask for tokens at invalid position, such as query and special symbols (PAD, SEP, CLS). 1.0 means token
                should be masked.
            return_dict (`bool`, *optional*, defaults to `False`):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.

        Returns:
        )rV  Nr   rs   )ri  rV  r¸  )ri  rv  g      à?)r{  rl  r  )rh  rV  z
blh,bl->bh)rh  rv  )r|  r}  r~  r  r€  )r‡  r»  Úsqueeze_rˆ  r   r‰  r   ÚBCEWithLogitsLossrz  r”  rx  Úsoftmaxrf   Útopkr…  rß  rã  rm  Ú	expand_asr†  ÚviewÚeinsum)r¯  rU  ri  r‹  rv  rŒ  rV  r�  r‡  r[  rˆ  Úloss_fctÚ
start_lossÚend_lossÚ
total_lossr€  Úloss_fct_clsÚcls_lossÚbszrn  ro  Ústart_log_probsr|  r}  Ústart_top_index_exprh  Úhidden_states_expandedÚend_log_probsr~  r  s                                 ro   r\  zSQuADHead.forward  s7  € ð> ×(Ò(¨¸vÐ(ÑFÔFˆàÐ&¨=Ð+Dà% }°iÀÐOð #ð #�Ø�= Q§U¢U¡W¤W¨q¢[ [Ø—J’J˜r‘N”N�Nøð Ÿš¨ÈÐ`f˜ÑgÔgˆJå'Ñ)Ô)ˆHØ!˜ ,°Ñ@Ô@ˆJØ�x 
¨MÑ:Ô:ˆHØ$ xÑ/°1Ñ4ˆJàÐ$¨Ð)Bà!×.Ò.¨}ÈoÐirÐ.ÑsÔs�
Ý!Ô3Ñ5Ô5�Ø'˜<¨
°MÑBÔB�ð ˜h¨™nÑ,�
à7BÐU•?¨
Ð3Ñ3Ô3Ð3ÈÈÐUð +×/Ò/Ñ1Ô1‰NˆC��sÝ œm×3Ò3°LÀbÐ3ÑIÔIˆOå38´:Ø Ô!1°rð4ñ 4ô 4Ñ0Ð ð #2×";Ò";¸BÑ"?Ô"?×"FÒ"FÀrÈ2ÈsÑ"SÔ"SÐÝ œ<¨°rÐ;NÑOÔOˆLØ'×1Ò1°!Ñ4Ô4×;Ò;¸BÀÀbÈ"ÑMÔMˆLà%2×%<Ò%<¸QÑ%?Ô%?×%IÒ%IØñ&ô &Ð"ð .4Ð-?�V×%Ò% bÑ)Ô)Ð)ÀTˆFØŸšÐ)?ÈlÐci˜ÑjÔjˆJÝœM×1Ò1°*À!Ð1ÑDÔDˆMå/4¬zØ˜tœ~°1ð0ñ 0ô 0Ñ,Ð˜}ð !2× 6Ò 6°r¸4Ô;KÈdÌnÑ;\Ñ ]Ô ]ÐØ)×.Ò.¨r°4Ô3CÀdÄnÑ3TÑUÔUˆMå œ<¨°mÀ_ÑUÔUˆLØ×*Ò*¨=À|Ð_hÐ*ÑiÔiˆJàð 	Ø+¨_Ð>OÐQ^Ð`jÐkÐkå&Ø(;Ø$3Ø&7Ø"/Ø)ðñ ô ð rn   )NNNNNF)r  r  r  r  r  rC   rz  r   rf   r]  r   rr  rÀ   r   r   r\  rJ  rK  s   @ro   rƒ  rƒ  ý  s*  ø€ € € € € ðð ð6ð 6ð 6ð 6ð 6ð Ð¨?ÐIYÐZÑZÔZð 7;Ø48Ø04Ø48Ø.2Ø!ð^ð ^àÔ(ð^ð " %Ô"2Ô3ð^ð   Ô 0Ô1ð	^ð
 ˜EÔ,Ô-ð^ð   Ô 0Ô1ð^ð ˜Ô*Ô+ð^ð ð^ð 
ˆ  eÔ&7Ô 8Ð8Ô	9ð^ð ^ð ^ñ [ÔZð^ð ^ð ^ð ^ð ^rn   rƒ  c                   ój   ‡ — e Zd ZdZdefˆ fd„Z	 d	dej        deej	                 dej        fd„Z
ˆ xZS )
ÚSequenceSummaryaÒ  
    Compute a single vector summary of a sequence hidden states.

    Args:
        config ([`PretrainedConfig`]):
            The config used by the model. Relevant arguments in the config class of the model are (refer to the actual
            config class of your model for the default values it uses):

            - **summary_type** (`str`) -- The method to use to make this summary. Accepted values are:

                - `"last"` -- Take the last token hidden state (like XLNet)
                - `"first"` -- Take the first token hidden state (like Bert)
                - `"mean"` -- Take the mean of all tokens hidden states
                - `"cls_index"` -- Supply a Tensor of classification token position (GPT/GPT-2)
                - `"attn"` -- Not implemented now, use multi-head attention

            - **summary_use_proj** (`bool`) -- Add a projection after the vector extraction.
            - **summary_proj_to_labels** (`bool`) -- If `True`, the projection outputs to `config.num_labels` classes
              (otherwise to `config.hidden_size`).
            - **summary_activation** (`Optional[str]`) -- Set to `"tanh"` to add a tanh activation to the output,
              another string or `None` will add no activation.
            - **summary_first_dropout** (`float`) -- Optional dropout probability before the projection and activation.
            - **summary_last_dropout** (`float`)-- Optional dropout probability after the projection and activation.
    r×  c                 ó.  •— t          ¦   «                              ¦   «          t          |dd¦  «        | _        | j        dk    rt          ‚t          ¦   «         | _        t          |d¦  «        rW|j        rPt          |d¦  «        r|j	        r|j
        dk    r|j
        }n|j        }t          j        |j        |¦  «        | _        t          |dd ¦  «        }|rt          |¦  «        nt          ¦   «         | _        t          ¦   «         | _        t          |d¦  «        r)|j        dk    rt          j        |j        ¦  «        | _        t          ¦   «         | _        t          |d	¦  «        r+|j        dk    r"t          j        |j        ¦  «        | _        d S d S d S )
NÚsummary_typeÚlastÚattnÚsummary_use_projÚsummary_proj_to_labelsr   Úsummary_activationÚsummary_first_dropoutÚsummary_last_dropout)r  r  r[  r¤  rK  r   Úsummaryrf  r§  r¨  Ú
num_labelsrR  r   rœ  r   rd  Úfirst_dropoutrª  ÚDropoutÚlast_dropoutr«  )r¯  r×  Únum_classesÚactivation_stringr  s       €ro   r  zSequenceSummary.__init__Œ  s“  ø€ Ý‰Œ×ÒÑÔÐå# F¨N¸FÑCÔCˆÔØÔ Ò&Ð&õ &Ð%å‘z”zˆŒÝ�6Ð-Ñ.Ô.ð 	F°6Ô3Jð 	FÝ�vÐ7Ñ8Ô8ð 1¸VÔ=Zð 1Ð_eÔ_pÐstÒ_tÐ_tØ$Ô/��à$Ô0�Ýœ9 VÔ%7¸ÑEÔEˆDŒLå# FÐ,@À$ÑGÔGÐØIZÐ$j¥NÐ3DÑ$EÔ$EÐ$EÕ`hÑ`jÔ`jˆŒå%™ZœZˆÔÝ�6Ð2Ñ3Ô3ð 	J¸Ô8TÐWXÒ8XÐ8XÝ!#¤¨FÔ,HÑ!IÔ!IˆDÔå$™JœJˆÔÝ�6Ð1Ñ2Ô2ð 	H°vÔ7RÐUVÒ7VÐ7VÝ "¤
¨6Ô+FÑ GÔ GˆDÔÐÐð	Hð 	HÐ7VÐ7Vrn   NrU  rv  r‚   c                 ó:  — | j         dk    r|dd…df         }�n-| j         dk    r|dd…df         }�n| j         dk    r|                     d¬¦  «        }nò| j         d	k    rÕ|€=t          j        |d
dd…dd…f         |j        d         dz
  t          j        ¬¦  «        }nl|                     d¦  «                             d¦  «        }|                     d|                     ¦   «         dz
  z  | 	                    d¦  «        fz   ¦  «        }| 
                    d|¦  «                             d¦  «        }n| j         dk    rt          ‚|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|S )ak  
        Compute a single vector summary of a sequence hidden states.

        Args:
            hidden_states (`torch.FloatTensor` of shape `[batch_size, seq_len, hidden_size]`):
                The hidden states of the last layer.
            cls_index (`torch.LongTensor` of shape `[batch_size]` or `[batch_size, ...]` where ... are optional leading dimensions of `hidden_states`, *optional*):
                Used if `summary_type == "cls_index"` and takes the last token of the sequence as classification token.

        Returns:
            `torch.FloatTensor`: The summary of the sequence hidden states.
        r¥  Nrs   Úfirstr   Úmeanr   rl  rv  .r  r¹  )rs   r¦  )r¤  rµ  rf   Ú	full_likerÉ  Úlongrß  rã  r»  r”  rm  rZ  rK  r®  r¬  rd  r°  )r¯  rU  rv  rB  s       ro   r\  zSequenceSummary.forward©  sª  € ð Ô Ò&Ð&Ø" 1 1 1 b 5Ô)ˆF‰FØÔ 'Ò)Ð)Ø" 1 1 1 a 4Ô(ˆF‰FØÔ &Ò(Ð(Ø"×'Ò'¨AÐ'Ñ.Ô.ˆFˆFØÔ +Ò-Ð-ØÐ Ý!œOØ! # r¨ r¨1¨1¨1 *Ô-Ø!Ô'¨Ô+¨aÑ/Ýœ*ðñ ô �	�	ð &×/Ò/°Ñ3Ô3×=Ò=¸bÑAÔA�	Ø%×,Ò,¨U°i·m²m±o´oÈÑ6IÑ-JÈm×N`ÒN`ÐacÑNdÔNdÐMfÑ-fÑgÔg�	à"×)Ò)¨"¨iÑ8Ô8×@Ò@ÀÑDÔDˆFˆFØÔ &Ò(Ð(Ý%Ð%à×#Ò# FÑ+Ô+ˆØ—’˜fÑ%Ô%ˆØ—’ Ñ(Ô(ˆØ×"Ò" 6Ñ*Ô*ˆàˆrn   rý  rq  rK  s   @ro   r¢  r¢  r  sœ   ø€ € € € € ðð ð2HÐ/ð Hð Hð Hð Hð Hð Hð< Y]ð)ð )Ø"Ô.ð)Ø;CÀEÔDTÔ;Uð)à	Ô	ð)ð )ð )ð )ð )ð )ð )ð )rn   r¢  c                 óN   — t          | d¦  «        rt          | j        ¦  «        S | S )z¥
    Recursively unwraps a model from potential containers (as used in distributed training).

    Args:
        model (`torch.nn.Module`): The model to unwrap.
    r�   )rf  rë  r�   )r  s    ro   rë  rë  Õ  s+   € õ ˆu�hÑÔð Ý˜EœLÑ)Ô)Ð)àˆrn   c                 ó†   ‡‡— i }|                       ¦   «         D ]'\  ŠŠ|                     ˆˆfd„|D ¦   «         ¦  «         Œ(|S )zT
    Expand a device map to return the correspondance parameter name to device.
    c                 ó^   •— i | ])}|‰k    s|                      ‰› d �¦  «        s‰dk    ¯&|‰“Œ*S r5  rD  )rˆ   rí  r˜   r�   s     €€ro   rÞ  z%expand_device_map.<locals>.<dictcomp>ê  sE   ø€ ÐiÐiÐi˜1¨q°Fª{¨{¸a¿lºlÈfÈ<È<È<Ñ>XÔ>X¨{Ð\bÐfhÒ\hÐ\hˆQ�Ð\hÐ\hÐ\hrn   )r�   rŽ  )r†  Úparam_namesÚnew_device_mapr˜   r�   s      @@ro   r  r  ã  si   øø€ ð €NØ$×*Ò*Ñ,Ô,ð 
ð 
‰ˆ�Ø×ÒØiÐiÐiÐiÐi ÐiÑiÔiñ	
ô 	
ð 	
ð 	
ð Ðrn   c                 ó®  — t          j        t          ¦  «        }|d                              ¦   «         D ]„\  }}t	          |¦  «        dk    rK|| vrGd                     |                     d¦  «        dd…         ¦  «        }t	          |¦  «        dk    r|| v°G||                              | |         ¦  «         Œ…d„ |                     ¦   «         D ¦   «         S )zT
    Returns the list of shard files containing only weights offloaded to disk.
    rÑ   r   r¾   Nrs   c                 ó@   — g | ]\  }}t          |¦  «        d hk    ¯|‘ŒS )r|  )r  )rˆ   ÚfnameÚdevicess      ro   r‹   z-get_disk_only_shard_files.<locals>.<listcomp>ù  s0   € ÐZÐZÐZ‘n�e˜WÅÀWÁÄÐRXÐQYÒAYÐAYˆEÐAYÐAYÐAYrn   )rø  rù  r  r�   rÔ   rý   re  rÕ   )r†  ry  Úfiles_contentrò  r  s        ro   r  r  ï  sà   € õ  Ô+­DÑ1Ô1€MØ!1°,Ô!?×!EÒ!EÑ!GÔ!Gð @ð @Ñˆ�XÝ�+ÑÔ Ò"Ð" {¸*Ð'DÐ'DØŸ(š( ;×#4Ò#4°SÑ#9Ô#9¸#¸2¸#Ô#>Ñ?Ô?ˆKõ �+ÑÔ Ò"Ð" {¸*Ð'DÐ'Dà�hÔ×&Ò& z°+Ô'>Ñ?Ô?Ð?Ð?àZÐZ¨×(;Ò(;Ñ(=Ô(=ÐZÑZÔZÐZrn   r   )TT)	NNNNNNFFNrý  )¶rø  rº  r  Úimportlib.metadatar7  r‚  r  rj   rÁ   r	  r  rÄ  Ú
contextlibr   Údataclassesr   r   r   Útypingr   r   r	   r
   r   r   r   rf   Ú	packagingr   r   r   Útorch.nnr   r   Útorch.utils.checkpointr   Úactivationsr   Úconfiguration_utilsr   Údynamic_module_utilsr   Ú
generationr   r   r  r   r   r   Úpytorch_utilsr   r   r   r    r!   r"   r#   Úutilsr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   Ú	utils.hubrE   rF   Úutils.import_utilsrG   rH   rI   rJ   Úutils.quantization_configrK   rL   rM   rN   Úutils.versionsrO   rk   rl   ÚupperrP   rR   rn  rS   rT   rU   Úaccelerate.hooksrV   r�  rW   rX   rY   rZ   r[   r\   r]   r^   Úsafetensorsr_   Úsafetensors.torchr`   r	  ra   r  Ú
get_loggerr  rÿ   rz   rp   ru   Ú!smdistributed.modelparallel.torchÚmodelparallelró  Úsmdistributed.modelparallelrw   ÚSMP_VERSIONr6  rò  rx   r}   rš   r    r¦   r´   rº   r¼   rÆ   r›   rt   ræ   r!  rI  r
  r<  rc  rj  rr  r“  r–  r   r  rÊ  r  r'  rP  r_  rt  rz  rƒ  r¢  rë  r  r  rm   rn   ro   ú<module>rÜ     sR
  ðð  Ð Ð Ð Ø Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø €€€Ø 	€	€	€	Ø 	€	€	€	Ø €€€Ø €€€Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø !Ð !Ð !Ð !Ð !Ð !Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ Dà €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø -Ð -Ð -Ð -Ð -Ð -à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ Xðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð"ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ðF LÐ KÐ KÐ KÐ KÐ KÐ KÐ Kðð ð ð ð ð ð ð ð ð ð ð ð eÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dÐ dØ 0Ð 0Ð 0Ð 0Ð 0Ð 0ð Œz�~Š~˜n¨cÑ2Ô2×8Ò8Ñ:Ô:€Ø”J—N’NÐ#6¸Ñ<Ô<×BÒBÑDÔDÐ àÐÑÔð ØTÐTÐTÐTÐTÐTÐTÐTÐTÐTØ3Ð3Ð3Ð3Ð3Ð3ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð ÐÑÔð >Ø%Ð%Ð%Ð%Ð%Ð%Ø=Ð=Ð=Ð=Ð=Ð=Ø=Ð=Ð=Ð=Ð=Ð=à	ˆÔ	˜HÑ	%Ô	%€ð €ðð ð ðLð Lð Lð ÐÑÔð &Ø3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3ØFÐFÐFÐFÐFÐFà - ¤¨kÑ :Ô :¸m¸g¼mÈFÑ>SÔ>SÒ SÐÐà %ÐàÐÑÔð 0Ø/Ð/Ð/Ð/Ð/Ð/ð ð)ð )ð )ñ „ð)ð % E¨"¬)°_ÐFXÐ*XÔ$Yð %ð %ð %ð %ð$¨¨r¬y¸/ÐK]Ð/]Ô)^ð $ð $ð $ð $ð$. 5¨¬°OÐEWÐ)WÔ#Xð .ð .ð .ð .ðbNð Nð Nð
/ð 
/ð 
/ðð ð ð* LRÐgsðPð PØ�S˜%œ,Ð&Ô'ðPØ9>¸sÀC¸x¼ðPØadðPð Pð Pð PðfQTð QTð QTð QTðh+ U¨3°´Ð+;Ô%<ð +ð +ð +ð +ð\-ð -ð -ð:ð :ð :ðz#ð #ð #ð.4ð 4ð 4ð@ ØØØØØ
ØØØð7ð 7ð 7ð 7ðDð ˜sð ¨X°c¬]ð Àcð ð ð ð ðmqð mqð mqð mqð mqñ mqô mqð mqð`	y/-ð y/-ð y/-ð y/-ð y/-�b”iÐ!1°?ÀNÐTdñ y/-ô y/-ð y/-ðx_ (˜i¨Ô(CÑDÔD€Ô ØÔÔ&Ð2Ø*9Ô*EÔ*M×*TÒ*TØ [¸|ð +Uñ +ô +€OÔÔ'ð
#ð #ð #ð #ð #˜œ	ñ #ô #ð #ðLBð Bð Bð Bð B�b”iñ Bô Bð BðJ>ð >ð >ð >ð >˜œ	ñ >ô >ð >ðB ð3ð 3ð 3ð 3ð 3�kñ 3ô 3ñ „ð3ð<rð rð rð rð r�”	ñ rô rð rðj`ð `ð `ð `ð `�b”iñ `ô `ð `ðF˜œ	ð  b¤ið ð ð ð ð	ð 	ð 	ð
[ð 
[ð 
[ð 
[ð 
[rn   