






"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A		:	Tuple      =		{
    '''configuration_mpnet''': ['''MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MPNetConfig'''],
    '''tokenization_mpnet''': ['''MPNetTokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	Any      =		['''MPNetTokenizerFast''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	List[Any]      =		[
						    '''MPNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''MPNetForMaskedLM''',
						    '''MPNetForMultipleChoice''',
						    '''MPNetForQuestionAnswering''',
						    '''MPNetForSequenceClassification''',
						    '''MPNetForTokenClassification''',
						    '''MPNetLayer''',
						    '''MPNetModel''',
						    '''MPNetPreTrainedModel''',
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	Optional[int]      =		[
						    '''TF_MPNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFMPNetEmbeddings''',
						    '''TFMPNetForMaskedLM''',
						    '''TFMPNetForMultipleChoice''',
						    '''TFMPNetForQuestionAnswering''',
						    '''TFMPNetForSequenceClassification''',
						    '''TFMPNetForTokenClassification''',
						    '''TFMPNetMainLayer''',
						    '''TFMPNetModel''',
						    '''TFMPNetPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_mpnet import MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP, MPNetConfig
						from .tokenization_mpnet import MPNetTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_mpnet_fast import MPNetTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_mpnet import (
												    MPNET_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MPNetForMaskedLM,
												    MPNetForMultipleChoice,
												    MPNetForQuestionAnswering,
												    MPNetForSequenceClassification,
												    MPNetForTokenClassification,
												    MPNetLayer,
												    MPNetModel,
												    MPNetPreTrainedModel,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_mpnet import (
												    TF_MPNET_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFMPNetEmbeddings,
												    TFMPNetForMaskedLM,
												    TFMPNetForMultipleChoice,
												    TFMPNetForQuestionAnswering,
												    TFMPNetForSequenceClassification,
												    TFMPNetForTokenClassification,
												    TFMPNetMainLayer,
												    TFMPNetModel,
												    TFMPNetPreTrainedModel,
												)

else:
						import sys

						__A		:	Optional[int]      =		_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)











"""simple docstring"""



import math
import os

import cva
import numpy as np

__A		:	int      =		255.0



def 						lowercase   (    __snake_case    :			float		, __snake_case    :			float     ):
		lowercase_			:			Any								=       np.mean((original - contrast) ** 2     )
		if mse == 0:
				return 1_0_0

		return 2_0 * math.logaa(PIXEL_MAX / math.sqrt(__snake_case     )     )



def 						lowercase   (    ):
		lowercase_			:			Any								=       os.path.dirname(os.path.realpath(__snake_case     )     )
		# Loading images (original image and compressed image)
		lowercase_			:			Union[str, Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/original_image.png'''     )     )
		lowercase_			:			List[Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/compressed_image.png'''     )		, 1     )

		lowercase_			:			Tuple								=       cva.imread(os.path.join(__snake_case		, '''image_data/PSNR-example-base.png'''     )     )
		lowercase_			:			List[str]								=       cva.imread(
		    os.path.join(__snake_case		, '''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(__snake_case		, __snake_case     )} dB'''     )

		# # Value expected: 31.53dB (Wikipedia Example)
		print('''\n-- Second Test --'''     )
		print(F'''PSNR value is {peak_signal_to_noise_ratio(__snake_case		, __snake_case     )} dB'''     )


if __name__ == "__main__":
						main()



