Ë
    ÜÓ^jŒ  ã                   óš   — d Z ddlZddlmZmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ  ej                  e«      Zdd	d
œZ G d„ de«      ZdgZy)z Tokenization class for model T5.é    N)Ú	TokenizerÚdecodersÚnormalizersÚpre_tokenizersÚ
processors)ÚUnigramé   )ÚTokenizersBackend)Úloggingzspiece.modelztokenizer.json)Ú
vocab_fileÚtokenizer_filec                   óp   ‡ — e Zd ZdZeZddgZeZ	 	 	 	 	 	 	 d	de	e
ee	ef      z  dz  fˆ fd„Zd„ Zd„ Zˆ xZS )
ÚT5Tokenizera¾  
    Construct a T5 tokenizer (backed by HuggingFace's *tokenizers* library). Based on
    [Unigram](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=unigram#models).

    This tokenizer inherits from [`TokenizersBackend`] which contains most of the main methods. Users should
    refer to this superclass for more information regarding those methods.

    Args:
        vocab_file (`str`, *optional*):
            [SentencePiece](https://github.com/google/sentencepiece) file (generally has a *.spm* extension) that
            contains the vocabulary necessary to instantiate a tokenizer.
        eos_token (`str`, *optional*, defaults to `"</s>"`):
            The end of sequence token.

            <Tip>

            When building a sequence using special tokens, this is not the token that is used for the end of sequence.
            The token used is the `sep_token`.

            </Tip>

        unk_token (`str`, *optional*, defaults to `"<unk>"`):
            The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
            token instead.
        pad_token (`str`, *optional*, defaults to `"<pad>"`):
            The token used for padding, for example when batching sequences of different lengths.
        extra_ids (`int`, *optional*, defaults to 100):
            Add a number of extra ids added to the vocabulary for use as sentinels. These tokens are accessible as
            "<extra_id_{%d}>" where "{%d}" is a number between 0 and extra_ids-1. These tokens can be retrieved by
            calling get_sentinel_tokens method and token ids can be by calling get_sentinel_token_ids method
        additional_special_tokens (`list[str]`, *optional*):
            Additional special tokens used by the tokenizer.
        vocab (`str`, `dict` or `list`, *optional*):
            Custom vocabulary dict. If not provided, a minimal vocabulary is created using the special tokens.
    Ú	input_idsÚattention_maskNÚvocabc           	      óH  •— || _         |�q|D �	cg c]  }	dt        |	«      v sŒ|	‘Œ }
}	t        |
«      dk  r!|t        |«      D �cg c]  }d|› d�‘Œ
 c}z  }nC|dkD  r>|t        |
«      k7  r0t	        d|› d|› d�«      ‚t        |«      D �cg c]  }d|› d�‘Œ
 }
}|
}|�|| _        nbt        |«      dft        |«      dft        |«      dfd	g| _        t        |dz
  d
d
«      D ]#  }| j
                  j                  d|› d�df«       Œ% t        t        | j
                  dd¬«      «      | _	        |�$t        j                  |«      | j                  _        t        j                  t        j                  «       t        j                   ddd¬«      g«      | j                  _        t%        j                   ddd¬«      | j                  _        t)        ‰| �T  d|||||dœ|¤Ž t-        j.                  ddgg d¢d| j0                  fg¬«      | j                  _        y c c}	w c c}w c c}w )Nz
<extra_id_é   ú>r   zBoth extra_ids (z!) and additional_special_tokens (zk) are provided to T5Tokenizer. In this case the additional_special_tokens must include the extra_ids tokensg        )õ   â–�g       Àéÿÿÿÿé   F)Úunk_idÚbyte_fallbackr   ÚalwaysT)ÚreplacementÚprepend_schemeÚsplit)Ú	eos_tokenÚ	unk_tokenÚ	pad_tokenÚ	extra_idsÚadditional_special_tokensú$Aú</s>)r$   r%   z$Br%   )ÚsingleÚpairÚspecial_tokens© )Ú
_extra_idsÚstrÚlenÚrangeÚ
ValueErrorÚ_vocab_scoresÚappendr   r   Ú
_tokenizerr   ÚPrecompiledÚ
normalizerr   ÚSequenceÚWhitespaceSplitÚ	MetaspaceÚpre_tokenizerr   ÚdecoderÚsuperÚ__init__r   ÚTemplateProcessingÚeos_token_idÚpost_processor)Úselfr   r   r    r!   Ú_spm_precompiled_charsmapr"   r#   ÚkwargsÚxÚextra_tokensÚiÚ	__class__s               €úq/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/t5/tokenization_t5.pyr:   zT5Tokenizer.__init__G   s_  ø€ ð $ˆŒð %Ð0Ø'@Ö[ !ÀLÔTWÐXYÓTZÒDZšAÐ[ˆLÐ[Ü�<Ó  1Ò$Ø)ÌÈyÓIYÖ-ZÀA°
¸1¸#¸QÒ.?Ò-ZÑZÑ)Ø˜Q’ 9´°LÓ0AÒ#AÜ Ø& y kÐ1RÐSlÐRmð nð óð ô 8=¸YÓ7GÖH°!˜j¨¨¨1Ò-ÐHˆLÐHØ(4Ð%ð ÐØ!&ˆDÕô �Y“ Ð%Ü�Y“ Ð%Ü�Y“ Ð%Øð	"ˆDÔô ˜9 q™=¨"¨bÓ1ò D�Ø×"Ñ"×)Ñ)¨Z¸°s¸!Ð+<¸cÐ*BÕCðDô $ÜØ×"Ñ"ØØ#ôó
ˆŒð %Ð0Ü)4×)@Ñ)@ÐAZÓ)[ˆD�O‰OÔ&ä(6×(?Ñ(?ä×.Ñ.Ó0Ü×(Ñ(°UÈ8Ð[_Ô`ðó)
ˆ�‰Ô%ô #+×"4Ñ"4ÀÐW_ÐgkÔ"lˆ�‰Ôä‰Ñð 	
ØØØØØ&?ñ	
ð ò	
ô *4×)FÑ)FØ˜&�>Ú-à˜×*Ñ*Ð+ðô*
ˆ�‰Õ&ùòm \ùâ-Zùò Is   �H¢HÁHÂ	Hc                 óT   — t        t        t        d„ | j                  «      «      «      S )zQGet the list of sentinel tokens (extra_id tokens) from additional_special_tokens.c                 óD   — t        t        j                  d| «      «      d uS )Nz<extra_id_\d+>)ÚboolÚreÚsearch)rA   s    rE   ú<lambda>z1T5Tokenizer.get_sentinel_tokens.<locals>.<lambda>—   s   € ¤¤b§i¡iÐ0AÀ1Ó&EÓ!FÈdÐ!R€ ó    )ÚlistÚsetÚfilterr#   )r>   s    rE   Úget_sentinel_tokenszT5Tokenizer.get_sentinel_tokens”   s&   € äÜ”ÑRÐTX×TrÑTrÓsÓtó
ð 	
rL   c                 óf   — | j                  «       D �cg c]  }| j                  |«      ‘Œ c}S c c}w )z&Get the token IDs for sentinel tokens.)rP   Úconvert_tokens_to_ids)r>   Útokens     rE   Úget_sentinel_token_idsz"T5Tokenizer.get_sentinel_token_idsš   s*   € à?C×?WÑ?WÓ?YÖZ°e�×*Ñ*¨5Õ1ÒZÐZùÒZs   “.)Nr%   z<unk>z<pad>Néd   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚVOCAB_FILES_NAMESÚvocab_files_namesÚmodel_input_namesr   Úmodelr+   rM   ÚtupleÚfloatr:   rP   rT   Ú__classcell__)rD   s   @rE   r   r      sl   ø„ ñ"ðH *ÐØ$Ð&6Ð7ÐØ€Eð 7;ØØØØ"&ØØ"&ñK
à�T˜%  U 
Ñ+Ñ,Ñ,¨tÑ3õK
òZ
ö[rL   r   )rY   rI   Ú
tokenizersr   r   r   r   r   Útokenizers.modelsr   Útokenization_utils_tokenizersr
   Úutilsr   Ú
get_loggerrV   ÚloggerrZ   r   Ú__all__r)   rL   rE   ú<module>rh      sW   ðñ 'ã 	ç SÕ SÝ %å >Ý ð 
ˆ×	Ñ	˜HÓ	%€à#1ÐEUÑVÐ ô~[Ð#ô ~[ðB ˆ/�rL   