

'''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  UpperCAmelCase (							UpperCAmelCase__    ):

		'''simple docstring'''






		SCREAMING_SNAKE_CASE_           =					['''image_processor''', '''tokenizer''']
		SCREAMING_SNAKE_CASE_           =					'''BlipImageProcessor'''
		SCREAMING_SNAKE_CASE_           =					'''AutoTokenizer'''
		def __init__(					self   ,			SCREAMING_SNAKE_CASE_   ,			SCREAMING_SNAKE_CASE_		)  ->     Optional[Any]:






							'''simple docstring'''



							lowerCamelCase_  				=      False
							super().__init__(__lowerCAmelCase   ,			__lowerCAmelCase		)
							lowerCamelCase_  				=      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_   ,			)  ->     Union[str, Any]:






							'''simple docstring'''



							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:
												lowerCamelCase_  				=      self.tokenizer
												lowerCamelCase_  				=      self.tokenizer(
												    text=__lowerCAmelCase   ,			add_special_tokens=__lowerCAmelCase   ,			padding=__lowerCAmelCase   ,			truncation=__lowerCAmelCase   ,			max_length=__lowerCAmelCase   ,			stride=__lowerCAmelCase   ,			pad_to_multiple_of=__lowerCAmelCase   ,			return_attention_mask=__lowerCAmelCase   ,			return_overflowing_tokens=__lowerCAmelCase   ,			return_special_tokens_mask=__lowerCAmelCase   ,			return_offsets_mapping=__lowerCAmelCase   ,			return_token_type_ids=__lowerCAmelCase   ,			return_length=__lowerCAmelCase   ,			verbose=__lowerCAmelCase   ,			return_tensors=__lowerCAmelCase   ,			**__lowerCAmelCase   ,			)
												return text_encoding

							# add pixel_values
							lowerCamelCase_  				=      self.image_processor(__lowerCAmelCase   ,			return_tensors=__lowerCAmelCase		)

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

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

							return encoding_image_processor
		def 			UpperCamelCase(					self   ,			*SCREAMING_SNAKE_CASE_   ,			**SCREAMING_SNAKE_CASE_		)  ->     List[Any]:






							'''simple docstring'''



							return self.tokenizer.batch_decode(*__lowerCAmelCase   ,			**__lowerCAmelCase		)
		def 			UpperCamelCase(					self   ,			*SCREAMING_SNAKE_CASE_   ,			**SCREAMING_SNAKE_CASE_		)  ->     List[str]:






							'''simple docstring'''



							return self.tokenizer.decode(*__lowerCAmelCase   ,			**__lowerCAmelCase		)






		@property
		# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
		def 			UpperCamelCase(					self		)  ->     int:






							'''simple docstring'''



							lowerCamelCase_  				=      self.tokenizer.model_input_names
							lowerCamelCase_  				=      self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)









'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase  =			{
    """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase  =			[
	    """PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """PegasusXForConditionalGeneration""",
	    """PegasusXModel""",
	    """PegasusXPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_pegasus_x import PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusXConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_pegasus_x import (
		    PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST,
		    PegasusXForConditionalGeneration,
		    PegasusXModel,
		    PegasusXPreTrainedModel,
		)


else:
	import sys

	_lowercase  =			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

