
    fTh                         S r SSKrSSKJrJrJr  SSKJr  SSKJ	r	  SSK
JrJrJrJrJr  SSKJr   " S	 S
\	5      rS
/rg)z&
Image/Text processor class for FLAVA
    N)ListOptionalUnion   )
ImageInput)ProcessorMixin)BatchEncodingPaddingStrategyPreTokenizedInput	TextInputTruncationStrategy)
TensorTypec            (       h  ^  \ rS rSrSrSS/rSrSrS!U 4S jjr                  S"S\	\
   S	\	\\\\\   \\   4      S
\S\\\\4   S\\\\4   S\	\   S\S\	\   S\	\   S\	\   S\	\   S\	\   S\S\S\S\S\S\	\\\4      4$S jjrS rS r\S 5       r\S 5       r\S 5       rS rU =r$ )#FlavaProcessor   a  
Constructs a FLAVA processor which wraps a FLAVA image processor and a FLAVA tokenizer into a single processor.

[`FlavaProcessor`] offers all the functionalities of [`FlavaImageProcessor`] and [`BertTokenizerFast`]. See the
[`~FlavaProcessor.__call__`] and [`~FlavaProcessor.decode`] for more information.

Args:
    image_processor ([`FlavaImageProcessor`], *optional*): The image processor is a required input.
    tokenizer ([`BertTokenizerFast`], *optional*): The tokenizer is a required input.
image_processor	tokenizerFlavaImageProcessor)BertTokenizerBertTokenizerFastc                    > S nSU;   a,  [         R                  " S[        5        UR                  S5      nUb  UOUnUc  [	        S5      eUc  [	        S5      e[
        TU ]  X5        U R                  U l        g )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        b/var/www/auris/envauris/lib/python3.13/site-packages/transformers/models/flava/processing_flava.pyr   FlavaProcessor.__init__,   s     &(MM
 !'

+> ?-<-H/N_"HIIABB4!%!5!5    imagestextadd_special_tokenspadding
truncation
max_lengthstridepad_to_multiple_ofreturn_image_maskreturn_codebook_pixelsreturn_token_type_idsreturn_attention_maskreturn_overflowing_tokensreturn_special_tokens_maskreturn_offsets_mappingreturn_lengthverbosereturn_tensorsc                    Uc  Uc  [        S5      eUb"  U R                  " SUUUUUUUUUUUUUUUS.UD6nUb  U R                  " U4U	U
US.UD6nUb  Ub  WR                  W5        U$ Ub  W$ [	        [        S0 WD6US9$ )z
This method uses [`FlavaImageProcessor.__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.
z?You have to specify either text or images. Both cannot be none.)r(   r)   r*   r+   r,   r-   r.   r1   r2   r3   r4   r5   r6   r7   r8   )r/   r0   r8   )datatensor_type )r   r   r   updater	   dict)r!   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r"   encodingimage_featuress                         r$   __call__FlavaProcessor.__call__?   s    : <FN^__~~ #5%%#5&;&;*C+E'=+-  !H$ !11"3'=-	
 N  2OON+OO d&<^&<.YYr&   c                 :    U R                   R                  " U0 UD6$ )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$   rD   FlavaProcessor.batch_decode   s    
 ~~**D;F;;r&   c                 :    U R                   R                  " U0 UD6$ )z
This method forwards all its arguments to BertTokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
the docstring of this method for more information.
)r   decoderE   s      r$   rI   FlavaProcessor.decode   s    
 ~~$$d5f55r&   c                     U R                   R                  nU R                  R                  n[        [        R                  X-   5      5      $ )N)r   model_input_namesr   listr>   fromkeys)r!   tokenizer_input_namesimage_processor_input_namess      r$   rL    FlavaProcessor.model_input_names   s<     $ @ @&*&:&:&L&L#DMM"7"UVWWr&   c                 P    [         R                  " S[        5        U R                  $ )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_class&FlavaProcessor.feature_extractor_class   s"    u	
 )))r&   c                 P    [         R                  " S[        5        U R                  $ )Nz[`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.)r   r   r   r   rT   s    r$   r    FlavaProcessor.feature_extractor   s"    i	
 ###r&   )r    )NN)NNTFFNr   NNNNNFFFFTN)__name__
__module____qualname____firstlineno____doc__
attributesrS   tokenizer_classr   r   r   r   r   r   r   boolstrr
   r   intr   rA   rD   rI   propertyrL   rU   r   __static_attributes____classcell__)r#   s   @r$   r   r      s   	 $[1J1<O6* (,hl#'5:;@$(,0,0150404*/+0',#;?'BZ$BZ uY(94	?DQbLccdeBZ !	BZ
 tS/12BZ $%778BZ SMBZ BZ %SMBZ $D>BZ !)BZ  (~BZ  (~BZ $(BZ %)BZ  !%!BZ" #BZ$ %BZ& !sJ!78'BZH<6 X X
 * * $ $r&   r   )r]   r   typingr   r   r   image_utilsr   processing_utilsr   tokenization_utils_baser	   r
   r   r   r   utilsr   r   __all__r<   r&   r$   <module>rl      s=     ( ( % . w w I$^ I$X 
r&   