





import math
import os

import cva
import numpy as np

_SCREAMING_SNAKE_CASE   						=		2_5_5.0


def 				SCREAMING_SNAKE_CASE__    (     __a ,			__a ):
	snake_case_		:      Optional[Any]           =						np.mean((original - contrast) ** 2 )
	if mse == 0:
		return 1_00

	return 20 * math.logaa(PIXEL_MAX / math.sqrt(__a ) )


def 				SCREAMING_SNAKE_CASE__    (     ):
	snake_case_		:      Any           =						os.path.dirname(os.path.realpath(__a ) )
	# Loading images (original image and compressed image)
	snake_case_		:      int           =						cva.imread(os.path.join(__a ,			'image_data/original_image.png' ) )
	snake_case_		:      Tuple           =						cva.imread(os.path.join(__a ,			'image_data/compressed_image.png' ) ,			1 )

	snake_case_		:      Dict           =						cva.imread(os.path.join(__a ,			'image_data/PSNR-example-base.png' ) )
	snake_case_		:      Optional[Any]           =						cva.imread(
	    os.path.join(__a ,			'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(__a ,			__a )} dB""" )

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


if __name__ == "__main__":
						main()





import unittest
import warnings
from dataclasses import dataclass

from transformers.convert_slow_tokenizer import SpmConverter
from transformers.testing_utils import get_tests_dir

@dataclass
class    __magic_name__						:
     A:		str



class    __magic_name__						(  unittest.TestCase):


     def   UpperCAmelCase__						(   self				:  Any      )	->   List[Any]:





      '''simple docstring'''






      UpperCamelCase__       :     Optional[Any] 							= get_tests_dir('''fixtures/test_sentencepiece.model'''      )
      UpperCamelCase__       :     Any 							= get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.model'''      )

      UpperCamelCase__       :     List[str] 							= FakeOriginalTokenizer(vocab_file=lowerCamelCase__      )

      with warnings.catch_warnings(record=lowerCamelCase__      ) as w:
       UpperCamelCase__       :     Optional[int] 							= SpmConverter(lowerCamelCase__      )
      self.assertEqual(len(lowerCamelCase__      )				,						0      )

      UpperCamelCase__       :     Tuple 							= FakeOriginalTokenizer(vocab_file=lowerCamelCase__      )

      with warnings.catch_warnings(record=lowerCamelCase__      ) as w:
       UpperCamelCase__       :     str 							= SpmConverter(lowerCamelCase__      )
      self.assertEqual(len(lowerCamelCase__      )				,						1      )

      self.assertIn(
          '''The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option'''
          ''' which is not implemented in the fast tokenizers.'''				,						str(w[0].message      )				,						)


