Ë
    S^(h|  ã                   ó˜   — d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ  e
j                  e«      Zd	d
ddœZ G d„ de«      ZdgZy)z$Tokenization classes for OpenAI GPT.é    )ÚListÚOptionalÚTuple)Úpre_tokenizersé   )ÚPreTrainedTokenizerFast)Úloggingé   )ÚCLIPTokenizerz
vocab.jsonz
merges.txtztokenizer.json)Ú
vocab_fileÚmerges_fileÚtokenizer_filec                   óÊ   ‡ — e Zd ZdZeZddgZeZ	 	 	 	 	 	 	 dˆ fd„	Z	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 )ÚCLIPTokenizerFastaÊ  
    Construct a "fast" CLIP tokenizer (backed by HuggingFace's *tokenizers* library). Based on byte-level
    Byte-Pair-Encoding.

    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`, *optional*):
            Path to the vocabulary file.
        merges_file (`str`, *optional*):
            Path to the merges file.
        tokenizer_file (`str`, *optional*):
            The path to a tokenizer file to use instead of the vocab file.
        unk_token (`str`, *optional*, defaults to `"<|endoftext|>"`):
            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.
        bos_token (`str`, *optional*, defaults to `"<|startoftext|>"`):
            The beginning of sequence token.
        eos_token (`str`, *optional*, defaults to `"<|endoftext|>"`):
            The end of sequence token.
        pad_token (`str`, *optional*, defaults to `"<|endoftext|>"`):
            The token used for padding, for example when batching sequences of different lengths.
    Ú	input_idsÚattention_maskc           	      óÆ   •— t        ‰	| �  ||f|||||dœ|¤Ž t        | j                  j                  t
        j                  «      st        d«      ‚| j                  «        y )N)r   Ú	unk_tokenÚ	bos_tokenÚ	eos_tokenÚ	pad_tokenaÌ  The `backend_tokenizer` provided does not match the expected format. The CLIP tokenizer has been heavily modified from transformers version 4.17.0. You need to convert the tokenizer you are using to be compatible with this version.The easiest way to do so is `CLIPTokenizerFast.from_pretrained("path_to_local_folder_or_hub_repo, from_slow=True)`. If you want to use your existing tokenizer, you will have to revert to a version prior to 4.17.0 of transformers.)	ÚsuperÚ__init__Ú
isinstanceÚbackend_tokenizerÚpre_tokenizerr   ÚSequenceÚ
ValueErrorÚ%_wrap_decode_method_backend_tokenizer)
Úselfr   r   r   r   r   r   r   ÚkwargsÚ	__class__s
            €úm/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/clip/tokenization_clip_fast.pyr   zCLIPTokenizerFast.__init__=   sv   ø€ ô 	‰ÑØØð		
ð *ØØØØñ		
ð ò		
ô ˜$×0Ñ0×>Ñ>Ä×@WÑ@WÔXÜð!óð ð 	×2Ñ2Õ4ó    c                 ó¢   ‡‡— | j                   j                  Š| j                   j                  j                  Šˆˆfd„}|| j                   _        y )Nc                  óX   •—  ‰| i |¤Ž}|j                  ‰d«      j                  «       }|S )Nú )ÚreplaceÚstrip)Úargsr!   ÚtextÚend_of_word_suffixÚorig_decode_methods      €€r#   Únew_decode_methodzRCLIPTokenizerFast._wrap_decode_method_backend_tokenizer.<locals>.new_decode_methodf   s1   ø€ Ù% tÐ6¨vÑ6ˆDØ—<‘<Ð 2°CÓ8×>Ñ>Ó@ˆDØˆKr$   )r   ÚdecodeÚmodelr,   )r    r.   r,   r-   s     @@r#   r   z7CLIPTokenizerFast._wrap_decode_method_backend_tokenizer_   sD   ù€ Ø!×3Ñ3×:Ñ:Ðð "×3Ñ3×9Ñ9×LÑLÐõ	ð
 ):ˆ×ÑÕ%r$   Útoken_ids_0Útoken_ids_1Úreturnc                 ól   — | j                   g}| j                  g}|€||z   |z   S ||z   |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. A CLIP sequence has the following format:

        - single sequence: `<|startoftext|> X <|endoftext|>`

        Pairs of sequences are not the expected use case, but they will be handled without a separator.

        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.
        )Úbos_token_idÚeos_token_id©r    r1   r2   r   r   s        r#   Ú build_inputs_with_special_tokensz2CLIPTokenizerFast.build_inputs_with_special_tokensm   sU   € ð( ×&Ñ&Ð'ˆ	Ø×&Ñ&Ð'ˆ	àÐØ˜{Ñ*¨YÑ6Ð6Ø˜;Ñ&¨Ñ2°YÑ>ÀÑLÈyÑXÐXr$   c                 ó    — | j                   g}| j                  g}|€t        ||z   |z   «      dgz  S t        ||z   |z   |z   |z   |z   «      dgz  S )a—  
        Create a mask from the two sequences passed. CLIP 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   )r5   r6   Úlenr7   s        r#   Ú$create_token_type_ids_from_sequencesz6CLIPTokenizerFast.create_token_type_ids_from_sequencesˆ   sp   € ð  ×&Ñ&Ð'ˆ	Ø×&Ñ&Ð'ˆ	àÐÜ�y ;Ñ.°Ñ:Ó;¸q¸cÑAÐAÜ�9˜{Ñ*¨YÑ6¸ÑBÀ[ÑPÐS\Ñ\Ó]ÐabÐ`cÑcÐcr$   Úsave_directoryÚfilename_prefixc                 óf   — | j                   j                  j                  ||¬«      }t        |«      S )N)Úname)Ú
_tokenizerr0   ÚsaveÚtuple)r    r<   r=   Úfiless       r#   Úsave_vocabularyz!CLIPTokenizerFast.save_vocabularyŸ   s+   € Ø—‘×%Ñ%×*Ñ*¨>ÀÐ*ÓPˆÜ�U‹|Ðr$   )NNNú<|endoftext|>z<|startoftext|>rE   rE   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚVOCAB_FILES_NAMESÚvocab_files_namesÚmodel_input_namesr   Úslow_tokenizer_classr   r   r   Úintr   r8   r;   Ústrr   rD   Ú__classcell__)r"   s   @r#   r   r      sÛ   ø„ ñð2 *ÐØ$Ð&6Ð7ÐØ(Ðð ØØØ!Ø#Ø!Ø!õ5òD:ð JNñYØ ™9ðYØ3;¸DÀ¹IÑ3FðYà	ˆc‰óYð8 JNñdØ ™9ðdØ3;¸DÀ¹IÑ3Fðdà	ˆc‰ódñ.¨cð ÀHÈSÁMð Ð]bÐcfÑ]g÷ r$   r   N)rI   Útypingr   r   r   Ú
tokenizersr   Útokenization_utils_fastr   Úutilsr	   Útokenization_clipr   Ú
get_loggerrF   ÚloggerrJ   r   Ú__all__© r$   r#   ú<module>rZ      sX   ðñ +ç (Ñ (å %å >Ý Ý ,ð 
ˆ×	Ñ	˜HÓ	%€à#/ÀÐ`pÑqÐ ôBÐ/ô BðJ Ð
�r$   