Ë
    ÜÓ^j/  ã                   ód   — d Z ddlmZmZ ddlmZ  ej                  e«      Z G d„ de«      Z	dgZ
y)z!Tokenization class for Perceiver.é   )Ú
AddedTokenÚPreTrainedTokenizer)Úloggingc            
       ó  ‡ — e Zd ZdZddgZ	 	 	 	 	 	 	 d	 dˆ fd„Zdeeef   fd„Z	e
d„ «       Z	 dd	ee   d
ee   dz  dedee   fˆ fd„Z	 dd	ee   d
ee   dz  dee   fd„Zdedee   fd„Zd„ Zd„ Zd„ Zddededz  dee   fd„Zˆ xZS )ÚPerceiverTokenizeraS  
    Construct a Perceiver tokenizer. The Perceiver simply uses raw bytes utf-8 encoding.

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

    Args:
        pad_token (`str`, *optional*, defaults to `"[PAD]"`):
            The token used for padding, for example when batching sequences of different lengths.
        bos_token (`str`, *optional*, defaults to `"[BOS]"`):
            The BOS token (reserved in the vocab, but not actually used).
        eos_token (`str`, *optional*, defaults to `"[EOS]"`):
            The end of sequence token (reserved in the vocab, but not actually used).

            <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>

        mask_token (`str`, *optional*, defaults to `"[MASK]"`):
            The MASK token, useful for masked language modeling.
        cls_token (`str`, *optional*, defaults to `"[CLS]"`):
            The CLS token (reserved in the vocab, but not actually used).
        sep_token (`str`, *optional*, defaults to `"[SEP]"`):
            The separator token, which is used when building a sequence from two sequences.

    Ú	input_idsÚattention_maskÚreturnNc                 ó  •— t        |t        «      rt        |dd¬«      n|}t        |t        «      rt        |dd¬«      n|}t        |t        «      rt        |dd¬«      n|}t        |t        «      rt        |dd¬«      n|}t        |t        «      rt        |dd¬«      n|}t        |t        «      rt        |dd¬«      n|}d| _        ||||||dœ| _        t        | j                  «      | _        t        ‰	| �   d|||||||dœ|¤Ž y )NF)ÚlstripÚrstripé   )é    é   é   r   é   é   )Ú	pad_tokenÚ	bos_tokenÚ	eos_tokenÚ
mask_tokenÚ	cls_tokenÚ	sep_tokenÚmodel_max_length© )	Ú
isinstanceÚstrr   Ú_utf_vocab_sizeÚ_added_tokens_decoderÚlenÚ_num_special_tokensÚsuperÚ__init__)
Úselfr   r   r   r   r   r   r   ÚkwargsÚ	__class__s
            €ú/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/perceiver/tokenization_perceiver.pyr#   zPerceiverTokenizer.__init__8   s  ø€ ô JTÐT]Ô_bÔIc”J˜y°¸uÕEÐirˆ	ÜISÐT]Ô_bÔIc”J˜y°¸uÕEÐirˆ	ÜISÐT]Ô_bÔIc”J˜y°¸uÕEÐirˆ	ÜKUÐV`ÔbeÔKf”Z 
°5ÀÕGÐlvˆ
ÜISÐT]Ô_bÔIc”J˜y°¸uÕEÐirˆ	ÜISÐT]Ô_bÔIc”J˜y°¸uÕEÐirˆ	à#ˆÔð ØØØØØñ6
ˆÔ"ô $' t×'AÑ'AÓ#BˆÔ Ü‰Ñð 		
ØØØØ!ØØØ-ñ		
ð ó		
ó    c                 ó®   — i }t        | j                  «      D ]  }t        |«      }|| j                  z   ||<   Œ! |j	                  | j
                  «       |S ©N)Úranger   Úchrr!   ÚupdateÚadded_tokens_encoder)r$   ÚvocabÚiÚtokens       r'   Ú	get_vocabzPerceiverTokenizer.get_vocaba   sW   € ØˆÜ�t×+Ñ+Ó,ò 	8ˆAÜ˜“FˆEØ˜t×7Ñ7Ñ7ˆE�%ŠLð	8ð 	�‰�T×.Ñ.Ô/Øˆr(   c                 ó   — | j                   S r*   )r   )r$   s    r'   Ú
vocab_sizezPerceiverTokenizer.vocab_sizei   s   € à×#Ñ#Ð#r(   Útoken_ids_0Útoken_ids_1Úalready_has_special_tokensc                 ó´   •— |rt         ‰| �  ||d¬«      S |€dgdgt        |«      z  z   dgz   S dgdgt        |«      z  z   dgz   dgt        |«      z  z   dgz   S )aÄ  
        Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
        special tokens using the tokenizer `prepare_for_model` method.

        Args:
            token_ids_0 (`list[int]`):
                List of IDs.
            token_ids_1 (`list[int]`, *optional*):
                Optional second list of IDs for sequence pairs.
            already_has_special_tokens (`bool`, *optional*, defaults to `False`):
                Whether or not the token list is already formatted with special tokens for the model.

        Returns:
            `list[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
        T)r5   r6   r7   r   r   )r"   Úget_special_tokens_maskr    )r$   r5   r6   r7   r&   s       €r'   r9   z*PerceiverTokenizer.get_special_tokens_maskm   s‰   ø€ ñ$ &Ü‘7Ñ2Ø'°[Ð]að 3ó ð ð
 ÐØ�3˜!˜œs ;Ó/Ñ/Ñ/°1°#Ñ5Ð5Øˆs�q�cœC Ó,Ñ,Ñ-°°Ñ3¸°s¼SÀÓ=MÑ7MÑNÐRSÐQTÑTÐTr(   c                 ó    — |€| j                   g|z   | j                  gz   S | j                   g|z   | j                  gz   |z   | j                  gz   S )af  
        Build model inputs from a sequence or a pair of sequence for sequence classification tasks. A sequence has the
        following format:

        - single sequence: `[CLS] X [SEP]`
        - pair of sequences: `[CLS] A [SEP] B [SEP]`

        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.
        )Úcls_token_idÚsep_token_id)r$   r5   r6   s      r'   Ú build_inputs_with_special_tokensz3PerceiverTokenizer.build_inputs_with_special_tokens‰   sb   € ð& ÐØ×%Ñ%Ð&¨Ñ4¸×8IÑ8IÐ7JÑJÐJà×%Ñ%Ð&¨Ñ4¸×8IÑ8IÐ7JÑJÈ[ÑXÐ\`×\mÑ\mÐ[nÑnÐnr(   Útextc                 ó^   — |j                  d«      D �cg c]  }t        |«      ‘Œ }}|S c c}w )zPTake as input a string and return a list of strings (tokens) for words/sub-wordsúutf-8)Úencoder,   )r$   r>   r0   Útokenss       r'   Ú	_tokenizezPerceiverTokenizer._tokenize¡   s,   € à"&§+¡+¨gÓ"6Ö7˜Q”#�a•&Ð7ˆÐ7Øˆùò 8s   ”*c                 ón   — t        |«      dk7  r| j                  }|S t        |«      | j                  z   }|S )z0Converts a token (str) in an id using the vocab.r   )r    Úunk_token_idÚordr!   )r$   r1   Útoken_ids      r'   Ú_convert_token_to_idz'PerceiverTokenizer._convert_token_to_id¦   s:   € äˆu‹:˜Š?Ø×(Ñ(ˆHð ˆô ˜5“z D×$<Ñ$<Ñ<ˆHØˆr(   c                 ó6   — t        || j                  z
  «      }|S )z=Converts an index (integer) in a token (str) using the vocab.)r,   r!   )r$   Úindexr1   s      r'   Ú_convert_id_to_tokenz'PerceiverTokenizer._convert_id_to_token®   s   € ä�E˜D×4Ñ4Ñ4Ó5ˆØˆr(   c                 óÄ   — d}|D ]E  }|| j                   v rt        |«      j                  d«      }nt        t	        |«      g«      }||z  }ŒG |j                  dd¬«      }|S )z:Converts a sequence of tokens (string) in a single string.r(   r@   Úreplace)Úerrors)Ú_added_tokens_encoderr   rA   ÚbytesrF   Údecode)r$   rB   Úbstringr1   Ú
tok_stringÚstrings         r'   Úconvert_tokens_to_stringz+PerceiverTokenizer.convert_tokens_to_string´   sk   € àˆØò 	"ˆEØ˜×2Ñ2Ñ2Ü  ›Z×.Ñ.¨wÓ7‘
ä"¤C¨£J <Ó0�
Ø�zÑ!‰Gð	"ð —‘ °	�Ó:ˆØˆr(   Úsave_directoryÚfilename_prefixc                  ó   — y)Nr   r   )r$   rV   rW   s      r'   Úsave_vocabularyz"PerceiverTokenizer.save_vocabularyÁ   s   € Ør(   )z[PAD]z[BOS]z[EOS]z[MASK]z[CLS]z[SEP]i   )r
   N)NFr*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úmodel_input_namesr#   Údictr   Úintr2   Úpropertyr4   ÚlistÚboolr9   r=   rC   rH   rK   rU   ÚtuplerY   Ú__classcell__)r&   s   @r'   r   r      s+  ø„ ñð< %Ð&6Ð7Ðð ØØØØØØð'
ð 
õ'
ðR˜4  S ™>ó ð ñ$ó ð$ð puñUØ ™9ðUØ37¸±9¸tÑ3CðUØhlðUà	ˆc‰õUð: GKñoØ ™9ðoØ37¸±9¸tÑ3Cðoà	ˆc‰óoð0˜cð  d¨3¡ió ò
òò
ñ¨cð ÀCÈ$ÁJð ÐZ_Ð`cÑZd÷ r(   r   N)r]   Útokenization_pythonr   r   Úutilsr   Ú
get_loggerrZ   Úloggerr   Ú__all__r   r(   r'   ú<module>rk      s>   ðñ (ç BÝ ð 
ˆ×	Ñ	˜HÓ	%€ôkÐ,ô kð\  Ð
 �r(   