


"""simple docstring"""


import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
class snake_case					(     _UpperCamelCase):
		__UpperCamelCase							=	['image_processor', 'tokenizer']
		__UpperCamelCase							=	'LayoutLMv2ImageProcessor'
		__UpperCamelCase							=	('LayoutLMv2Tokenizer', 'LayoutLMv2TokenizerFast')







		def __init__(    self					:				List[Any]			,      a__					:				List[str]=None			,      a__					:				List[str]=None			,      **a__					:				int						)				->  Union[str, Any]:





						'''simple docstring'''







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

						_A         =	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__(a__			,      a__						)







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





						'''simple docstring'''







						if self.image_processor.apply_ocr and (boxes is not None):
										raise ValueError(
										    "You cannot provide bounding boxes if you initialized the image processor with apply_ocr set to True."						)

						if self.image_processor.apply_ocr and (word_labels is not None):
										raise ValueError(
										    "You cannot provide word labels if you initialized the image processor with apply_ocr set to True."						)

						if return_overflowing_tokens is True and return_offsets_mapping is False:
										raise ValueError("You cannot return overflowing tokens without returning the offsets mapping."						)

						# first, apply the image processor
						_A         =	self.image_processor(images=a__			,      return_tensors=a__						)

						# second, apply the tokenizer
						if text is not None and self.image_processor.apply_ocr and text_pair is None:
										if isinstance(a__			,      a__						):
														_A         =	[text]  # add batch dimension (as the image processor always adds a batch dimension)
										_A         =	features["words"]

						_A         =	self.tokenizer(
						    text=text if text is not None else features["words"]			,      text_pair=text_pair if text_pair is not None else None			,      boxes=boxes if boxes is not None else features["boxes"]			,      word_labels=a__			,      add_special_tokens=a__			,      padding=a__			,      truncation=a__			,      max_length=a__			,      stride=a__			,      pad_to_multiple_of=a__			,      return_token_type_ids=a__			,      return_attention_mask=a__			,      return_overflowing_tokens=a__			,      return_special_tokens_mask=a__			,      return_offsets_mapping=a__			,      return_length=a__			,      verbose=a__			,      return_tensors=a__			,      **a__			,      )

						# add pixel values
						_A         =	features.pop("pixel_values"						)
						if return_overflowing_tokens is True:
										_A         =	self.get_overflowing_images(a__			,      encoded_inputs["overflow_to_sample_mapping"]						)
						_A         =	images

						return encoded_inputs







		def        a_       (    self					:				List[str]			,      a__					:				Optional[int]			,      a__					:				int						)				->  List[str]:





						'''simple docstring'''







						_A         =	[]
						for sample_idx in overflow_to_sample_mapping:
										images_with_overflow.append(images[sample_idx]						)

						if len(a__						) != len(a__						):
										raise ValueError(
										    "Expected length of images to be the same as the length of `overflow_to_sample_mapping`, but got"
										    F""" {len(a__						)} and {len(a__						)}"""						)

						return images_with_overflow







		def        a_       (    self					:				Any			,      *a__					:				List[Any]			,      **a__					:				List[Any]						)				->  Any:





						'''simple docstring'''







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







		def        a_       (    self					:				Dict			,      *a__					:				Union[str, Any]			,      **a__					:				List[str]						)				->  Any:





						'''simple docstring'''







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







		@property
		def        a_       (    self					:				Tuple						)				->  Any:





						'''simple docstring'''







						return ["input_ids", "bbox", "token_type_ids", "attention_mask", "image"]







		@property
		def        a_       (    self					:				str						)				->  Optional[Any]:





						'''simple docstring'''







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







		@property
		def        a_       (    self					:				Optional[Any]						)				->  Optional[Any]:





						'''simple docstring'''







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




def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5) + 32							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) + 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5) + 491.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) - 32) * 5 / 9							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(((float(__UpperCAmelCase	) - 32) * 5 / 9) + 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) + 459.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) - 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(((float(__UpperCAmelCase	) - 273.15) * 9 / 5) + 32							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) - 491.67) * 5 / 9							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) - 459.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 5 / 9)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 1.25 + 273.15)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 2.25 + 32)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 1.25)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 2.25 + 32 + 459.67)							,					__UpperCAmelCase	)


if __name__ == "__main__":
							import doctest

							doctest.testmod()





