





'''simple docstring'''






from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
class 					__snake_case  (					__SCREAMING_SNAKE_CASE							):






   '''simple docstring'''





   lowerCamelCase__    							=      ['''image_processor''', '''tokenizer''']
   lowerCamelCase__    							=      '''BlipImageProcessor'''
   lowerCamelCase__    							=      '''AutoTokenizer'''

   def __init__(							self	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       ):
    snake_case__     :					Optional[int]    =  False
    super().__init__(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )
    snake_case__     :					Union[str, Any]    =  self.image_processor

   def __call__(							self	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = True	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = 0	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = None	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = False	,		__SCREAMING_SNAKE_CASE = True	,		__SCREAMING_SNAKE_CASE = None	,		**__SCREAMING_SNAKE_CASE	,		):
    if images is None and text is None:
     raise ValueError("""You have to specify either images or text."""       )

    # Get only text
    if images is None:
     snake_case__     :					Optional[int]    =  self.tokenizer
     snake_case__     :					Union[str, Any]    =  self.tokenizer(
         text=__SCREAMING_SNAKE_CASE	,		add_special_tokens=__SCREAMING_SNAKE_CASE	,		padding=__SCREAMING_SNAKE_CASE	,		truncation=__SCREAMING_SNAKE_CASE	,		max_length=__SCREAMING_SNAKE_CASE	,		stride=__SCREAMING_SNAKE_CASE	,		pad_to_multiple_of=__SCREAMING_SNAKE_CASE	,		return_attention_mask=__SCREAMING_SNAKE_CASE	,		return_overflowing_tokens=__SCREAMING_SNAKE_CASE	,		return_special_tokens_mask=__SCREAMING_SNAKE_CASE	,		return_offsets_mapping=__SCREAMING_SNAKE_CASE	,		return_token_type_ids=__SCREAMING_SNAKE_CASE	,		return_length=__SCREAMING_SNAKE_CASE	,		verbose=__SCREAMING_SNAKE_CASE	,		return_tensors=__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE	,		)
     return text_encoding

    # add pixel_values
    snake_case__     :					Any    =  self.image_processor(__SCREAMING_SNAKE_CASE	,		return_tensors=__SCREAMING_SNAKE_CASE       )

    if text is not None:
     snake_case__     :					Any    =  self.tokenizer(
         text=__SCREAMING_SNAKE_CASE	,		add_special_tokens=__SCREAMING_SNAKE_CASE	,		padding=__SCREAMING_SNAKE_CASE	,		truncation=__SCREAMING_SNAKE_CASE	,		max_length=__SCREAMING_SNAKE_CASE	,		stride=__SCREAMING_SNAKE_CASE	,		pad_to_multiple_of=__SCREAMING_SNAKE_CASE	,		return_attention_mask=__SCREAMING_SNAKE_CASE	,		return_overflowing_tokens=__SCREAMING_SNAKE_CASE	,		return_special_tokens_mask=__SCREAMING_SNAKE_CASE	,		return_offsets_mapping=__SCREAMING_SNAKE_CASE	,		return_token_type_ids=__SCREAMING_SNAKE_CASE	,		return_length=__SCREAMING_SNAKE_CASE	,		verbose=__SCREAMING_SNAKE_CASE	,		return_tensors=__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE	,		)
    else:
     snake_case__     :					Any    =  None

    if text_encoding is not None:
     encoding_image_processor.update(__SCREAMING_SNAKE_CASE       )

    return encoding_image_processor

   def 		__UpperCamelCase						(							self	,		*__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE       ):
    return self.tokenizer.batch_decode(*__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self	,		*__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE       ):
    return self.tokenizer.decode(*__SCREAMING_SNAKE_CASE	,		**__SCREAMING_SNAKE_CASE       )


   @property
   # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					List[str]    =  self.tokenizer.model_input_names
    snake_case__     :					Tuple    =  self.image_processor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )








'''simple docstring'''





from .glue import GlueDataset, GlueDataTrainingArguments
from .language_modeling import (
    LineByLineTextDataset,
    LineByLineWithRefDataset,
    LineByLineWithSOPTextDataset,
    TextDataset,
    TextDatasetForNextSentencePrediction,
)
from .squad import SquadDataset, SquadDataTrainingArguments



