
    ^j                         d Z ddlmZmZmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ  ej                  e      ZddiZ G d	 d
e      Zd
gZy)zTokenization classes for XGLM.    )Regex	Tokenizerdecodersnormalizerspre_tokenizers
processors)Unigram   )TokenizersBackend)loggingtokenizer_fileztokenizer.jsonc                        e Zd ZdZeZddgZeZ	 	 	 	 	 	 	 	 	 dde	e
ee	ef      z  dz  de	de	de	d	e	d
e	de	de	dz  def fdZ xZS )XGLMTokenizeraW  
    Construct a XGLM tokenizer (backed by HuggingFace's tokenizers library). Based on BPE.

    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:
        tokenizer_file (`str`, *optional*):
            Path to a tokenizers JSON file containing the serialization of a tokenizer.
        bos_token (`str`, *optional*, defaults to `"<s>"`):
            The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.
        eos_token (`str`, *optional*, defaults to `"</s>"`):
            The end of sequence token.
        sep_token (`str`, *optional*, defaults to `"</s>"`):
            The separator token, which is used when building a sequence from multiple sequences.
        cls_token (`str`, *optional*, defaults to `"<s>"`):
            The classifier token which is used when doing sequence classification.
        unk_token (`str`, *optional*, defaults to `"<unk>"`):
            The unknown token.
        pad_token (`str`, *optional*, defaults to `"<pad>"`):
            The token used for padding.
        vocab (`str`, `dict` or `list`, *optional*):
            Custom vocabulary dictionary. If not provided, a minimal vocabulary is created.
        merges (`list[tuple[str, str]]`, *optional*):
            Custom merge rules for BPE. If not provided, merges are generated from the vocabulary.
        add_prefix_space (`bool`, *optional*, defaults to `True`):
            Whether to add a prefix space before encoding.
    	input_idsattention_maskNvocab	bos_token	eos_token	sep_token	cls_token	unk_token	pad_token_spm_precompiled_charsmapadd_prefix_spacec
                    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<   |	| _        ||| _        n7t        |      dft        |      dft        |      dft        |      dfg| _        t        t        | j                  dd            | _        t        j                  t        d	      d
      g}|%|j                  dt        j                  |             t        j                  |      | j                  _        |	rdnd}t!        j"                  d|      | j                  _        t'        j"                  d|      | j                  _        t+        | X  d|||||||	d|
 t/        j0                  | j2                   d| j2                   d| j2                   d
| j2                   d| j4                  | j6                  f| j2                  | j8                  fg      | j                  _        y c c}w c c}w )N   z<madeupword>additional_special_tokensg        r
   F)r   unk_idbyte_fallbackz {2,} r   alwaysneveru   ▁)replacementprepend_scheme)r   r   r   r   r   r   r   z $Az $A z $B)singlepairspecial_tokens )num_madeup_wordsrangegetr   _vocabstrr   r	   
_tokenizerr   Replacer   insertPrecompiledSequence
normalizerr   	Metaspacepre_tokenizerr   decodersuper__init__r   TemplateProcessingr   r   bos_token_ideos_token_idpost_processor)selfr   r   r   r   r   r   r   r   r   kwargsimadeup_wordswordnormalizers_r%   	__class__s                   u/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/xglm/tokenization_xglm.pyr9   zXGLMTokenizer.__init__>   s5    !"49$:O:O4PQq+aS*QQ.4jj9TVX.Y._]_*+*+)0
T@[9\-\D0
 	
+ !1DK Y%Y%Y%Y%	DK $G$++aW\$]^ $++E(OSAB$0;#:#:;T#UV%0%9%9,%G"%57(6(@(@Ucq(r%"*"4"4We"f 		
-		
 		
 *4)F)Fnn%S)NN#4'7q8HL!2!23!2!23*
&U R0
s   H7H<
H<
)	N<s></s>rG   rF   z<unk>z<pad>NT)__name__
__module____qualname____doc__VOCAB_FILES_NAMESvocab_files_namesmodel_input_namesr	   modelr.   listtuplefloatboolr9   __classcell__)rD   s   @rE   r   r      s    : *$&67E 7;  04!%?
T%U
+,,t3?
 ?
 	?

 ?
 ?
 ?
 ?
 $':?
 ?
 ?
    r   N)rK   
tokenizersr   r   r   r   r   r   tokenizers.modelsr	   tokenization_utils_tokenizersr   utilsr   
get_loggerrH   loggerrL   r   __all__r)   rU   rE   <module>r]      sS    % Z Z % >  
		H	%%'78 a
% a
H 
rU   