Ë
    ÛÓ^j‘  ã                   ón   — d dl 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dœZ G d	„ d
e«      Zd
gZy)é    N)Ú	TokenizerÚdecodersÚnormalizersÚpre_tokenizersÚ
processors)ÚUnigramé   )ÚTokenizersBackendzspiece.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	d„ Z
d„ Z	 	 	 ddeee   z  d	ed
edz  dedef
ˆ fd„Zˆ xZS )ÚLasrTokenizeraÀ  
    Construct a LASR 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_maskNc	           	      ó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 (zm) are provided to LasrTokenizer. In this case the additional_special_tokens must include the extra_ids tokensg        )õ   â–�g       Àéÿÿÿÿr	   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   Ú_spm_precompiled_charsmapr   r    Úvocabr   ÚkwargsÚxÚextra_tokensÚiÚ	__class__s                €úu/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/lasr/tokenization_lasr.pyr7   zLasrTokenizer.__init__J   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Ø˜&�>Ú-à˜×*Ñ*Ð+ðô*
ˆ�‰Õ&ùòk \ùâ-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)r?   s    rC   ú<lambda>z3LasrTokenizer.get_sentinel_tokens.<locals>.<lambda>š   s   € ¤¤b§i¡iÐ0AÀ1Ó&EÓ!FÈdÐ!R€ ó    )ÚlistÚsetÚfilterr    )r;   s    rC   Úget_sentinel_tokensz!LasrTokenizer.get_sentinel_tokens—   s&   € äÜ”ÑRÐTX×TrÑTrÓsÓtó
ð 	
rJ   c                 óf   — | j                  «       D �cg c]  }| j                  |«      ‘Œ c}S c c}w )z&Get the token IDs for sentinel tokens.)rN   Úconvert_tokens_to_ids)r;   Útokens     rC   Úget_sentinel_token_idsz$LasrTokenizer.get_sentinel_token_ids�   s*   € à?C×?WÑ?WÓ?YÖZ°e�×*Ñ*¨5Õ1ÒZÐZùÒZs   “.Ú	token_idsÚskip_special_tokensÚclean_up_tokenization_spacesÚgroup_tokensÚreturnc                 óð   •— t        |t        «      r|g}|r%t        j                  |«      D �cg c]  }|d   ‘Œ	 }}|D �cg c]  }|| j                  k7  sŒ|‘Œ }}t        ‰| �  d|||dœ|¤ŽS c c}w c c}w )Nr   )rS   rT   rU   r&   )Ú
isinstanceÚintÚ	itertoolsÚgroupbyÚpad_token_idr6   Ú_decode)	r;   rS   rT   rU   rV   r>   Útoken_grouprQ   rB   s	           €rC   r^   zLasrTokenizer._decode¡   s’   ø€ ô �i¤Ô%Ø"˜ˆIÙÜ;D×;LÑ;LÈYÓ;WÖX¨K˜ Q›ÐXˆIÐXð )2ÖP˜u°U¸d×>OÑ>OÓ5O’UÐPˆ	ÐPä‰w‰ð 
ØØ 3Ø)Eñ
ð ñ	
ð 	
ùò Yùò Qs   ®A.Á A3ÁA3)r"   z<unk>z<pad>Néd   NNN)FNT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚVOCAB_FILES_NAMESÚvocab_files_namesÚmodel_input_namesr   Úmodelr7   rN   rR   rZ   rK   rF   r(   r^   Ú__classcell__)rB   s   @rC   r   r   !   sŸ   ø„ ñ"ðH *ÐØ$Ð&6Ð7ÐØ€Eð ØØØ"&ØØ"&ØØõK
òZ
ò[ð %*Ø48Ø!ñ
à˜˜c™‘?ð
ð "ð
ð '+¨T¡kð	
ð
 ð
ð 
÷
ñ 
rJ   r   )r[   rG   Ú
tokenizersr   r   r   r   r   Útokenizers.modelsr   Útokenization_utils_tokenizersr
   re   r   Ú__all__r&   rJ   rC   ú<module>rn      sA   ðó* Û 	ç SÕ SÝ %å >ð $2ÐEUÑVÐ ôU
Ð%ô U
ðp Ð
�rJ   