

"""simple docstring"""






import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin






class     _UpperCAmelCase			(		UpperCamelCase_):
			__a :       Optional[Any]									=							["""image_processor""", """tokenizer"""]
			__a :       Tuple									=							"""AutoImageProcessor"""
			__a :       List[str]									=							"""AutoTokenizer"""
			def __init__(		self      ,		_A=None      ,		_A=None      ,		**_A     )    ->    Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase    :							Any									=					None
				if "feature_extractor" in kwargs:
					warnings.warn(
					    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
					    """ instead."""      ,		__UpperCamelCase      ,		)
					_UpperCAmelCase    :							Union[str, Any]									=					kwargs.pop("""feature_extractor"""     )

				_UpperCAmelCase    :							int									=					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__(__UpperCamelCase      ,		__UpperCamelCase     )
				_UpperCAmelCase    :							Union[str, Any]									=					self.image_processor
				_UpperCAmelCase    :							str									=					False
			def __call__(		self      ,		*_A      ,		**_A     )    ->    Union[str, Any]:






				'''simple docstring'''







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

				_UpperCAmelCase    :							Optional[Any]									=					kwargs.pop("""images"""      ,		__UpperCamelCase     )
				_UpperCAmelCase    :							Optional[Any]									=					kwargs.pop("""text"""      ,		__UpperCamelCase     )
				if len(__UpperCamelCase     ) > 0:
					_UpperCAmelCase    :							List[Any]									=					args[0]
					_UpperCAmelCase    :							List[str]									=					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:
					_UpperCAmelCase    :							Union[str, Any]									=					self.image_processor(__UpperCamelCase      ,		*__UpperCamelCase      ,		**__UpperCamelCase     )
				if text is not None:
					_UpperCAmelCase    :							Dict									=					self.tokenizer(__UpperCamelCase      ,		**__UpperCamelCase     )

				if text is None:
					return inputs
				elif images is None:
					return encodings
				else:
					_UpperCAmelCase    :							str									=					encodings['''input_ids''']
					return inputs
			def 							__snake_case (		self      ,		*_A      ,		**_A     )    ->    List[str]:






				'''simple docstring'''







				return self.tokenizer.batch_decode(*__UpperCamelCase      ,		**__UpperCamelCase     )
			def 							__snake_case (		self      ,		*_A      ,		**_A     )    ->    List[Any]:






				'''simple docstring'''







				return self.tokenizer.decode(*__UpperCamelCase      ,		**__UpperCamelCase     )
			@contextmanager
			def 							__snake_case (		self     )    ->    Tuple:






				'''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."""     )
				_UpperCAmelCase    :							Dict									=					True
				_UpperCAmelCase    :							List[Any]									=					self.tokenizer
				yield
				_UpperCAmelCase    :							List[Any]									=					self.image_processor
				_UpperCAmelCase    :							List[str]									=					False
			@property
			def 							__snake_case (		self     )    ->    List[str]:






				'''simple docstring'''







				warnings.warn(
				    """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""      ,		__UpperCamelCase      ,		)
				return self.image_processor_class
			@property
			def 							__snake_case (		self     )    ->    Tuple:






				'''simple docstring'''







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






"""simple docstring"""






def       UpperCamelCase					(			_lowerCAmelCase     :						int,  _lowerCAmelCase     :						int = 1000 )				->			str:
	if (not isinstance(_lowerCAmelCase,  _lowerCAmelCase )) or (digit_position <= 0):
		raise ValueError("""Digit position must be a positive integer""" )
	elif (not isinstance(_lowerCAmelCase,  _lowerCAmelCase )) or (precision < 0):
		raise ValueError("""Precision must be a nonnegative integer""" )

	# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
	# accurate
	_UpperCAmelCase    :							List[Any]									=					(
	    4 * _subsum(_lowerCAmelCase,  1,  _lowerCAmelCase )
	    - 2 * _subsum(_lowerCAmelCase,  4,  _lowerCAmelCase )
	    - _subsum(_lowerCAmelCase,  5,  _lowerCAmelCase )
	    - _subsum(_lowerCAmelCase,  6,  _lowerCAmelCase )
	)

	# return the first hex digit of the fractional part of the result
	return hex(int((sum_result % 1) * 16 ) )[2:]
def       UpperCamelCase					(			_lowerCAmelCase     :						int,  _lowerCAmelCase     :						int,  _lowerCAmelCase     :						int )				->			float:
	_UpperCAmelCase    :							Optional[int]									=					0.0
	for sum_index in range(digit_pos_to_extract + precision ):
		_UpperCAmelCase    :							Optional[Any]									=					8 * sum_index + denominator_addend
		if sum_index < digit_pos_to_extract:
			# if the exponential term is an integer and we mod it by the denominator
			# before dividing, only the integer part of the sum will change;
			# the fractional part will not
			_UpperCAmelCase    :							Optional[Any]									=					pow(
			    16,  digit_pos_to_extract - 1 - sum_index,  _lowerCAmelCase )
		else:
			_UpperCAmelCase    :							int									=					pow(16,  digit_pos_to_extract - 1 - sum_index )
		total += exponential_term / denominator
	return total


if __name__ == "__main__":
						import doctest

						doctest.testmod()





