o
    Zh                     @   sf   d Z ddlmZmZmZmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZ G dd deZdgZd	S )
z
Processor class for Nougat.
    )DictListOptionalUnion)PreTokenizedInput	TextInputTruncationStrategy   )ProcessorMixin)PaddingStrategy
TensorTypec                A       s  e Zd ZdZddgZdZdZ fddZ																					
														
d7dee	 dee	 dee
eef  dddee	 dee	 dee	 dee	 deeeef  dee	 deeeee f  deeeee f  ded deeedf  deeeeee ee f  deeeee ee f de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	d&ee d'eeeef  d(ee	 d)ee	 d*e	d+e	d,e	d-e	d.e	f@d/d0Zd1d2 Zd3d4 Zd5d6 Z  ZS )8NougatProcessoran  
    Constructs a Nougat processor which wraps a Nougat image processor and a Nougat tokenizer into a single processor.

    [`NougatProcessor`] offers all the functionalities of [`NougatImageProcessor`] and [`NougatTokenizerFast`]. See the
    [`~NougatProcessor.__call__`] and [`~NougatProcessor.decode`] for more information.

    Args:
        image_processor ([`NougatImageProcessor`]):
            An instance of [`NougatImageProcessor`]. The image processor is a required input.
        tokenizer ([`NougatTokenizerFast`]):
            An instance of [`NougatTokenizerFast`]. The tokenizer is a required input.
    image_processor	tokenizerZAutoImageProcessorZAutoTokenizerc                    s   t  || | j| _d S )N)super__init__r   Zcurrent_processor)selfr   r   	__class__ [/var/www/auris/lib/python3.10/site-packages/transformers/models/nougat/processing_nougat.pyr   -   s   zNougatProcessor.__init__Nchannels_firstTFr   do_crop_margin	do_resizesizeresampleZPILImageResamplingdo_thumbnaildo_align_long_axisdo_pad
do_rescalerescale_factordo_normalize
image_mean	image_stddata_formatZChannelDimensioninput_data_format	text_pairtext_targettext_pair_targetadd_special_tokenspadding
truncation
max_lengthstrideis_split_into_wordspad_to_multiple_ofreturn_tensorsreturn_token_type_idsreturn_attention_maskreturn_overflowing_tokensreturn_special_tokens_maskreturn_offsets_mappingreturn_lengthverbosec#           %      C   s   |d u r|d u rt d|d ur'| j|f|||||||	|
|||||||d}#|d urh| j|fi d|d|d|d|d|d|d	|d
|d|d|d|d|d|d|d|d| d|!d|"}$|d u rn|#S |d u rt|$S |$d |#d< |#S )NzBYou need to specify either an `images` or `text` input to process.)r   r   r   r   r   r   r   r   r    r!   r"   r#   r0   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   Z	input_idslabels)
ValueErrorr   r   )%r   Zimagestextr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   Zinputs	encodingsr   r   r   __call__1   s   '	
zNougatProcessor.__call__c                 O      | j j|i |S )z
        This method forwards all its arguments to NougatTokenizer's [`~PreTrainedTokenizer.batch_decode`]. Please refer
        to the docstring of this method for more information.
        )r   batch_decoder   argskwargsr   r   r   r>         zNougatProcessor.batch_decodec                 O   r=   )z
        This method forwards all its arguments to NougatTokenizer's [`~PreTrainedTokenizer.decode`]. Please refer to
        the docstring of this method for more information.
        )r   decoder?   r   r   r   rC      rB   zNougatProcessor.decodec                 O   r=   )z
        This method forwards all its arguments to NougatTokenizer's [`~PreTrainedTokenizer.post_process_generation`].
        Please refer to the docstring of this method for more information.
        )r   post_process_generationr?   r   r   r   rD      rB   z'NougatProcessor.post_process_generation)"NNNNNNNNNNNNNNr   NNNNTFNNr   FNNNNFFFFT)__name__
__module____qualname____doc__
attributesZimage_processor_classZtokenizer_classr   r   boolr   strintr   floatr   r   r   r   r   r   r<   r>   rC   rD   __classcell__r   r   r   r   r      s    	
 !"#$%
\r   N)rH   typingr   r   r   r   Z$transformers.tokenization_utils_baser   r   r   Zprocessing_utilsr
   utilsr   r   r   __all__r   r   r   r   <module>   s    
	