



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


			'''simple docstring'''

			_A   :	Optional[int]    					=	['image_processor', 'tokenizer']
			_A   :	Tuple    					=	'BlipImageProcessor'
			_A   :	Optional[int]    					=	'AutoTokenizer'

			def __init__(							self  :				List[str]							,  lowerCAmelCase__  :				Any							,  lowerCAmelCase__  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	False
					super().__init__(A_							,  A_		)
					__SCREAMING_SNAKE_CASE :	str					 =	self.image_processor

			def __call__(							self  :				List[Any]							,  lowerCAmelCase__  :				Any = None							,  lowerCAmelCase__  :				Optional[Any] = None							,  lowerCAmelCase__  :				str = True							,  lowerCAmelCase__  :				Union[str, Any] = False							,  lowerCAmelCase__  :				Union[str, Any] = None							,  lowerCAmelCase__  :				Tuple = None							,  lowerCAmelCase__  :				Any = 0							,  lowerCAmelCase__  :				Dict = None							,  lowerCAmelCase__  :				Any = None							,  lowerCAmelCase__  :				Optional[int] = False							,  lowerCAmelCase__  :				Dict = False							,  lowerCAmelCase__  :				Dict = False							,  lowerCAmelCase__  :				Dict = False							,  lowerCAmelCase__  :				Union[str, Any] = False							,  lowerCAmelCase__  :				List[Any] = True							,  lowerCAmelCase__  :				Any = None							,  **lowerCAmelCase__  :				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:
							__SCREAMING_SNAKE_CASE :	int					 =	self.tokenizer
							__SCREAMING_SNAKE_CASE :	Optional[int]					 =	self.tokenizer(
							    text=A_							,  add_special_tokens=A_							,  padding=A_							,  truncation=A_							,  max_length=A_							,  stride=A_							,  pad_to_multiple_of=A_							,  return_attention_mask=A_							,  return_overflowing_tokens=A_							,  return_special_tokens_mask=A_							,  return_offsets_mapping=A_							,  return_token_type_ids=A_							,  return_length=A_							,  verbose=A_							,  return_tensors=A_							,  **A_							,  )
							return text_encoding

					# add pixel_values
					__SCREAMING_SNAKE_CASE :	int					 =	self.image_processor(A_							,  return_tensors=A_		)

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

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

					return encoding_image_processor

			def UpperCamelCase__      (							self  :				Optional[Any]							,  *lowerCAmelCase__  :				Dict							,  **lowerCAmelCase__  :				int		):





					"""simple docstring"""






					return self.tokenizer.batch_decode(*A_							,  **A_		)

			def UpperCamelCase__      (							self  :				Any							,  *lowerCAmelCase__  :				str							,  **lowerCAmelCase__  :				Union[str, Any]		):





					"""simple docstring"""






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



			@property
			# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
			def UpperCamelCase__      (							self  :				List[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.tokenizer.model_input_names
					__SCREAMING_SNAKE_CASE :	int					 =	self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)




'''simple docstring'''




from ..utils import DummyObject, requires_backends






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Union[str, Any]    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				Optional[int]							,  *lowerCAmelCase__  :				Optional[Any]							,  **lowerCAmelCase__  :				int		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Tuple							,  *lowerCAmelCase__  :				Union[str, Any]							,  **lowerCAmelCase__  :				Optional[int]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				str							,  *lowerCAmelCase__  :				int							,  **lowerCAmelCase__  :				Optional[Any]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Dict    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				str							,  *lowerCAmelCase__  :				str							,  **lowerCAmelCase__  :				List[str]		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Optional[Any]							,  *lowerCAmelCase__  :				Dict							,  **lowerCAmelCase__  :				Dict		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				str							,  *lowerCAmelCase__  :				List[str]							,  **lowerCAmelCase__  :				str		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Tuple    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				str							,  *lowerCAmelCase__  :				List[str]							,  **lowerCAmelCase__  :				Dict		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Any							,  *lowerCAmelCase__  :				Tuple							,  **lowerCAmelCase__  :				Any		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				List[str]							,  *lowerCAmelCase__  :				Union[str, Any]							,  **lowerCAmelCase__  :				Dict		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Optional[int]    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				Optional[int]							,  *lowerCAmelCase__  :				Dict							,  **lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Any							,  *lowerCAmelCase__  :				List[Any]							,  **lowerCAmelCase__  :				List[str]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				List[str]							,  *lowerCAmelCase__  :				str							,  **lowerCAmelCase__  :				Optional[int]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Union[str, Any]    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				Optional[int]							,  *lowerCAmelCase__  :				int							,  **lowerCAmelCase__  :				List[str]		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				List[str]							,  *lowerCAmelCase__  :				int							,  **lowerCAmelCase__  :				int		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				str							,  *lowerCAmelCase__  :				int							,  **lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)






class 		_UpperCamelCase						(							metaclass=lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Optional[Any]    					=	['''torch''', '''transformers''', '''onnx''']

			def __init__(							self  :				Optional[int]							,  *lowerCAmelCase__  :				Tuple							,  **lowerCAmelCase__  :				List[str]		):





					"""simple docstring"""






					requires_backends(self							,  ["""torch""", """transformers""", """onnx"""]		)

			@classmethod
			def UpperCamelCase__      (							cls  :				Tuple							,  *lowerCAmelCase__  :				Dict							,  **lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)



			@classmethod
			def UpperCamelCase__      (							cls  :				List[str]							,  *lowerCAmelCase__  :				Dict							,  **lowerCAmelCase__  :				Tuple		):





					"""simple docstring"""






					requires_backends(cls							,  ["""torch""", """transformers""", """onnx"""]		)