Ë
    T^(hï  ã                   ó`   — d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ  G d„ de«      ZdgZy	)
z
Processor class for MarkupLM.
é    )ÚOptionalÚUnioné   )Ú
TensorType)ÚProcessorMixin)ÚBatchEncodingÚPaddingStrategyÚTruncationStrategyc                    óä   — e Zd ZdZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d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   dedededededeee	ef      defd„Zd„ Zd„ Zed„ «       Zy)ÚMarkupLMProcessoraJ  
    Constructs a MarkupLM processor which combines a MarkupLM feature extractor and a MarkupLM tokenizer into a single
    processor.

    [`MarkupLMProcessor`] offers all the functionalities you need to prepare data for the model.

    It first uses [`MarkupLMFeatureExtractor`] to extract nodes and corresponding xpaths from one or more HTML strings.
    Next, these are provided to [`MarkupLMTokenizer`] or [`MarkupLMTokenizerFast`], which turns them into token-level
    `input_ids`, `attention_mask`, `token_type_ids`, `xpath_tags_seq` and `xpath_subs_seq`.

    Args:
        feature_extractor (`MarkupLMFeatureExtractor`):
            An instance of [`MarkupLMFeatureExtractor`]. The feature extractor is a required input.
        tokenizer (`MarkupLMTokenizer` or `MarkupLMTokenizerFast`):
            An instance of [`MarkupLMTokenizer`] or [`MarkupLMTokenizerFast`]. The tokenizer is a required input.
        parse_html (`bool`, *optional*, defaults to `True`):
            Whether or not to use `MarkupLMFeatureExtractor` to parse HTML strings into nodes and corresponding xpaths.
    ÚMarkupLMFeatureExtractor)ÚMarkupLMTokenizerÚMarkupLMTokenizerFastTNÚadd_special_tokensÚpaddingÚ
truncationÚ
max_lengthÚstrideÚpad_to_multiple_ofÚreturn_token_type_idsÚreturn_attention_maskÚreturn_overflowing_tokensÚreturn_special_tokens_maskÚreturn_offsets_mappingÚreturn_lengthÚverboseÚreturn_tensorsÚreturnc                 ó¬  — | j                   r:|€t        d«      ‚|€|€|�t        d«      ‚| j                  |«      }|d   }|d   }n|�t        d«      ‚|�|€t        d«      ‚|�| j                   rt        |t        «      r|g} | j
                  di d|�|n|“d	|�|nd“d|“d
|“d|“d|“d|“d|	“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“|¤Ž}|S )aÆ  
        This method first forwards the `html_strings` argument to [`~MarkupLMFeatureExtractor.__call__`]. Next, it
        passes the `nodes` and `xpaths` along with the additional arguments to [`~MarkupLMTokenizer.__call__`] and
        returns the output.

        Optionally, one can also provide a `text` argument which is passed along as first sequence.

        Please refer to the docstring of the above two methods for more information.
        NzDMake sure to pass HTML strings in case `parse_html` is set to `True`zUPlease don't pass nodes, xpaths nor node labels in case `parse_html` is set to `True`ÚnodesÚxpathsz@You have passed HTML strings but `parse_html` is set to `False`.zIMake sure to pass nodes and xpaths in case `parse_html` is set to `False`ÚtextÚ	text_pairÚnode_labelsr   r   r   r   r   r   r   r   r   r   r   r   r   r   © )Ú
parse_htmlÚ
ValueErrorÚfeature_extractorÚ
isinstanceÚstrÚ	tokenizer)ÚselfÚhtml_stringsr    r!   r$   Ú	questionsr   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚkwargsÚfeaturesÚencoded_inputss                          ún/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/markuplm/processing_markuplm.pyÚ__call__zMarkupLMProcessor.__call__2   s‡  € ðB �?Š?ØÐ#Ü Ð!gÓhÐhàÐ  FÐ$6¸+Ð:QÜ Økóð ð ×-Ñ-¨lÓ;ˆHØ˜WÑ%ˆEØ˜hÑ'‰FàÐ'Ü Ð!cÓdÐdØˆ}  Ü Ð!lÓmÐmð Ð  T§_¢_Ü˜)¤SÔ)Ø&˜K�	à'˜Ÿ™ò 
Ø'Ð3‘¸øð
à(Ð4‘e¸$øð
ñ ð
ñ $ð	
ñ
  2ð
ñ ð
ñ "ð
ñ "ð
ñ ð
ñ  2ð
ñ #8ð
ñ #8ð
ñ '@ð
ñ (Bð
ñ $:ð
ñ  (ð!
ñ" ð#
ñ$ *Øñ'
ˆð, Ðó    c                 ó:   —  | j                   j                  |i |¤ŽS )z¾
        This method forwards all its arguments to TrOCRTokenizer's [`~PreTrainedTokenizer.batch_decode`]. Please refer
        to the docstring of this method for more information.
        )r+   Úbatch_decode©r,   Úargsr/   s      r2   r6   zMarkupLMProcessor.batch_decode‚   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r4   c                 ó:   —  | j                   j                  |i |¤ŽS )z¸
        This method forwards all its arguments to TrOCRTokenizer's [`~PreTrainedTokenizer.decode`]. Please refer to the
        docstring of this method for more information.
        )r+   Údecoder7   s      r2   r:   zMarkupLMProcessor.decode‰   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r4   c                 ó2   — | j                   j                  }|S )N)r+   Úmodel_input_names)r,   Útokenizer_input_namess     r2   r<   z#MarkupLMProcessor.model_input_names�   s   € à $§¡× @Ñ @ÐØ$Ð$r4   )NNNNNTFNNr   NNNFFFFTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfeature_extractor_classÚtokenizer_classr&   Úboolr   r*   r	   r
   r   Úintr   r   r3   r6   r:   Úpropertyr<   r%   r4   r2   r   r      sU  „ ñð& 9ÐØD€OØ€Jð ØØØØØ#'Ø5:Ø;?Ø$(ØØ,0Ø04Ø04Ø*/Ø+0Ø',Ø#ØØ;?ñ)Nð !ðNð �t˜S /Ð1Ñ2ðNð ˜$ Ð%7Ð7Ñ8ðNð ˜S‘MðNð ðNð % S™MðNð  (¨™~ðNð  (¨™~ðNð $(ðNð  %)ð!Nð" !%ð#Nð$ ð%Nð& ð'Nð( !  s¨J Ñ!7Ñ8ð)Nð, 
ó-Nò`<ò6ð ñ%ó ñ%r4   r   N)rA   Útypingr   r   Ú
file_utilsr   Úprocessing_utilsr   Útokenization_utils_baser   r	   r
   r   Ú__all__r%   r4   r2   ú<module>rL      s4   ðñ÷ #å $Ý .ß YÑ Yôy%˜ô y%ðx Ð
�r4   