Ë
    T^(hÆ  ã                   ó¶   — d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 ddl
mZmZ  e«       rdd	lmZ ndZ ej                  e«      Zd
ddœZ G d„ de	«      ZdgZy)zTokenization classes for XGLM.é    N)Úcopyfile)ÚListÚOptionalÚTupleé   )ÚPreTrainedTokenizerFast)Úis_sentencepiece_availableÚloggingé   )ÚXGLMTokenizerzsentencepiece.bpe.modelztokenizer.json)Ú
vocab_fileÚtokenizer_filec                   óÜ   ‡ — e Zd ZdZeZddgZeZ	 	 	 	 	 	 	 	 dˆ fd„	Z	e
defd„«       Z	 ddee   deee      dee   fd	„Z	 ddee   deee      dee   fd
„Zddedee   dee   fd„Zˆ xZS )ÚXGLMTokenizerFasta{	  
    Construct a "fast" XGLM tokenizer (backed by HuggingFace's *tokenizers* library). Adapted from [`RobertaTokenizer`]
    and [`XLNetTokenizer`]. Based on
    [BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models).

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

    Args:
        vocab_file (`str`):
            Path to the vocabulary file.
        bos_token (`str`, *optional*, defaults to `"<s>"`):
            The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.

            <Tip>

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

            </Tip>

        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>

        sep_token (`str`, *optional*, defaults to `"</s>"`):
            The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
            sequence classification or for a text and a question for question answering. It is also used as the last
            token of a sequence built with special tokens.
        cls_token (`str`, *optional*, defaults to `"<s>"`):
            The classifier token which is used when doing sequence classification (classification of the whole sequence
            instead of per-token classification). It is the first token of the sequence when built with special tokens.
        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.
        additional_special_tokens (`List[str]`, *optional*, defaults to `["<s>NOTUSED", "</s>NOTUSED"]`):
            Additional special tokens used by the tokenizer.
    Ú	input_idsÚattention_maskc	                 ó*  •— d| _         t        | j                   «      D �
cg c]  }
d|
› d�‘Œ
 }}
|	j                  dg «      xs g |	d<   |	dxx   |D �cg c]  }||	d   vsŒ|‘Œ c}z  cc<   t        ‰| �  |f|||||||dœ|	¤Ž || _        y c c}
w c c}w )Né   z<madeupwordú>Úadditional_special_tokens)r   Ú	bos_tokenÚ	eos_tokenÚ	sep_tokenÚ	cls_tokenÚ	unk_tokenÚ	pad_token)Únum_madeup_wordsÚrangeÚgetÚsuperÚ__init__r   )Úselfr   r   r   r   r   r   r   r   ÚkwargsÚiÚmadeup_wordsÚwordÚ	__class__s                €úm/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/xglm/tokenization_xglm_fast.pyr!   zXGLMTokenizerFast.__init__X   sÍ   ø€ ð !"ˆÔÜ49¸$×:OÑ:OÓ4PÖQ¨q˜+ a S¨Ò*ÐQˆÐQà.4¯j©jÐ9TÐVXÓ.YÒ._Ð]_ˆÐ*Ñ+ØÐ*Ó+Ø)ö0
Ø¨T¸Ð@[Ñ9\Ò-\ŠDò0
ñ 	
Ó+ô 	‰ÑØð
	
à)ØØØØØØñ
	
ð ò
	
ð %ˆ�ùò' Rùò0
s    BÁB
ÁB
Úreturnc                 óp   — | j                   r)t        j                  j                  | j                   «      S dS )NF)r   ÚosÚpathÚisfile)r"   s    r(   Úcan_save_slow_tokenizerz)XGLMTokenizerFast.can_save_slow_tokenizer{   s$   € à26·/²/Œr�w‰w�~‰~˜dŸo™oÓ.ÐLÀuÐLó    Útoken_ids_0Útoken_ids_1c                 ó\   — |€| j                   g|z   S | j                   g}||z   |z   |z   |z   S )a›  
        Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
        adding special tokens. An XLM-RoBERTa sequence has the following format:

        - single sequence: `<s> X </s>`
        - pair of sequences: `<s> A </s></s> B </s>`

        Args:
            token_ids_0 (`List[int]`):
                List of IDs to which the special tokens will be added.
            token_ids_1 (`List[int]`, *optional*):
                Optional second list of IDs for sequence pairs.

        Returns:
            `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
        )Úsep_token_id©r"   r0   r1   Úseps       r(   Ú build_inputs_with_special_tokensz2XGLMTokenizerFast.build_inputs_with_special_tokens   sF   € ð( ÐØ×%Ñ%Ð&¨Ñ4Ð4Ø× Ñ Ð!ˆØ�[Ñ  3Ñ&¨Ñ,¨{Ñ:Ð:r/   c                 óz   — | j                   g}|€t        ||z   «      dgz  S t        ||z   |z   |z   |z   «      dgz  S )aÑ  
        Create a mask from the two sequences passed to be used in a sequence-pair classification task. XLM-RoBERTa does
        not make use of token type ids, therefore a list of zeros is returned.

        Args:
            token_ids_0 (`List[int]`):
                List of IDs.
            token_ids_1 (`List[int]`, *optional*):
                Optional second list of IDs for sequence pairs.

        Returns:
            `List[int]`: List of zeros.

        r   )r3   Úlenr4   s       r(   Ú$create_token_type_ids_from_sequencesz6XGLMTokenizerFast.create_token_type_ids_from_sequences˜   sU   € ð$ × Ñ Ð!ˆàÐÜ�s˜[Ñ(Ó)¨Q¨CÑ/Ð/Ü�3˜Ñ$ sÑ*¨SÑ0°;Ñ>Ó?À1À#ÑEÐEr/   Úsave_directoryÚfilename_prefixc                 óÈ  — | j                   st        d«      ‚t        j                  j	                  |«      st
        j                  d|› d�«       y t        j                  j                  ||r|dz   ndt        d   z   «      }t        j                  j                  | j                  «      t        j                  j                  |«      k7  rt        | j                  |«       |fS )NzhYour fast tokenizer does not have the necessary information to save the vocabulary for a slow tokenizer.zVocabulary path (z) should be a directory.ú-Ú r   )r.   Ú
ValueErrorr+   r,   ÚisdirÚloggerÚerrorÚjoinÚVOCAB_FILES_NAMESÚabspathr   r   )r"   r:   r;   Úout_vocab_files       r(   Úsave_vocabularyz!XGLMTokenizerFast.save_vocabulary°   sµ   € Ø×+Ò+Üðóð ô
 �w‰w�}‰}˜^Ô,Ü�L‰LÐ,¨^Ð,<Ð<TÐUÔVØÜŸ™Ÿ™Ø±o˜_¨sÒ2È2ÔQbÐcoÑQpÑpó
ˆô �7‰7�?‰?˜4Ÿ?™?Ó+¬r¯w©w¯©¸~Ó/NÒNÜ�T—_‘_ nÔ5àÐ Ð r/   )NNú<s>ú</s>rI   rH   z<unk>z<pad>)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rD   Úvocab_files_namesÚmodel_input_namesr   Úslow_tokenizer_classr!   ÚpropertyÚboolr.   r   Úintr   r6   r9   Ústrr   rG   Ú__classcell__)r'   s   @r(   r   r   $   sô   ø„ ñ-ð^ *ÐØ$Ð&6Ð7ÐØ(Ðð ØØØØØØØõ!%ðF ðM¨ò Mó ðMð JNñ;Ø ™9ð;Ø3;¸DÀ¹IÑ3Fð;à	ˆc‰ó;ð4 JNñFØ ™9ðFØ3;¸DÀ¹IÑ3FðFà	ˆc‰óFñ0!¨cð !ÀHÈSÁMð !Ð]bÐcfÑ]g÷ !r/   r   )rM   r+   Úshutilr   Útypingr   r   r   Útokenization_utils_fastr   Úutilsr	   r
   Útokenization_xglmr   Ú
get_loggerrJ   rA   rD   r   Ú__all__© r/   r(   ú<module>r^      sf   ðñ %ã 	Ý ß (Ñ (å >ß 8ñ ÔÞ0à€Mð 
ˆ×	Ñ	˜HÓ	%€à#<ÐP`ÑaÐ ô]!Ð/ô ]!ð@ Ð
�r/   