
    Z j                         S r SSKrSSKJrJrJrJrJr  SSKJ	r	  SSK
Jr  SSKJr  \R                  " \5      rSS	S
.r " S S\5      rS/rg)z Tokenization class for model T5.    N)	Tokenizerdecodersnormalizerspre_tokenizers
processors)Unigram   )TokenizersBackend)loggingzspiece.modelztokenizer.json)
vocab_filetokenizer_filec                   ~   ^  \ rS rSrSr\rSS/r\r	       SS\
\\\
\4      -  S-  4U 4S jjjrS rS	 rS
rU =r$ )T5Tokenizer   aN  
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           	      d  > X`l         Ub~  U V	s/ s H  n	S[        U	5      ;   d  M  U	PM     n
n	[        U
5      S:  a$  U[        U5       Vs/ s H	  nSU S3PM     sn-  nOIUS:  a!  U[        U
5      :w  a  [	        SU SU S35      eO![        U5       Vs/ s H	  nSU S3PM     n
nU
nUb  Xl        Od[        U5      S4[        U5      S4[        U5      S4S	/U l        [        US-
  S
S
5       H$  nU R
                  R                  SU S3S45        M&     [        [        U R
                  SSS95      U l	        Ub%  [        R                  " U5      U R                  l        [        R                  " [        R                  " 5       [        R                   " SSSS9/5      U R                  l        [$        R                   " SSSS9U R                  l        [(        TU ]T  " SUUUUUS.UD6  [,        R.                  " SS// SQSU R0                  4/S9U R                  l        g s  sn	f s  snf s  snf )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               w/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/t5/tokenization_t5.pyr;   T5Tokenizer.__init__G   sa    $ %0'@['@!LTWXYTZDZA'@L[< 1$)yIY-ZIYA
1#Q.?IY-ZZ)Q9L0A#A &yk1RSlRm n   8=Y7GH7G!j1-7GLH(4% !& Y%Y%Y%	"D 9q="b1""))Zs!+<c*BC 2 $""#
 %0)4)@)@AZ)[DOO&(6(?(?..0((U8[_`)
% #+"4"4W_gk"l 	
&?	
 	
 *4)F)F&>-**+*
&m \-Z Is   H#H#H(H-c                 T    [        [        [        S U R                  5      5      5      $ )zQGet the list of sentinel tokens (extra_id tokens) from additional_special_tokens.c                 F    [        [        R                  " SU 5      5      S L$ )Nz<extra_id_\d+>)boolresearch)rB   s    rF   <lambda>1T5Tokenizer.get_sentinel_tokens.<locals>.<lambda>   s    bii0A1&E!Fd!R    )listsetfilterr$   )r?   s    rF   get_sentinel_tokensT5Tokenizer.get_sentinel_tokens   s&    RTXTrTrst
 	
rO   c                 j    U R                  5        Vs/ s H  oR                  U5      PM     sn$ s  snf )z&Get the token IDs for sentinel tokens.)rS   convert_tokens_to_ids)r?   tokens     rF   get_sentinel_token_ids"T5Tokenizer.get_sentinel_token_ids   s.    ?C?W?W?YZ?Ye**51?YZZZs   0)r+   r2   r0   )Nr&   z<unk>z<pad>Nd   N)__name__
__module____qualname____firstlineno____doc__VOCAB_FILES_NAMESvocab_files_namesmodel_input_namesr   modelr,   rP   tuplefloatr;   rS   rX   __static_attributes____classcell__)rE   s   @rF   r   r      sx    "H *$&67E 7;"&"&K
T%U
+,,t3K
 K
Z
[ [rO   r   )r_   rK   
tokenizersr   r   r   r   r   tokenizers.modelsr   tokenization_utils_tokenizersr
   utilsr   
get_loggerr[   loggerr`   r   __all__r*   rO   rF   <module>ro      sU    ' 	 S S % >  
		H	%#1EUV ~[# ~[B /rO   