



"""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 			A__   (  lowerCamelCase_							):




	'''simple docstring'''





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

	def __init__(     self:		Dict       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		Optional[int])				->       Union[str, Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  List[str]												=       False
				super().__init__(_lowercase       ,			_lowercase)
				__lowerCAmelCase      :  Tuple												=       self.image_processor

	def __call__(     self:		int       ,			_SCREAMING_SNAKE_CASE:		ImageInput = None       ,			_SCREAMING_SNAKE_CASE:		Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None       ,			_SCREAMING_SNAKE_CASE:		bool = True       ,			_SCREAMING_SNAKE_CASE:		Union[bool, str, PaddingStrategy] = False       ,			_SCREAMING_SNAKE_CASE:		Union[bool, str, TruncationStrategy] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[int] = None       ,			_SCREAMING_SNAKE_CASE:		int = 0       ,			_SCREAMING_SNAKE_CASE:		Optional[int] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[bool] = None       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = True       ,			_SCREAMING_SNAKE_CASE:		Optional[Union[str, TensorType]] = None       ,			**_SCREAMING_SNAKE_CASE:		Union[str, Any]       ,			)				->       Tuple:

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

				# add pixel_values
				__lowerCAmelCase      :  int												=       self.image_processor(_lowercase       ,			return_tensors=_lowercase)

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

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

				return encoding_image_processor

	def 							_SCREAMING_SNAKE_CASE   (     self:		List[str]       ,			*_SCREAMING_SNAKE_CASE:		Optional[int]       ,			**_SCREAMING_SNAKE_CASE:		str)				->       Dict:

				"""simple docstring"""

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

	def 							_SCREAMING_SNAKE_CASE   (     self:		Union[str, Any]       ,			*_SCREAMING_SNAKE_CASE:		Optional[Any]       ,			**_SCREAMING_SNAKE_CASE:		Optional[int])				->       Tuple:

				"""simple docstring"""

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







	@property
	# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
	def 							_SCREAMING_SNAKE_CASE   (     self:		int)				->       Union[str, Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  Dict												=       self.tokenizer.model_input_names
				__lowerCAmelCase      :  int												=       self.image_processor.model_input_names
				return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
import warnings

from ..trainer import Trainer
from ..utils import logging


__lowerCamelCase			: List[Any]							   =		logging.get_logger(__name__)







class __snake_case				(						lowerCamelCase_		):




   def __init__(    self			:				Tuple       ,	_lowercase			:				Optional[int]=None       ,	**_lowercase			:				List[Any]      ):



     """simple docstring"""






     warnings.warn(
         """`SageMakerTrainer` is deprecated and will be removed in v5 of Transformers. You can use `Trainer` """
         """instead."""       ,	_lowercase       ,	)
     super().__init__(args=_lowercase       ,	**_lowercase      )
