Ë
    T^(hÝ  ã                   ót   — d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ  G d„ d	e«      Zd	gZy)
z
Processor class for ViLT.
é    N)ÚListÚOptionalÚUnioné   )ÚProcessorMixin)ÚBatchEncodingÚPaddingStrategyÚPreTokenizedInputÚ	TextInputÚTruncationStrategy)Ú
TensorTypec            "       ó2  ‡ — e Zd ZdZddgZdZdZdˆ fd„	Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d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   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ed„ «       Zed„ «       Zˆ xZS )ÚViltProcessorau  
    Constructs a ViLT processor which wraps a BERT tokenizer and ViLT image processor into a single processor.

    [`ViltProcessor`] offers all the functionalities of [`ViltImageProcessor`] and [`BertTokenizerFast`]. See the
    docstring of [`~ViltProcessor.__call__`] and [`~ViltProcessor.decode`] for more information.

    Args:
        image_processor (`ViltImageProcessor`, *optional*):
            An instance of [`ViltImageProcessor`]. The image processor is a required input.
        tokenizer (`BertTokenizerFast`, *optional*):
            An instance of ['BertTokenizerFast`]. The tokenizer is a required input.
    Úimage_processorÚ	tokenizerÚViltImageProcessor)ÚBertTokenizerÚBertTokenizerFastc                 óê   •— d }d|v r+t        j                  dt        «       |j                  d«      }|�|n|}|€t	        d«      ‚|€t	        d«      ‚t
        ‰| �  ||«       | j                  | _        y )NÚfeature_extractorzhThe `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor` instead.z)You need to specify an `image_processor`.z"You need to specify a `tokenizer`.)	ÚwarningsÚwarnÚFutureWarningÚpopÚ
ValueErrorÚsuperÚ__init__r   Úcurrent_processor)Úselfr   r   Úkwargsr   Ú	__class__s        €úf/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/vilt/processing_vilt.pyr   zViltProcessor.__init__-   s…   ø€ Ø ÐØ &Ñ(Ü�M‰Mðäôð
 !'§
¡
Ð+>Ó ?Ðà-<Ð-H™/ÐN_ˆØÐ"ÜÐHÓIÐIØÐÜÐAÓBÐBä‰Ñ˜¨)Ô4Ø!%×!5Ñ!5ˆÕó    ÚtextÚ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                   d||||||||	|
||||||dœ|¤Ž}| j                  ||¬«      }|j                  |«       |S )a  
        This method uses [`ViltImageProcessor.__call__`] method to prepare image(s) for the model, and
        [`BertTokenizerFast.__call__`] to prepare text for the model.

        Please refer to the docstring of the above two methods for more information.
        )r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   )r2   © )r   r   Úupdate)r   Úimagesr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r    ÚencodingÚencoding_image_processors                       r"   Ú__call__zViltProcessor.__call__@   sz   € ð4 "�4—>‘>ð 
ØØ1ØØ!Ø!ØØ1Ø"7Ø"7Ø&?Ø'AØ#9Ø'ØØ)ñ
ð  ñ!
ˆð& $(×#7Ñ#7¸È~Ð#7Ó#^Ð Ø�‰Ð0Ô1àˆr#   c                 ó:   —  | j                   j                  |i |¤ŽS )zÁ
        This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r   Úbatch_decode©r   Úargsr    s      r"   r<   zViltProcessor.batch_decoder   s    € ð
 +ˆt�~‰~×*Ñ*¨DÐ;°FÑ;Ð;r#   c                 ó:   —  | j                   j                  |i |¤ŽS )z»
        This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
        the docstring of this method for more information.
        )r   Údecoder=   s      r"   r@   zViltProcessor.decodey   s    € ð
 %ˆt�~‰~×$Ñ$ dÐ5¨fÑ5Ð5r#   c                 óœ   — | j                   j                  }| j                  j                  }t        t        j                  ||z   «      «      S )N)r   Úmodel_input_namesr   ÚlistÚdictÚfromkeys)r   Útokenizer_input_namesÚimage_processor_input_namess      r"   rB   zViltProcessor.model_input_names€   s?   € à $§¡× @Ñ @ÐØ&*×&:Ñ&:×&LÑ&LÐ#Ü”D—M‘MÐ"7Ð:UÑ"UÓVÓWÐWr#   c                 óN   — t        j                  dt        «       | j                  S )Nzg`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.)r   r   r   Úimage_processor_class©r   s    r"   Úfeature_extractor_classz%ViltProcessor.feature_extractor_class†   s"   € ä�‰ØuÜô	
ð ×)Ñ)Ð)r#   c                 óN   — t        j                  dt        «       | j                  S )Nz[`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.)r   r   r   r   rJ   s    r"   r   zViltProcessor.feature_extractorŽ   s"   € ä�‰ØiÜô	
ð ×#Ñ#Ð#r#   )NN)NTFNNr   NNNFFFFTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
attributesrI   Útokenizer_classr   r   r   r
   r   ÚboolÚstrr	   r   r   Úintr   r   r:   r<   r@   ÚpropertyrB   rK   r   Ú__classcell__)r!   s   @r"   r   r      s“  ø„ ñð $ [Ð1€JØ0ÐØ<€Oõ6ð, _cØ#'Ø5:Ø;?Ø$(ØØ,0Ø04Ø04Ø*/Ø+0Ø',Ø#ØØ;?ñ#0ð �IÐ0°$°y±/À4ÐHYÑCZÐZÑ[ð0ð !ð	0ð
 �t˜S /Ð1Ñ2ð0ð ˜$ Ð%7Ð7Ñ8ð0ð ˜S‘Mð0ð ð0ð % S™Mð0ð  (¨™~ð0ð  (¨™~ð0ð $(ð0ð %)ð0ð !%ð0ð ð0ð  ð!0ð" !  s¨J Ñ!7Ñ8ð#0ð& 
ó'0òd<ò6ð ñXó ðXð
 ñ*ó ð*ð ñ$ó ô$r#   r   )rP   r   Útypingr   r   r   Úprocessing_utilsr   Útokenization_utils_baser   r	   r
   r   r   Úutilsr   r   Ú__all__r5   r#   r"   ú<module>r]      s:   ðñó ß (Ñ (å .ß wÕ wÝ ôy$�Nô y$ðx Ð
�r#   