o
    òÜÓhÁ  ã                   @   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$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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Ú	tokenizerÚBridgeTowerImageProcessor)ÚRobertaTokenizerÚRobertaTokenizerFastc                    s   t ƒ  ||¡ d S ©N)ÚsuperÚ__init__)Úselfr   r   ©Ú	__class__© úl/var/www/html/ai/venv/lib/python3.10/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 d||||||||	|
||||||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)   Údo_normalizeÚdo_center_cropNr   )r   r   Úupdate)r   Úimagesr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   ÚkwargsÚencodingÚencoding_image_processorr   r   r   Ú__call__1   s8   ñðÿÿÿ
zBridgeTowerProcessor.__call__c                 O   ó   | j j|i |¤Ž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   r4   e   ó   z!BridgeTowerProcessor.batch_decodec                 O   r3   )z¾
        This method forwards all its arguments to RobertaTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer
        to the docstring of this method for more information.
        )r   Údecoder5   r   r   r   r8   l   r7   zBridgeTowerProcessor.decodec                 C   s"   | j j}| jj}tt || ¡ƒS r   )r   Úmodel_input_namesr   ÚlistÚdictÚfromkeys)r   Útokenizer_input_namesÚimage_processor_input_namesr   r   r   r9   s   s   z&BridgeTowerProcessor.model_input_names)NTFNNr   NNNFFFFTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
attributesÚimage_processor_classÚtokenizer_classr   r   r
   r	   r   ÚboolÚstrr   r   r   Úintr   r   r2   r4   r8   Úpropertyr9   Ú__classcell__r   r   r   r   r      st    ïýüûúùø	÷
öõôóòñðï
í4r   N)rB   Útypingr   r   r   Úprocessing_utilsr   Útokenization_utils_baser   r   r	   r
   r   Úutilsr   r   r   r   r   r   Ú<module>   s   