
    eTh[                     J    S SK Jr  S SKJr  S SKJr  S SKJrJr  S\S\	4S jr
g)	    )Path)Any)TikTokenConverter)TIKTOKEN_VOCAB_FILETOKENIZER_FILEencoding
output_dirc                    [        U5      nUR                  SS9  US-  [        -  nU[        -  n[	        UR                  5       5      n[	        UR                  5       5      n SSKJn  SSKJ	n  [        U [        5      (       a  U" U 5      n U" U R                  U5        [        X@R                  U R                   S9R#                  5       nUR%                  U5        g	! [         a    [        S5      ef = f)
a  
Converts given `tiktoken` encoding to `PretrainedTokenizerFast` and saves the configuration of converted tokenizer
on disk.

Args:
    encoding (`str` or `tiktoken.Encoding`):
        Tokenizer from `tiktoken` library. If `encoding` is `str`, the tokenizer will be loaded with
        `tiktoken.get_encoding(encoding)`.
    output_dir (`str`):
        Save path for converted tokenizer configuration file.
T)exist_oktiktokenr   )get_encoding)dump_tiktoken_bpezY`tiktoken` is required to save a `tiktoken` file. Install it with `pip install tiktoken`.)
vocab_filepatternadditional_special_tokensN)r   mkdirr   r   strabsoluter   r   tiktoken.loadr   
isinstance_mergeable_ranksImportError
ValueErrorr   _pat_str_special_tokens	convertedsave)	r   r	   	save_filetokenizer_filesave_file_absoluteoutput_file_absoluter   r   	tokenizers	            Z/var/www/auris/envauris/lib/python3.13/site-packages/transformers/integrations/tiktoken.pyconvert_tiktoken_to_fastr$      s     j!Jd#Z'*==I.0NY//12~6689	v)3h$$#H-H(335GH "%/@/@\d\t\tik  NN'(  vtuuvs   #<C C3N)pathlibr   typingr   #transformers.convert_slow_tokenizerr   $transformers.tokenization_utils_fastr   r   r   r$        r#   <module>r+      s$      A T#)s #) #)r*   