U
    ,È-eÀ  ã                   @   s`   d 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„ deƒZd	S )
z"
Processor class for BridgeTower.
é    )ÚListÚOptionalÚUnioné   )ÚProcessorMixin)ÚBatchEncodingÚPaddingStrategyÚPreTokenizedInputÚ	TextInputÚTruncationStrategy)Ú
TensorTypec                       s¾   e Zd ZdZddgZdZdZ‡ fdd„Zdee	e
ee	 ee
 f eeeeef eeeef ee eee ee ee eeeeeeeeef  edœdd„Zdd„ Zdd„ Zedd„ ƒZ‡  ZS )ÚBridgeTowerProcessora©  
    Constructs a BridgeTower processor which wraps a Roberta tokenizer and BridgeTower image processor into a single
    processor.

    [`BridgeTowerProcessor`] offers all the functionalities of [`BridgeTowerImageProcessor`] and
    [`RobertaTokenizerFast`]. See the docstring of [`~BridgeTowerProcessor.__call__`] and
    [`~BridgeTowerProcessor.decode`] for more information.

    Args:
        image_processor (`BridgeTowerImageProcessor`):
            An instance of [`BridgeTowerImageProcessor`]. The image processor is a required input.
        tokenizer (`RobertaTokenizerFast`):
            An instance of ['RobertaTokenizerFast`]. The tokenizer is a required input.
    Úimage_processorÚ	tokenizerZBridgeTowerImageProcessor)ZRobertaTokenizerZRobertaTokenizerFastc                    s   t ƒ  ||¡ d S ©N)ÚsuperÚ__init__)Úselfr   r   ©Ú	__class__© úw/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/transformers/models/bridgetower/processing_bridgetower.pyr   -   s    zBridgeTowerProcessor.__init__NTFr   )Ú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                 K   sX   | j f ||||||||	|
||||||dœ|—Ž}| j|f|dddœ|—Ž}| |¡ |S )a  
        This method uses [`BridgeTowerImageProcessor.__call__`] method to prepare image(s) for the model, and
        [`RobertaTokenizerFast.__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#   r$   r%   r&   T)r&   Zdo_normalizeZdo_center_crop)r   r   Úupdate)r   Zimagesr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   ÚkwargsÚencodingZencoding_image_processorr   r   r   Ú__call__0   s<    ñðÿ  ÿÿ
zBridgeTowerProcessor.__call__c                 O   s   | j j||ŽS )zÄ
        This method forwards all its arguments to RobertaTokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
        refer to the docstring of this method for more information.
        )r   Úbatch_decode©r   Úargsr)   r   r   r   r,   d   s    z!BridgeTowerProcessor.batch_decodec                 O   s   | j j||ŽS )z¾
        This method forwards all its arguments to RobertaTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer
        to the docstring of this method for more information.
        )r   Údecoder-   r   r   r   r/   k   s    zBridgeTowerProcessor.decodec                 C   s"   | j j}| jj}tt || ¡ƒS r   )r   Úmodel_input_namesr   ÚlistÚdictÚfromkeys)r   Ztokenizer_input_namesZimage_processor_input_namesr   r   r   r0   r   s    z&BridgeTowerProcessor.model_input_names)NTFNNr   NNNFFFFTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
attributesZimage_processor_classZtokenizer_classr   r   r
   r	   r   ÚboolÚstrr   r   r   Úintr   r   r+   r,   r/   Úpropertyr0   Ú__classcell__r   r   r   r   r      sT                  ïí4r   N)r7   Útypingr   r   r   Zprocessing_utilsr   Ztokenization_utils_baser   r   r	   r
   r   Úutilsr   r   r   r   r   r   Ú<module>   s
   