






"""simple docstring"""



import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin




class        __lowercase(       _UpperCamelCase  ):
						lowerCAmelCase_		:							str=       ["""image_processor""", """tokenizer"""]
						lowerCAmelCase_		:							str=       """AutoImageProcessor"""
						lowerCAmelCase_		:							int=       """AutoTokenizer"""






						def __init__(					self    ,						_SCREAMING_SNAKE_CASE=None    ,						_SCREAMING_SNAKE_CASE=None    ,						**_SCREAMING_SNAKE_CASE)			->  List[str]:




											"""simple docstring"""





											lowerCamelCase__				=None
											if "feature_extractor" in kwargs:
																warnings.warn(
																    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
																    ' instead.'    ,						_SCREAMING_SNAKE_CASE    ,						)
																lowerCamelCase__				=kwargs.pop('feature_extractor')

											lowerCamelCase__				=image_processor if image_processor is not None else feature_extractor
											if image_processor is None:
																raise ValueError('You need to specify an `image_processor`.')
											if tokenizer is None:
																raise ValueError('You need to specify a `tokenizer`.')

											super().__init__(_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=self.image_processor
											lowerCamelCase__				=False






						def __call__(					self    ,						*_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)			->  List[str]:




											"""simple docstring"""





											if self._in_target_context_manager:
																return self.current_processor(*_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)

											lowerCamelCase__				=kwargs.pop('images'    ,						_SCREAMING_SNAKE_CASE)
											lowerCamelCase__				=kwargs.pop('text'    ,						_SCREAMING_SNAKE_CASE)
											if len(_SCREAMING_SNAKE_CASE) > 0:
																lowerCamelCase__				=args[0]
																lowerCamelCase__				=args[1:]

											if images is None and text is None:
																raise ValueError('You need to specify either an `images` or `text` input to process.')

											if images is not None:
																lowerCamelCase__				=self.image_processor(_SCREAMING_SNAKE_CASE    ,						*_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)
											if text is not None:
																lowerCamelCase__				=self.tokenizer(_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)

											if text is None:
																return inputs
											elif images is None:
																return encodings
											else:
																lowerCamelCase__				=encodings['input_ids']
																return inputs






						def 		lowerCAmelCase   (					self    ,						*_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)			->  Any:




											"""simple docstring"""





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






						def 		lowerCAmelCase   (					self    ,						*_SCREAMING_SNAKE_CASE    ,						**_SCREAMING_SNAKE_CASE)			->  str:




											"""simple docstring"""





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






						@contextmanager
						def 		lowerCAmelCase   (					self)			->  Union[str, Any]:




											"""simple docstring"""





											warnings.warn(
											    '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
											    'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
											    'your images inputs, or in a separate call.')
											lowerCamelCase__				=True
											lowerCamelCase__				=self.tokenizer
											yield
											lowerCamelCase__				=self.image_processor
											lowerCamelCase__				=False






						@property
						def 		lowerCAmelCase   (					self)			->  Any:




											"""simple docstring"""





											warnings.warn(
											    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'    ,						_SCREAMING_SNAKE_CASE    ,						)
											return self.image_processor_class






						@property
						def 		lowerCAmelCase   (					self)			->  Dict:




											"""simple docstring"""





											warnings.warn(
											    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'    ,						_SCREAMING_SNAKE_CASE    ,						)
											return self.image_processor







"""simple docstring"""



from __future__ import annotations




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			,	__A  :		int			):
					assert n > 1 and a > 0 and greatest_common_divisor(__A			,	__A			) == 1
					((lowerCamelCase__)				,     (lowerCamelCase__)				,     (lowerCamelCase__))				=extended_gcd(__A			,	__A			)  # Implemented below
					lowerCamelCase__				=(b * s) % n
					return x




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			):
					((lowerCamelCase__)				,     (lowerCamelCase__))				=extended_euclid(__A			,	__A			)  # Implemented below
					if b < 0:
										lowerCamelCase__				=(b % n + n) % n
					return b




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			,	__A  :		int			):
					lowerCamelCase__				=invert_modulo(__A			,	__A			)
					lowerCamelCase__				=(b * s) % n
					return x




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			):
					assert a >= 0 and b >= 0

					if b == 0:
										lowerCamelCase__				,     lowerCamelCase__				,     lowerCamelCase__				=a, 1, 0
					else:
										((lowerCamelCase__)				,     (lowerCamelCase__)				,     (lowerCamelCase__))				=extended_gcd(__A			,	a % b			)
										lowerCamelCase__				=q
										lowerCamelCase__				=p - q * (a // b)

					assert a % d == 0 and b % d == 0
					assert d == a * x + b * y

					return (d, x, y)




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			):
					if b == 0:
										return (1, 0)
					((lowerCamelCase__)				,     (lowerCamelCase__))				=extended_euclid(__A			,	a % b			)
					lowerCamelCase__				=a // b
					return (y, x - k * y)




def 						lowerCamelCase_				(  __A  :		int			,	__A  :		int			):
					if a < b:
										lowerCamelCase__				,     lowerCamelCase__				=b, a

					while a % b != 0:
										lowerCamelCase__				,     lowerCamelCase__				=b, a % b

					return b


if __name__ == "__main__":
						from doctest import testmod

						testmod(name="modular_division", verbose=True)
						testmod(name="modular_division2", verbose=True)
						testmod(name="invert_modulo", verbose=True)
						testmod(name="extended_gcd", verbose=True)
						testmod(name="extended_euclid", verbose=True)
						testmod(name="greatest_common_divisor", verbose=True)