
"""simple docstring"""

import sys
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path

from huggingface_hub import HfFolder, delete_repo
from requests.exceptions import HTTPError

from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor
from transformers.testing_utils import TOKEN, USER, get_tests_dir, is_staging_test


sys.path.append(str(Path(__file__).parent.parent / '''utils'''))

from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402


SCREAMING_SNAKE_CASE_            =    get_tests_dir('''fixtures''')
class   _UpperCAmelCase				(		unittest.TestCase				):




      def      a_   (				self				)    ->       Union[str, Any]:
          # A mock response for an HTTP head request to emulate server down
          UpperCAmelCase          =       mock.Mock()
          UpperCAmelCase          =       5_0_0
          UpperCAmelCase          =       {}
          UpperCAmelCase          =       HTTPError
          UpperCAmelCase          =       {}

          # Download this model to make sure it's in the cache.
          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained('hf-internal-testing/tiny-random-wav2vec2'				)
          # Under the mock environment we get a 500 error when trying to reach the model.
          with mock.patch('requests.Session.request' ,							return_value=lowercase_				) as mock_head:
              UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained('hf-internal-testing/tiny-random-wav2vec2'				)
              # This check we did call the fake head request
              mock_head.assert_called()




      def      a_   (				self				)    ->       List[str]:
          # This test is for deprecated behavior and can be removed in v5
          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained(
              'https://huggingface.co/hf-internal-testing/tiny-random-wav2vec2/resolve/main/preprocessor_config.json'				)

@is_staging_test
class   _UpperCAmelCase				(		unittest.TestCase				):




      @classmethod
      def      a_   (				cls				)    ->       List[str]:
          UpperCAmelCase          =       TOKEN
          HfFolder.save_token(lowercase_				)




      @classmethod
      def      a_   (				cls				)    ->       int:
          try:
              delete_repo(token=cls._token ,							repo_id='test-feature-extractor'				)
          except HTTPError:
              pass

          try:
              delete_repo(token=cls._token ,							repo_id='valid_org/test-feature-extractor-org'				)
          except HTTPError:
              pass

          try:
              delete_repo(token=cls._token ,							repo_id='test-dynamic-feature-extractor'				)
          except HTTPError:
              pass




      def      a_   (				self				)    ->       List[str]:
          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained(lowercase_				)
          feature_extractor.push_to_hub('test-feature-extractor' ,							use_auth_token=self._token				)

          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained(F"{USER}/test-feature-extractor"				)
          for k, v in feature_extractor.__dict__.items():
              self.assertEqual(lowercase_ ,							getattr(lowercase_ ,							lowercase_				)				)

          # Reset repo
          delete_repo(token=self._token ,							repo_id='test-feature-extractor'				)

          # Push to hub via save_pretrained
          with tempfile.TemporaryDirectory() as tmp_dir:
              feature_extractor.save_pretrained(
                  lowercase_ ,							repo_id='test-feature-extractor' ,							push_to_hub=lowercase_ ,							use_auth_token=self._token				)

          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained(F"{USER}/test-feature-extractor"				)
          for k, v in feature_extractor.__dict__.items():
              self.assertEqual(lowercase_ ,							getattr(lowercase_ ,							lowercase_				)				)




      def      a_   (				self				)    ->       Any:
          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained(lowercase_				)
          feature_extractor.push_to_hub('valid_org/test-feature-extractor' ,							use_auth_token=self._token				)

          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained('valid_org/test-feature-extractor'				)
          for k, v in feature_extractor.__dict__.items():
              self.assertEqual(lowercase_ ,							getattr(lowercase_ ,							lowercase_				)				)

          # Reset repo
          delete_repo(token=self._token ,							repo_id='valid_org/test-feature-extractor'				)

          # Push to hub via save_pretrained
          with tempfile.TemporaryDirectory() as tmp_dir:
              feature_extractor.save_pretrained(
                  lowercase_ ,							repo_id='valid_org/test-feature-extractor-org' ,							push_to_hub=lowercase_ ,							use_auth_token=self._token				)

          UpperCAmelCase          =       WavaVecaFeatureExtractor.from_pretrained('valid_org/test-feature-extractor-org'				)
          for k, v in feature_extractor.__dict__.items():
              self.assertEqual(lowercase_ ,							getattr(lowercase_ ,							lowercase_				)				)




      def      a_   (				self				)    ->       List[str]:
          CustomFeatureExtractor.register_for_auto_class()
          UpperCAmelCase          =       CustomFeatureExtractor.from_pretrained(lowercase_				)

          feature_extractor.push_to_hub('test-dynamic-feature-extractor' ,							use_auth_token=self._token				)

          # This has added the proper auto_map field to the config
          self.assertDictEqual(
              feature_extractor.auto_map ,							{'AutoFeatureExtractor': 'custom_feature_extraction.CustomFeatureExtractor'} ,							)

          UpperCAmelCase          =       AutoFeatureExtractor.from_pretrained(
              F"{USER}/test-dynamic-feature-extractor" ,							trust_remote_code=lowercase_				)
          # Can't make an isinstance check because the new_feature_extractor is from the CustomFeatureExtractor class of a dynamic module
          self.assertEqual(new_feature_extractor.__class__.__name__ ,							'CustomFeatureExtractor'				)





"""simple docstring"""

import math




def      lowercase__    (       lowerCAmelCase					:       str			,					lowerCAmelCase					:       Optional[Any]			)			->   List[Any]:






    """simple docstring"""




    if 0 not in (x, y):
        # We use the relation x^y = y*log10(x), where 10 is the base.
        return y * math.logaa(lowerCAmelCase			)
    else:
        if x == 0:  # 0 raised to any number is 0
            return 0
        elif y == 0:
            return 1  # any number raised to 0 is 1
    raise AssertionError('This should never happen'			)


if __name__ == "__main__":  # Main function
   # Read two numbers from input and typecast them to int using map function.
   # Here x is the base and y is the power.
   SCREAMING_SNAKE_CASE_            =    '''Enter the base and the power separated by a comma: '''
   SCREAMING_SNAKE_CASE_       ,    SCREAMING_SNAKE_CASE_            =    map(int, input(prompt).split(''','''))
   SCREAMING_SNAKE_CASE_       ,    SCREAMING_SNAKE_CASE_            =    map(int, input(prompt).split(''','''))

   # We find the log of each number, using the function res(), which takes two
   # arguments.
   SCREAMING_SNAKE_CASE_            =    res(xa, ya)
   SCREAMING_SNAKE_CASE_            =    res(xa, ya)

   # We check for the largest number
   if resa > resa:
      print('''Largest number is''', xa, '''^''', ya)
   elif resa > resa:
      print('''Largest number is''', xa, '''^''', ya)
   else:
      print('''Both are equal''')



