


"""simple docstring"""





import json
import sys
import tempfile
import unittest
from pathlib import Path

import transformers
from transformers import (
    CONFIG_MAPPING,
    FEATURE_EXTRACTOR_MAPPING,
    AutoConfig,
    AutoFeatureExtractor,
    WavaVecaConfig,
    WavaVecaFeatureExtractor,
)
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, get_tests_dir


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

from test_module.custom_configuration import CustomConfig  # noqa E402
from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402


snake_case__		:     List[Any]    				=				get_tests_dir('''fixtures''')
snake_case__		:     List[str]    				=				get_tests_dir('''fixtures/dummy_feature_extractor_config.json''')
snake_case__		:     List[Any]    				=				get_tests_dir('''fixtures/dummy-config.json''')



class 		snake_case_(       unittest.TestCase			):






     def      lowerCamelCase__     (	self  :					int				):
           lowerCAmelCase					:	List[Any]       =   0






     def      lowerCamelCase__     (	self  :					List[Any]				):
           lowerCAmelCase					:	Tuple       =   AutoFeatureExtractor.from_pretrained('''facebook/wav2vec2-base-960h'''				)
           self.assertIsInstance(UpperCamelCase_					,				UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Optional[int]				):
           lowerCAmelCase					:	Dict       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_				)
           self.assertIsInstance(UpperCamelCase_					,				UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Tuple				):
           with tempfile.TemporaryDirectory() as tmpdirname:
                 lowerCAmelCase					:	Any       =   WavaVecaConfig()

                 # remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
                 lowerCAmelCase					:	Dict       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_				).to_dict()

                 config_dict.pop('''feature_extractor_type'''				)
                 lowerCAmelCase					:	Dict       =   WavaVecaFeatureExtractor(**UpperCamelCase_				)

                 # save in new folder
                 model_config.save_pretrained(UpperCamelCase_				)
                 config.save_pretrained(UpperCamelCase_				)

                 lowerCAmelCase					:	str       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_				)

                 # make sure private variable is not incorrectly saved
                 lowerCAmelCase					:	Optional[Any]       =   json.loads(config.to_json_string()				)
                 self.assertTrue('''_processor_class''' not in dict_as_saved				)

           self.assertIsInstance(UpperCamelCase_					,				UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Tuple				):
           lowerCAmelCase					:	List[str]       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_				)
           self.assertIsInstance(UpperCamelCase_					,				UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					str				):
           with self.assertRaisesRegex(
               UpperCamelCase_					,				'''bert-base is not a local folder and is not a valid model identifier'''				):
                 lowerCAmelCase					:	Optional[int]       =   AutoFeatureExtractor.from_pretrained('''bert-base'''				)






     def      lowerCamelCase__     (	self  :					Optional[int]				):
           with self.assertRaisesRegex(
               UpperCamelCase_					,				r'''aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'''				):
                 lowerCAmelCase					:	Optional[Any]       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_					,				revision='''aaaaaa'''				)






     def      lowerCamelCase__     (	self  :					Optional[Any]				):
           with self.assertRaisesRegex(
               UpperCamelCase_					,				'''hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json.'''					,				):
                 lowerCAmelCase					:	int       =   AutoFeatureExtractor.from_pretrained('''hf-internal-testing/config-no-model'''				)






     def      lowerCamelCase__     (	self  :					Dict				):
           # If remote code is not set, we will time out when asking whether to load the model.
           with self.assertRaises(UpperCamelCase_				):
                 lowerCAmelCase					:	int       =   AutoFeatureExtractor.from_pretrained(
                     '''hf-internal-testing/test_dynamic_feature_extractor'''				)
           # If remote code is disabled, we can't load this config.
           with self.assertRaises(UpperCamelCase_				):
                 lowerCAmelCase					:	Dict       =   AutoFeatureExtractor.from_pretrained(
                     '''hf-internal-testing/test_dynamic_feature_extractor'''					,				trust_remote_code=UpperCamelCase_				)

           lowerCAmelCase					:	Union[str, Any]       =   AutoFeatureExtractor.from_pretrained(
               '''hf-internal-testing/test_dynamic_feature_extractor'''					,				trust_remote_code=UpperCamelCase_				)
           self.assertEqual(feature_extractor.__class__.__name__					,				'''NewFeatureExtractor'''				)

           # Test feature extractor can be reloaded.
           with tempfile.TemporaryDirectory() as tmp_dir:
                 feature_extractor.save_pretrained(UpperCamelCase_				)
                 lowerCAmelCase					:	Tuple       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_					,				trust_remote_code=UpperCamelCase_				)
           self.assertEqual(reloaded_feature_extractor.__class__.__name__					,				'''NewFeatureExtractor'''				)






     def      lowerCamelCase__     (	self  :					Any				):
           try:
                 AutoConfig.register('''custom'''					,				UpperCamelCase_				)
                 AutoFeatureExtractor.register(UpperCamelCase_					,				UpperCamelCase_				)
                 # Trying to register something existing in the Transformers library will raise an error
                 with self.assertRaises(UpperCamelCase_				):
                       AutoFeatureExtractor.register(UpperCamelCase_					,				UpperCamelCase_				)

                 # Now that the config is registered, it can be used as any other config with the auto-API
                 lowerCAmelCase					:	Union[str, Any]       =   CustomFeatureExtractor.from_pretrained(UpperCamelCase_				)
                 with tempfile.TemporaryDirectory() as tmp_dir:
                       feature_extractor.save_pretrained(UpperCamelCase_				)
                       lowerCAmelCase					:	Any       =   AutoFeatureExtractor.from_pretrained(UpperCamelCase_				)
                       self.assertIsInstance(UpperCamelCase_					,				UpperCamelCase_				)

           finally:
                 if "custom" in CONFIG_MAPPING._extra_content:
                       del CONFIG_MAPPING._extra_content["custom"]
                 if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
                       del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]






     def      lowerCamelCase__     (	self  :					Tuple				):



           class 		snake_case_(       a__			):
                __UpperCamelCase  =					True

           try:
                 AutoConfig.register('''custom'''					,				UpperCamelCase_				)
                 AutoFeatureExtractor.register(UpperCamelCase_					,				UpperCamelCase_				)
                 # If remote code is not set, the default is to use local
                 lowerCAmelCase					:	Union[str, Any]       =   AutoFeatureExtractor.from_pretrained(
                     '''hf-internal-testing/test_dynamic_feature_extractor'''				)
                 self.assertEqual(feature_extractor.__class__.__name__					,				'''NewFeatureExtractor'''				)
                 self.assertTrue(feature_extractor.is_local				)

                 # If remote code is disabled, we load the local one.
                 lowerCAmelCase					:	str       =   AutoFeatureExtractor.from_pretrained(
                     '''hf-internal-testing/test_dynamic_feature_extractor'''					,				trust_remote_code=UpperCamelCase_				)
                 self.assertEqual(feature_extractor.__class__.__name__					,				'''NewFeatureExtractor'''				)
                 self.assertTrue(feature_extractor.is_local				)

                 # If remote is enabled, we load from the Hub
                 lowerCAmelCase					:	Optional[int]       =   AutoFeatureExtractor.from_pretrained(
                     '''hf-internal-testing/test_dynamic_feature_extractor'''					,				trust_remote_code=UpperCamelCase_				)
                 self.assertEqual(feature_extractor.__class__.__name__					,				'''NewFeatureExtractor'''				)
                 self.assertTrue(not hasattr(UpperCamelCase_					,				'''is_local'''				)				)

           finally:
                 if "custom" in CONFIG_MAPPING._extra_content:
                       del CONFIG_MAPPING._extra_content["custom"]
                 if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
                       del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]






"""simple docstring"""





from __future__ import annotations


def      _snake_case						(						_snake_case				:			list[int] ,   _snake_case				:			int			):
      if len(_snake_case			) == 0:
            return False
      lowerCAmelCase					:	List[Any]       =   len(_snake_case			) // 2
      if a_list[midpoint] == item:
            return True
      if item < a_list[midpoint]:
            return binary_search(a_list[:midpoint] ,   _snake_case			)
      else:
            return binary_search(a_list[midpoint + 1 :] ,   _snake_case			)


if __name__ == "__main__":
 snake_case__		:     List[str]    				=				input('''Enter numbers separated by comma:\n''').strip()
 snake_case__		:     Optional[int]    				=				[int(item.strip()) for item in user_input.split(''',''')]
 snake_case__		:     Dict    				=				int(input('''Enter the number to be found in the list:\n''').strip())
 snake_case__		:     str    				=				'''''' if binary_search(sequence, target) else '''not '''
 print(f"""{target} was {not_str}found in {sequence}""")


