



"""simple docstring"""
import math
import os

import cva
import numpy as np

__a           =							2_55.0
def   A_    (     _lowercase,   _lowercase      ):







						'''simple docstring'''


						snake_case_					:Optional[int]		=     np.mean((original - contrast) ** 2      )
						if mse == 0:
												return 100

						return 20 * math.logaa(PIXEL_MAX / math.sqrt(_lowercase      )      )
def   A_    (     ):







						'''simple docstring'''


						snake_case_					:Any		=     os.path.dirname(os.path.realpath(_lowercase      )      )
						# Loading images (original image and compressed image)
						snake_case_					:Optional[int]		=     cva.imread(os.path.join(_lowercase,   """image_data/original_image.png"""      )      )
						snake_case_					:Union[str, Any]		=     cva.imread(os.path.join(_lowercase,   """image_data/compressed_image.png"""      ),   1      )

						snake_case_					:Any		=     cva.imread(os.path.join(_lowercase,   """image_data/PSNR-example-base.png"""      )      )
						snake_case_					:Optional[int]		=     cva.imread(
						    os.path.join(_lowercase,   """image_data/PSNR-example-comp-10.jpg"""      ),   1      )

						# Value expected: 29.73dB
						print("""-- First Test --"""      )
						print(f"""PSNR value is {peak_signal_to_noise_ratio(_lowercase,   _lowercase      )} dB"""      )

						# # Value expected: 31.53dB (Wikipedia Example)
						print("""\n-- Second Test --"""      )
						print(f"""PSNR value is {peak_signal_to_noise_ratio(_lowercase,   _lowercase      )} dB"""      )


if __name__ == "__main__":
						main()


from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding





class 		__lowerCamelCase     (   lowercase		):
							lowerCamelCase__:				Any      =							['''image_processor''', '''tokenizer''']
							lowerCamelCase__:				List[Any]      =							'''EfficientNetImageProcessor'''
							lowerCamelCase__:				str      =							('''BertTokenizer''', '''BertTokenizerFast''')



							def __init__(     self	,				__snake_case	,				__snake_case							)						->     Optional[Any]:






								"""simple docstring"""



								super().__init__(__snake_case	,				__snake_case							)



							def __call__(     self	,				__snake_case=None	,				__snake_case=None	,				__snake_case="max_length"	,				__snake_case=6_4	,				__snake_case=None	,				**__snake_case							)						->     Any:






								"""simple docstring"""



								if text is None and images is None:
									raise ValueError("You have to specify either text or images. Both cannot be none."							)

								if text is not None:
									UpperCAmelCase:					Dict 						=     self.tokenizer(
									    __snake_case	,				padding=__snake_case	,				max_length=__snake_case	,				return_tensors=__snake_case	,				**__snake_case							)

								if images is not None:
									UpperCAmelCase:					List[str] 						=     self.image_processor(__snake_case	,				return_tensors=__snake_case	,				**__snake_case							)

								if text is not None and images is not None:
									UpperCAmelCase:					Optional[int] 						=     image_features.pixel_values
									return encoding
								elif text is not None:
									return encoding
								else:
									return BatchEncoding(data=dict(**__snake_case							)	,				tensor_type=__snake_case							)



							def     A__ (     self	,				*__snake_case	,				**__snake_case							)						->     Any:






								"""simple docstring"""



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



							def     A__ (     self	,				*__snake_case	,				**__snake_case							)						->     List[str]:






								"""simple docstring"""



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




							@property
							def     A__ (     self							)						->     Optional[int]:






								"""simple docstring"""



								UpperCAmelCase:					Optional[int] 						=     self.tokenizer.model_input_names
								UpperCAmelCase:					int 						=     self.image_processor.model_input_names
								return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)
