Ë
    T^(hý›  ã                   óÜ   — d 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mZmZmZmZmZmZmZ ddlmZ ddlmZmZ d	d
lmZmZmZ  ej8                  e«      ZddddœZ G d„ de«      Z dgZ!y)z¯
Fast tokenization class for LayoutLMv3. It overwrites 2 methods of the slow tokenizer class, namely _batch_encode_plus
and _encode_plus, in which the Rust tokenizer is used.
é    N)ÚDictÚListÚOptionalÚTupleÚUnion)Ú
processorsé   )ÚBatchEncodingÚEncodedInputÚPaddingStrategyÚPreTokenizedInputÚ
TensorTypeÚ	TextInputÚTextInputPairÚTruncationStrategy)ÚPreTrainedTokenizerFast)Úadd_end_docstringsÚloggingé   )Ú"LAYOUTLMV3_ENCODE_KWARGS_DOCSTRINGÚ2LAYOUTLMV3_ENCODE_PLUS_ADDITIONAL_KWARGS_DOCSTRINGÚLayoutLMv3Tokenizerz
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ddddddddd	d
ddg d¢g d¢g d¢ddfˆ fd„	Z	 e
ee«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d9deeeee   ee   f   deeeee   f      deeee      eeee         f   deeee   eee      f      dedeeeef   deeeef   dee   dedee   dee   deeeef      dee   dee   ded ed!ed"ed#ed$ef(d%„«       Z e
ee«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d9d&eee   ee   ee   f   d'ee   deeeee            deeee   eee      f      dedeeeef   deeeef   dee   dedee   dee   deeeef      dee   dee   ded ed!ed"ed#ed$ef(d(„«       Zd:ded)ee   ded$ee   fd*„Z e
ee«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d9deeef   dee   deeee         deee      dedeeeef   deeeef   dee   dedee   dee   deeeef      dee   dee   ded ed!ed"ed#ed$ef(d+„«       Zddddej<                  ej>                  ddddddddddddfd&eee   ee   ee   f   d'ee   deeeee            deeee         ded,ed-edee   dedee   dee   dee   dee   dee   ded ed!ed"ed#ed$ef(d.„Z ddddej<                  ej>                  ddddddddddddfdeeef   dee   deeee         deee      ded,ed-edee   dedee   dee   dee   dee   dee   ded ed!ed"ed#ed$ef(d/„Z!dej<                  dddfd0ee"ee#f   ef   dee   d,edee   dee   dee   d$e$fd1„Z%d;d2ed3ee   d$e&e   fd4„Z'd;d5„Z(	 d;d6ee   d7eee      d$ee   fd8„Z)ˆ xZ*S )<ÚLayoutLMv3TokenizerFasta<  
    Construct a "fast" LayoutLMv3 tokenizer (backed by HuggingFace's *tokenizers* library). Based on BPE.

    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`):
            Path to the vocabulary file.
        merges_file (`str`):
            Path to the merges file.
        errors (`str`, *optional*, defaults to `"replace"`):
            Paradigm to follow when decoding bytes to UTF-8. See
            [bytes.decode](https://docs.python.org/3/library/stdtypes.html#bytes.decode) for more information.
        bos_token (`str`, *optional*, defaults to `"<s>"`):
            The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.

            <Tip>

            When building a sequence using special tokens, this is not the token that is used for the beginning of
            sequence. The token used is the `cls_token`.

            </Tip>

        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>

        sep_token (`str`, *optional*, defaults to `"</s>"`):
            The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
            sequence classification or for a text and a question for question answering. It is also used as the last
            token of a sequence built with special tokens.
        cls_token (`str`, *optional*, defaults to `"<s>"`):
            The classifier token which is used when doing sequence classification (classification of the whole sequence
            instead of per-token classification). It is the first token of the sequence when built with special tokens.
        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.
        mask_token (`str`, *optional*, defaults to `"<mask>"`):
            The token used for masking values. This is the token used when training this model with masked language
            modeling. This is the token which the model will try to predict.
        add_prefix_space (`bool`, *optional*, defaults to `False`):
            Whether or not to add an initial space to the input. This allows to treat the leading word just as any
            other word. (RoBERTa tokenizer detect beginning of words by the preceding space).
        trim_offsets (`bool`, *optional*, defaults to `True`):
            Whether the post processing step should trim offsets to avoid including whitespaces.
        cls_token_box (`List[int]`, *optional*, defaults to `[0, 0, 0, 0]`):
            The bounding box to use for the special [CLS] token.
        sep_token_box (`List[int]`, *optional*, defaults to `[0, 0, 0, 0]`):
            The bounding box to use for the special [SEP] token.
        pad_token_box (`List[int]`, *optional*, defaults to `[0, 0, 0, 0]`):
            The bounding box to use for the special [PAD] token.
        pad_token_label (`int`, *optional*, defaults to -100):
            The label to use for padding tokens. Defaults to -100, which is the `ignore_index` of PyTorch's
            CrossEntropyLoss.
        only_label_first_subword (`bool`, *optional*, defaults to `True`):
            Whether or not to only label the first subword, in case word labels are provided.
    Ú	input_idsÚattention_maskNÚreplacez<s>z</s>z<unk>z<pad>z<mask>T)r   r   r   r   iœÿÿÿc                 ó’  •— t        ‰| �  ||fi d|“d|“d|“d|“d|“d|“d|	“d|
“d	|“d
|“d|“d|“d|“d|“d|“d|“|¤Ž d}t        | j                  |d «      }|rÇt	        j
                  |j                  «       «      }d|v rt        |d   «      |d<   d|v rt        |d   «      |d<   d}|j                  d
|«      |k7  r||d
<   d}|j                  d|«      |k7  r||d<   d}|r>t        t        |j                  d«      «      } |di |¤Ž}t        | j                  ||«       || _        || _        || _        || _        || _        y )Nr   ÚerrorsÚ	bos_tokenÚ	eos_tokenÚ	sep_tokenÚ	cls_tokenÚ	unk_tokenÚ	pad_tokenÚ
mask_tokenÚadd_prefix_spaceÚtrim_offsetsÚcls_token_boxÚsep_token_boxÚpad_token_boxÚpad_token_labelÚonly_label_first_subwordÚpost_processorÚsepÚclsFTÚtype© )ÚsuperÚ__init__ÚgetattrÚbackend_tokenizerÚjsonÚloadsÚ__getstate__ÚtupleÚgetr   ÚpopÚsetattrr,   r-   r.   r/   r0   )Úselfr   r   r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   ÚkwargsÚtokenizer_componentÚtokenizer_component_instanceÚstateÚchanges_to_applyÚcomponent_classÚ	new_valueÚ	__class__s                             €úy/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/layoutlmv3/tokenization_layoutlmv3_fast.pyr7   z LayoutLMv3TokenizerFast.__init__y   sÛ  ø€ ô, 	‰ÑØØò	
ñ *ð	
ñ ð		
ñ
  ð	
ñ  ð	
ñ  ð	
ñ  ð	
ñ  ð	
ñ  ð	
ñ "ð	
ñ .ð	
ñ &ð	
ñ (ð	
ñ (ð	
ñ  (ð!	
ñ" ,ð#	
ñ$ &>Øò'	
ð, /ÐÜ'.¨t×/EÑ/EÐGZÐ\`Ó'aÐ$Ù'Ü—J‘JÐ;×HÑHÓJÓKˆEð ˜‰~Ü$ U¨5¡\Ó2��e‘Ø˜‰~Ü$ U¨5¡\Ó2��e‘à$Ðà�y‰yÐ+Ð-=Ó>ÐBRÒRØ,<�Ð(Ñ)Ø#'Ð à�y‰y˜¨Ó6¸,ÒFØ(4��nÑ%Ø#'Ð áÜ")¬*°e·i±iÀÓ6GÓ"H�Ù+Ñ4¨eÑ4�	Ü˜×.Ñ.Ð0CÀYÔOð +ˆÔØ*ˆÔØ*ˆÔØ.ˆÔØ(@ˆÕ%ó    Fr   ÚtextÚ	text_pairÚboxesÚword_labelsÚadd_special_tokensÚpaddingÚ
truncationÚ
max_lengthÚstrideÚpad_to_multiple_ofÚpadding_sideÚreturn_tensorsÚreturn_token_type_idsÚreturn_attention_maskÚreturn_overflowing_tokensÚreturn_special_tokens_maskÚreturn_offsets_mappingÚreturn_lengthÚverboseÚreturnc                 óh  — d„ }|�4 ||«      st        d«      ‚t        |t        t        f«      s,t        d«      ‚t        |t        t        f«      st        d«      ‚|�t        |t        t        f«      }n5t        |t        t        f«      xr |xr t        |d   t        t        f«      }|€|n|}|€t        d«      ‚|rYt	        |«      t	        |«      k7  rt        d«      ‚t        ||«      D ]'  \  }}t	        |«      t	        |«      k7  sŒt        d«      ‚ n"t	        |«      t	        |«      k7  rt        d«      ‚|r®|�;t	        |«      t	        |«      k7  r$t        d	t	        |«      › d
t	        |«      › d�«      ‚|�t        t        ||«      «      n|}t        |du«      } | j                  d!i d|“d|“d|“d|“d|“d|“d|“d|“d|	“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“|¤ŽS  | j                  d!i d|“d |“d|“d|“d|“d|“d|“d|“d|	“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“|¤ŽS )"a3  
        Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
        sequences with word-level normalized bounding boxes and optional labels.

        Args:
            text (`str`, `List[str]`, `List[List[str]]`):
                The sequence or batch of sequences to be encoded. Each sequence can be a string, a list of strings
                (words of a single example or questions of a batch of examples) or a list of list of strings (batch of
                words).
            text_pair (`List[str]`, `List[List[str]]`):
                The sequence or batch of sequences to be encoded. Each sequence should be a list of strings
                (pretokenized string).
            boxes (`List[List[int]]`, `List[List[List[int]]]`):
                Word-level bounding boxes. Each bounding box should be normalized to be on a 0-1000 scale.
            word_labels (`List[int]`, `List[List[int]]`, *optional*):
                Word-level integer labels (for token classification tasks such as FUNSD, CORD).
        c                 ó  — t        | t        «      ryt        | t        t        f«      rft	        | «      dk(  ryt        | d   t        «      ryt        | d   t        t        f«      r)t	        | d   «      dk(  xs t        | d   d   t        «      S yy)NTr   F)Ú
isinstanceÚstrÚlistr=   Úlen)Úts    rJ   Ú_is_valid_text_inputz>LayoutLMv3TokenizerFast.__call__.<locals>._is_valid_text_inputò   sz   € Ü˜!œSÔ!àÜ˜A¤¤e˜}Ô-ä�q“6˜Q’;àÜ  !¡¤cÔ*àÜ  !¡¤t¬U mÔ4ä˜q ™t›9¨™>ÒE¬Z¸¸!¹¸Q¹ÄÓ-EÐEà àrK   NzStext input must of type `str` (single example) or `List[str]` (batch of examples). zwWords must be of type `List[str]` (single pretokenized example), or `List[List[str]]` (batch of pretokenized examples).r   z-You must provide corresponding bounding boxesz@You must provide words and boxes for an equal amount of examplesz:You must provide as many words as there are bounding boxeszbatch length of `text`: z- does not match batch length of `text_pair`: ú.Úbatch_text_or_text_pairsÚis_pairrN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rL   rM   r5   )	Ú
ValueErrorrb   rd   r=   re   ÚzipÚboolÚbatch_encode_plusÚencode_plus)rA   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rB   rg   Ú
is_batchedÚwordsÚwords_exampleÚboxes_exampleri   rj   s                               rJ   Ú__call__z LayoutLMv3TokenizerFast.__call__Æ   sa  € òX	ð( Ð á'¨Ô-Ü Ð!vÓwÐwÜ˜i¬$´¨Ô7Ü ðMóð ô ˜d¤T¬5 MÔ2Ü ðMóð ð
 Ð Ü# D¬4´¨-Ó8‰Jä# D¬4´¨-Ó8Òh¸TÒhÄjÐQUÐVWÑQXÔ[_ÔafÐZgÓFhˆJà!Ð)‘¨yˆØˆ=ÜÐLÓMÐMÙÜ�5‹zœS ›ZÒ'Ü Ð!cÓdÐdÜ03°E¸5Ó0Aò cÑ,�˜}Ü�}Ó%¬¨]Ó);Ó;Ü$Ð%aÓbÐbñcô �5‹zœS ›ZÒ'Ü Ð!]Ó^Ð^áØÐ$¬¨T«´c¸)³nÒ)DÜ Ø.¬s°4«y¨kð :Ü˜I›Ð' qð*óð ð FOÐEZ¤t¬C°°iÓ,@Ô'AÐ`dÐ$Ü˜9¨DÐ0Ó1ˆGØ)�4×)Ñ)ò Ù)Aðáðñ ðñ (ð	ñ
 $6ðñ  ðñ &ðñ &ðñ ðñ $6ðñ *ðñ  .ðñ '<ðñ '<ðñ +Dðñ  ,Fð!ñ" (>ð#ñ$ ,ð%ñ&  Øñ)ð ð. $�4×#Ñ#ò Ùðá#ðñ ðñ (ð	ñ
 $6ðñ  ðñ &ðñ &ðñ ðñ $6ðñ *ðñ  .ðñ '<ðñ '<ðñ +Dðñ  ,Fð!ñ" (>ð#ñ$ ,ð%ñ&  Øñ)ð rK   ri   rj   c           	      óÒ   —  | j                   d||||
|dœ|¤Ž\  }}}} | j                  di d|“d|“d|“d|“d|“d|“d|“d	|“d
|	“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“|¤ŽS )N©rQ   rR   rS   rU   r^   ri   rj   rN   rO   rP   Úpadding_strategyÚtruncation_strategyrS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r5   )Ú"_get_padding_truncation_strategiesÚ_batch_encode_plus)rA   ri   rj   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rB   rw   rx   s                          rJ   rn   z)LayoutLMv3TokenizerFast.batch_encode_plus_  s  € ð< ElÀD×DkÑDkð E
ØØ!Ø!Ø1ØñE
ð ñE
ÑAÐÐ-¨z¸6ð 'ˆt×&Ñ&ò 
Ù%=ð
áð
ñ ð
ñ $ð	
ñ
  2ð
ñ .ð
ñ !4ð
ñ "ð
ñ ð
ñ  2ð
ñ &ð
ñ *ð
ñ #8ð
ñ #8ð
ñ '@ð
ñ  (Bð!
ñ" $:ð#
ñ$ (ð%
ñ& Øñ)
ð 	
rK   Úpairc                 ót   — |r||fgn|g} | j                   j                  |f|ddœ|¤Ž}|d   j                  S )NF©rP   Úis_pretokenizedr   )Ú
_tokenizerÚencode_batchÚtokens)rA   rL   r{   rP   rB   Úbatched_inputÚ	encodingss          rJ   Útokenizez LayoutLMv3TokenizerFast.tokenizež  sQ   € Ù*.˜$ ˜™°T°FˆØ0�D—O‘O×0Ñ0Øð
Ø.@ÐRWñ
Ø[añ
ˆ	ð ˜‰|×"Ñ"Ð"rK   c           	      óÒ   —  | j                   d||||
|dœ|¤Ž\  }}}} | j                  di d|“d|“d|“d|“d|“d|“d|“d	|“d
|	“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“|¤ŽS )aj  
        Tokenize and prepare for the model a sequence or a pair of sequences. .. warning:: This method is deprecated,
        `__call__` should be used instead.

        Args:
            text (`str`, `List[str]`, `List[List[str]]`):
                The first sequence to be encoded. This can be a string, a list of strings or a list of list of strings.
            text_pair (`List[str]` or `List[int]`, *optional*):
                Optional second sequence to be encoded. This can be a list of strings (words of a single example) or a
                list of list of strings (words of a batch of examples).
        rv   rL   rN   rM   rO   rP   rw   rx   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r5   )ry   Ú_encode_plus)rA   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rB   rw   rx   s                          rJ   ro   z#LayoutLMv3TokenizerFast.encode_plus¦  s  € ðL ElÀD×DkÑDkð E
ØØ!Ø!Ø1ØñE
ð ñE
ÑAÐÐ-¨z¸6ð !ˆt× Ñ ò 
Ùð
áð
ñ  ð
ñ $ð	
ñ
  2ð
ñ .ð
ñ !4ð
ñ "ð
ñ ð
ñ  2ð
ñ &ð
ñ *ð
ñ #8ð
ñ #8ð
ñ '@ð
ñ  (Bð!
ñ" $:ð#
ñ$ (ð%
ñ& Øñ)
ð 	
rK   rw   rx   c                 óš  — t        |t        «      st        dt        |«      › d�«      ‚| j	                  ||||	|
|¬«       |r$|D ��cg c]  \  }}|j                  «       |f‘Œ }}}| j                  j                  ||d¬«      }|D �cg c]  }| j                  ||||||�dn|||¬«      ‘Œ! }}i }|d   d   j                  «       D ]'  }|D ���cg c]  \  }}||   D ]  }|‘Œ Œ }}}}|||<   Œ) |D ���cg c]  \  }}|D ]  }|‘Œ Œ }}}}|r2g } t        |«      D ]  \  }!\  }"}| |!gt        |"d   «      z  z  } Œ | |d	<   |d   D ]  }#| j                  |#||«       Œ g }$t        t        |d   «      «      D �]!  }%|r	|d	   |%   }&n|%}&g }'t        |d   |%   ||%   j                  ||%   j                   «      D ]Î  \  }(})}*|*�;|r!|)dk(  r|'j#                  | j$                  «       Œ,|'j#                  ||&   |*   «       ŒD|(| j&                  k(  r|'j#                  | j(                  «       Œo|(| j*                  k(  r|'j#                  | j,                  «       Œš|(| j.                  k(  r|'j#                  | j$                  «       ŒÅt1        d
«      ‚ |$j#                  |'«       �Œ$ |$|d<   |��g }+t        t        |d   «      «      D ]Ü  }%|r	|d	   |%   }&n|%}&g },d}-t        |d   |%   |d   |%   ||%   j                   «      D ]�  \  }(}.}*|*�l| j2                  rH|.d   dk(  r|-s|,j#                  ||&   |*   «       n|,j#                  | j4                  «       |.dk(  rd}-ŒZd}-Œ]|,j#                  ||&   |*   «       Œu|,j#                  | j4                  «       Œ‘ |+j#                  |,«       ŒÞ |+|d<   |s|d= t7        |||¬«      S c c}}w c c}w c c}}}w c c}}}w )Nz/batch_text_or_text_pairs has to be a list (got ú))rw   rx   rS   rT   rU   rV   Tr}   )ÚencodingrX   rY   rZ   r[   r\   r]   r^   r   r   Úoverflow_to_sample_mappingzId not recognizedÚbboxFÚoffset_mapping)r   r   Úlabels)Útensor_type)rb   rd   Ú	TypeErrorr4   Úset_truncation_and_paddingÚsplitr   r€   Ú_convert_encodingÚkeysÚ	enumeratere   Ú&_eventual_warn_about_too_long_sequenceÚrangerl   Úsequence_idsÚword_idsÚappendr.   Úcls_token_idr,   Úsep_token_idr-   Úpad_token_idrk   r0   r/   r
   )/rA   ri   rj   rN   rO   rP   rw   rx   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rL   rM   rƒ   r‰   Útokens_and_encodingsÚsanitized_tokensÚkeyÚitemÚ_ÚeÚstackÚsanitized_encodingsrŠ   ÚiÚtoksr   Útoken_boxesÚbatch_indexÚoriginal_indexÚtoken_boxes_exampleÚidÚsequence_idÚword_idr�   Úlabels_exampleÚprevious_token_emptyÚoffsets/                                                  rJ   rz   z*LayoutLMv3TokenizerFast._batch_encode_plusì  s¼  € ô4 Ð2´DÔ9ÜÐMÌdÐSkÓNlÐMmÐmnÐoÓpÐpð 	×'Ñ'Ø-Ø 3Ø!ØØ1Ø%ð 	(ô 	
ñ ØYq×'rÁoÀdÈI¨¯©«°yÒ(AÐ'rÐ$Ñ'rà—O‘O×0Ñ0Ø$Ø1Ø ð 1ó 
ˆ	ð2 &ö 
ð ð ×"Ñ"Ø!Ø&;Ø&;Ø*CØ+EàÐ*ñ (,à+Ø+Øð #õ ð 
Ðð  
ð, ÐØ'¨Ñ*¨1Ñ-×2Ñ2Ó4ò 	*ˆCØ&:×NÐN™7˜4 ÀDÈÁIÒN¸q’QÐN�QÐNˆEÒNØ$)Ð˜SÒ!ð	*ð 1E×SÐS¡W Q¨ÈdÒSÈšqÐS˜qÐSÐÒSñ %Ø)+Ð&Ü )Ð*>Ó ?ò K‘�‘9�D˜!Ø*¨q¨c´C¸¸[Ñ8IÓ4JÑ.JÑJÑ*ðKà=WÐÐ9Ñ:à)¨+Ñ6ò 	XˆIØ×7Ñ7¸	À:ÈwÕWð	Xð ˆÜ ¤Ð%5°kÑ%BÓ!CÓDó 	4ˆKÙ(Ø!1Ð2NÑ!OÐP[Ñ!\‘à!,�Ø"$ÐÜ,/Ø  Ñ-¨kÑ:Ø# KÑ0×=Ñ=Ø# KÑ0×9Ñ9ó-ò >Ñ(��K ð
 Ð&Ù ;°!Ò#3Ø+×2Ñ2°4×3EÑ3EÕFà+×2Ñ2°5¸Ñ3HÈÑ3QÕRà˜T×.Ñ.Ò.Ø+×2Ñ2°4×3EÑ3EÕFØ˜t×0Ñ0Ò0Ø+×2Ñ2°4×3EÑ3EÕFØ˜t×0Ñ0Ò0Ø+×2Ñ2°4×3EÑ3EÕFä(Ð)<Ó=Ð=ð%>ð& ×ÑÐ2Ö3ð3	4ð6 $/Ð˜Ñ ð Ñ"ØˆFÜ$¤SÐ)9¸+Ñ)FÓ%GÓHò .�Ù,Ø%5Ð6RÑ%SÐT_Ñ%`‘Nà%0�NØ!#�Ø',Ð$Ü+.Ø$ [Ñ1°+Ñ>Ø$Ð%5Ñ6°{ÑCØ'¨Ñ4×=Ñ=ó,ò DÑ'�B˜ ð
 Ð*Ø×8Ò8Ø% a™y¨Aš~Ñ6Jà .× 5Ñ 5°kÀ.Ñ6QÐRYÑ6ZÕ [à .× 5Ñ 5°d×6JÑ6JÔ KØ%¨Ò/Ø7;Ñ 4à7<Ñ 4à*×1Ñ1°+¸nÑ2MÈgÑ2VÕWà&×-Ñ-¨d×.BÑ.BÕCð'Dð( —‘˜nÕ-ð7.ð: *0Ð˜XÑ&á)Ø$Ð%5Ð6äÐ-Ð/BÐP^Ô_Ð_ùós (sùò 
ùô0 OùäSs   ÁN4Â$N:ÃN?
Ã6Oc                 óÒ  — |r||fgn|g}|g}|�|gnd } | j                   |fi dt        |d u«      “d|“d|“d|“d|“d|“d|“d|	“d	|
“d
|“d|“d|“d|“d|“d|“d|“d|“d|“|¤Ž}|€`|s^t        |j                  «       D ��ci c].  \  }}|t	        |«      dkD  rt        |d   t        «      r|d   n|“Œ0 c}}|j                  «      }| j                  |d   ||«       |S c c}}w )Nrj   rN   rO   rP   rw   rx   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r   r   )	rz   rm   r
   Úitemsre   rb   rd   rƒ   r•   )rA   rL   rM   rN   rO   rP   rw   rx   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   rB   r‚   Úbatched_boxesÚbatched_word_labelsÚbatched_outputrŸ   Úvalues                              rJ   r†   z$LayoutLMv3TokenizerFast._encode_plus�  s‘  € ñ6 09˜$ 	Ð*Ñ+¸t¸fˆØ˜ˆØ/:Ð/F˜{™mÈDÐØ0˜×0Ñ0Øò
ä˜¨$Ð.Ô/ð
ñ  ð
ñ ,ð	
ñ
  2ð
ñ .ð
ñ !4ð
ñ "ð
ñ ð
ñ  2ð
ñ &ð
ñ *ð
ñ #8ð
ñ #8ð
ñ '@ð
ñ  (Bð!
ñ" $:ð#
ñ$ (ð%
ñ& Øñ)
ˆð2 Ð!Ñ*CÜ*ð '5×&:Ñ&:Ó&<÷á"˜˜Uð ¤S¨£Z°!¢^¼
À5ÈÁ8ÌTÔ8R˜˜qšÐX]Ñ]óð ×(Ñ(óˆNð 	×3Ñ3°NÀ;Ñ4OÐQ[Ð]dÔeàÐùós   Â3C#
Úencoded_inputsc                 ó.  — |€d| j                   v }|| j                   d      }|t        j                  k(  rt        |«      }|�|�||z  dk7  r||z  dz   |z  }|t        j                  k7  xr t        |«      |k7  }|rd|vrdgt        |«      z  |d<   |�r|t        |«      z
  }	|�|n| j
                  }|dk(  r |r|d   dg|	z  z   |d<   d|v r|d   | j                  g|	z  z   |d<   d|v r|d   | j                  g|	z  z   |d<   d|v r|d   | j                  g|	z  z   |d<   d|v r|d   dg|	z  z   |d<   || j                  g|	z  z   || j                   d   <   |S |d	k(  r |rdg|	z  |d   z   |d<   d|v r| j                  g|	z  |d   z   |d<   d|v r| j                  g|	z  |d   z   |d<   d|v r| j                  g|	z  |d   z   |d<   d|v rdg|	z  |d   z   |d<   | j                  g|	z  |z   || j                   d   <   |S t        d
t        |«      z   «      ‚|S )a#  
        Pad encoded inputs (on left/right and up to predefined length or max length in the batch)

        Args:
            encoded_inputs:
                Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
            max_length: maximum length of the returned list and optionally padding length (see below).
                Will truncate by taking into account the special tokens.
            padding_strategy: PaddingStrategy to use for padding.

                - PaddingStrategy.LONGEST Pad to the longest sequence in the batch
                - PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
                - PaddingStrategy.DO_NOT_PAD: Do not pad
                The tokenizer padding sides are defined in self.padding_side:

                    - 'left': pads on the left of the sequences
                    - 'right': pads on the right of the sequences
            pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
                This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
                `>= 7.5` (Volta).
            padding_side:
                The side on which the model should have padding applied. Should be selected between ['right', 'left'].
                Default value is picked from the class attribute of the same name.
            return_attention_mask:
                (optional) Set to False to avoid returning attention mask (default: set to model specifics)
        r   r   r   ÚrightÚtoken_type_idsr‹   r�   Úspecial_tokens_maskÚleftzInvalid padding strategy:)Úmodel_input_namesr   ÚLONGESTre   Ú
DO_NOT_PADrV   Úpad_token_type_idr.   r/   rœ   rk   rc   )
rA   r·   rS   rw   rU   rV   rY   Úrequired_inputÚneeds_to_be_paddedÚ
differences
             rJ   Ú_padzLayoutLMv3TokenizerFast._padÕ  s  € ðH !Ð(Ø$4¸×8NÑ8NÐ$NÐ!à'¨×(>Ñ(>¸qÑ(AÑBˆàœ×6Ñ6Ò6Ü˜^Ó,ˆJàÐ!Ð&8Ð&DÈ*ÐWiÑJiÐmnÒJnØ%Ð);Ñ;¸qÑ@ÐDVÑVˆJà-´×1KÑ1KÑKÒqÔPSÐTbÓPcÐgqÑPqÐñ !Ð%5¸^Ñ%KØ01¨s´S¸Ó5HÑ/HˆNÐ+Ñ,âØ#¤c¨.Ó&9Ñ9ˆJØ+7Ð+C™<È×IZÑIZˆLØ˜wÒ&Ù(Ø7EÐFVÑ7WÐ[\ÐZ]Ð`jÑZjÑ7j�NÐ#3Ñ4Ø# ~Ñ5à&Ð'7Ñ8¸D×<RÑ<RÐ;SÐV`Ñ;`Ñ`ð #Ð#3Ñ4ð ˜^Ñ+Ø-;¸FÑ-CÀt×GYÑGYÐFZÐ]gÑFgÑ-g�N 6Ñ*Ø˜~Ñ-Ø/=¸hÑ/GÈ4×K_ÑK_ÐJ`ÐcmÑJmÑ/m�N 8Ñ,Ø(¨NÑ:Ø<JÐK`Ñ<aÐefÐdgÐjtÑdtÑ<t�NÐ#8Ñ9Ø<JÈd×N_ÑN_ÐM`ÐcmÑMmÑ<m�˜t×5Ñ5°aÑ8Ñ9ð$ Ðð#  Ò'Ù(Ø89°s¸ZÑ7GÈ.ÐYiÑJjÑ7j�NÐ#3Ñ4Ø# ~Ñ5Ø8<×8NÑ8NÐ7OÐR\Ñ7\Ð_mØ(ñ`ñ 8�NÐ#3Ñ4ð ˜^Ñ+Ø.2×.@Ñ.@Ð-AÀJÑ-NÐQ_Ð`fÑQgÑ-g�N 6Ñ*Ø˜~Ñ-Ø04×0DÑ0DÐ/EÈ
Ñ/RÐUcÐdlÑUmÑ/m�N 8Ñ,Ø(¨NÑ:Ø=>¸CÀ*Ñ<LÈ~Ð^sÑOtÑ<t�NÐ#8Ñ9Ø=A×=NÑ=NÐ<OÐR\Ñ<\Ð_mÑ<m�˜t×5Ñ5°aÑ8Ñ9ð Ðô !Ð!<¼sÀ<Ó?PÑ!PÓQÐQàÐrK   Úsave_directoryÚfilename_prefixc                 óf   — | j                   j                  j                  ||¬«      }t        |«      S )N)Úname)r   ÚmodelÚsaver=   )rA   rÅ   rÆ   Úfiless       rJ   Úsave_vocabularyz'LayoutLMv3TokenizerFast.save_vocabulary/  s+   € Ø—‘×%Ñ%×*Ñ*¨>ÀÐ*ÓPˆÜ�U‹|ÐrK   c                 óˆ   — | j                   g|z   | j                  gz   }|€|S || j                  gz   |z   | j                  gz   S ©N)Úbos_token_idÚeos_token_id)rA   Útoken_ids_0Útoken_ids_1Úoutputs       rJ   Ú build_inputs_with_special_tokensz8LayoutLMv3TokenizerFast.build_inputs_with_special_tokens3  sU   € Ø×#Ñ#Ð$ {Ñ2°d×6GÑ6GÐ5HÑHˆØÐØˆMà˜×*Ñ*Ð+Ñ+¨kÑ9¸T×=NÑ=NÐ<OÑOÐOrK   rÑ   rÒ   c                 ó    — | j                   g}| j                  g}|€t        ||z   |z   «      dgz  S t        ||z   |z   |z   |z   |z   «      dgz  S )aË  
        Args:
        Create a mask from the two sequences passed to be used in a sequence-pair classification task. RoBERTa does not:
        make use of token type ids, therefore a list of zeros is returned.
            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   )r›   rš   re   )rA   rÑ   rÒ   r2   r3   s        rJ   Ú$create_token_type_ids_from_sequencesz<LayoutLMv3TokenizerFast.create_token_type_ids_from_sequences:  sm   € ð × Ñ Ð!ˆØ× Ñ Ð!ˆàÐÜ�s˜[Ñ(¨3Ñ.Ó/°1°#Ñ5Ð5Ü�3˜Ñ$ sÑ*¨SÑ0°;Ñ>ÀÑDÓEÈÈÑKÐKrK   )NNNTFNNr   NNNNNFFFFT)NFrÎ   )+Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚVOCAB_FILES_NAMESÚvocab_files_namesr½   r   Úslow_tokenizer_classr7   r   r   r   r   r   r   r   r   Úintrm   rc   r   r   r   r
   rt   r   rn   r„   ro   r¿   ÚDO_NOT_TRUNCATErz   r†   r   r   ÚdictrÄ   r   rÌ   rÔ   rÖ   Ú__classcell__)rI   s   @rJ   r   r   1   s–	  ø„ ñAðF *ÐØ$Ð&6Ð7ÐØ.Ðð ØØØØØØØØØØØØÚ"Ú"Ú"ØØ!%õ'KAñZ Ð:Ð<nÓoð
 RVØ?CØCGØ#'Ø5:Ø;?Ø$(ØØ,0Ø&*Ø;?Ø04Ø04Ø*/Ø+0Ø',Ø#Øñ)Uà�IÐ0°$°y±/À4ÐHYÑCZÐZÑ[ðUð ˜EÐ"3°TÐ:KÑ5LÐ"LÑMÑNðUð �T˜$˜s™)‘_ d¨4°°S±	©?Ñ&;Ð;Ñ<ð	Uð
 ˜e D¨¡I¨t°D¸±I©Ð$>Ñ?Ñ@ðUð !ðUð �t˜S /Ð1Ñ2ðUð ˜$ Ð%7Ð7Ñ8ðUð ˜S‘MðUð ðUð % S™MðUð ˜s‘mðUð !  s¨J Ñ!7Ñ8ðUð  (¨™~ðUð  (¨™~ðUð  $(ð!Uð" %)ð#Uð$ !%ð%Uð& ð'Uð( ð)Uð, 
ò-Uó pðUñn Ð:Ð<nÓoð #'Ø15ØCGØ#'Ø5:Ø;?Ø$(ØØ,0Ø&*Ø;?Ø04Ø04Ø*/Ø+0Ø',Ø#Øñ1:
à"'Ø�‰OØ�ÑØÐ"Ñ#ð%ñ#
ð:
ð ˜$‘ð:
ð ˜˜T $ s¡)™_Ñ-Ñ.ð:
ð ˜e D¨¡I¨t°D¸±I©Ð$>Ñ?Ñ@ð:
ð !ð:
ð �t˜S /Ð1Ñ2ð:
ð ˜$ Ð%7Ð7Ñ8ð:
ð ˜S‘Mð:
ð ð:
ð % S™Mð:
ð  ˜s‘mð!:
ð" !  s¨J Ñ!7Ñ8ð#:
ð$  (¨™~ð%:
ð&  (¨™~ð':
ð( $(ð):
ð* %)ð+:
ð, !%ð-:
ð. ð/:
ð0 ð1:
ð4 
ò5:
ó pð:
ñz#˜Sð #¨°©ð #ÐRVð #ÐmqÐruÑmvó #ñ Ð:Ð<nÓoð
 26Ø+/Ø+/Ø#'Ø5:Ø;?Ø$(ØØ,0Ø&*Ø;?Ø04Ø04Ø*/Ø+0Ø',Ø#Øñ)B
à�IÐ0Ð0Ñ1ðB
ð Ð-Ñ.ðB
ð ˜˜T #™Y™Ñ(ð	B
ð
 ˜d 3™iÑ(ðB
ð !ðB
ð �t˜S /Ð1Ñ2ðB
ð ˜$ Ð%7Ð7Ñ8ðB
ð ˜S‘MðB
ð ðB
ð % S™MðB
ð ˜s‘mðB
ð !  s¨J Ñ!7Ñ8ðB
ð  (¨™~ðB
ð  (¨™~ðB
ð  $(ð!B
ð" %)ð#B
ð$ !%ð%B
ð& ð'B
ð( ð)B
ð, 
ò-B
ó pðB
ðV #'Ø15Ø15Ø#'Ø,;×,FÑ,FØ2D×2TÑ2TØ$(ØØ,0Ø&*Ø(,Ø04Ø04Ø*/Ø+0Ø',Ø#Øñ1a`à"'Ø�‰OØ�ÑØÐ"Ñ#ð%ñ#
ða`ð ˜$‘ða`ð ˜˜T $ s¡)™_Ñ-Ñ.ða`ð ˜d 4¨¡9™oÑ.ða`ð !ða`ð *ða`ð 0ða`ð ˜S‘Mða`ð ða`ð % S™Mða`ð  ˜s‘mð!a`ð" ! ™ð#a`ð$  (¨™~ð%a`ð&  (¨™~ð'a`ð( $(ð)a`ð* %)ð+a`ð, !%ð-a`ð. ð/a`ð0 ð1a`ð2 
ó3a`ðN 26Ø+/Ø+/Ø#'Ø,;×,FÑ,FØ2D×2TÑ2TØ$(ØØ,0Ø&*Ø)-Ø04Ø04Ø*/Ø+0Ø',Ø#Øñ)Bà�IÐ0Ð0Ñ1ðBð Ð-Ñ.ðBð ˜˜T #™Y™Ñ(ð	Bð
 ˜d 3™iÑ(ðBð !ðBð *ðBð 0ðBð ˜S‘MðBð ðBð % S™MðBð ˜s‘mðBð ! ™ðBð  (¨™~ðBð  (¨™~ðBð  $(ð!Bð" %)ð#Bð$ !%ð%Bð& ð'Bð( ð)Bð, 
ó-BðP %)Ø,;×,FÑ,FØ,0Ø&*Ø04ñWà˜d 3¨Ð#4Ñ5°}ÐDÑEðWð ˜S‘MðWð *ð	Wð
 % S™MðWð ˜s‘mðWð  (¨™~ðWð 
óWñt¨cð ÀHÈSÁMð Ð]bÐcfÑ]gó óPð JNñLØ ™9ðLØ3;¸DÀ¹IÑ3FðLà	ˆc‰÷LrK   r   )"rÚ   r:   Útypingr   r   r   r   r   Ú
tokenizersr   Útokenization_utils_baser
   r   r   r   r   r   r   r   Útokenization_utils_fastr   Úutilsr   r   Útokenization_layoutlmv3r   r   r   Ú
get_loggerr×   ÚloggerrÛ   r   Ú__all__r5   rK   rJ   ú<module>rë      sw   ðñó
 ß 5Õ 5å !÷	÷ 	ó 	õ ?ß 0÷ñ ð 
ˆ×	Ñ	˜HÓ	%€à#/ÀÐ`pÑqÐ ô\LÐ5ô \Lð~ %Ð
%�rK   