

"""simple docstring"""

def       SCREAMING_SNAKE_CASE							( lowercase__					,					lowercase__   )			->						int:
 return int((input_a, input_a).count(0   ) == 0   )



def       SCREAMING_SNAKE_CASE							( )			->						None:
 assert and_gate(0					,					0   ) == 0
 assert and_gate(0					,					1   ) == 0
 assert and_gate(1					,					0   ) == 0
 assert and_gate(1					,					1   ) == 1


if __name__ == "__main__":
    test_and_gate()
    print(and_gate(1, 0))
    print(and_gate(0, 0))
    print(and_gate(0, 1))
    print(and_gate(1, 1))









"""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


_UpperCamelCase		     =    get_tests_dir("""fixtures""")
_UpperCamelCase		     =    get_tests_dir("""fixtures/dummy_feature_extractor_config.json""")
_UpperCamelCase		     =    get_tests_dir("""fixtures/dummy-config.json""")






class 			__a					(						unittest.TestCase       ):





       """simple docstring"""


       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Optional[int] 			=				0






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Optional[int] 			=				AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h"   )
        self.assertIsInstance(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				Tuple 			=				AutoFeatureExtractor.from_pretrained(snake_case   )
        self.assertIsInstance(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        with tempfile.TemporaryDirectory() as tmpdirname:
         lowerCAmelCase__   :				int 			=				WavaVecaConfig()

         # remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
         lowerCAmelCase__   :				Union[str, Any] 			=				AutoFeatureExtractor.from_pretrained(snake_case   ).to_dict()

         config_dict.pop("feature_extractor_type"   )
         lowerCAmelCase__   :				Any 			=				WavaVecaFeatureExtractor(**snake_case   )

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

         lowerCAmelCase__   :				List[str] 			=				AutoFeatureExtractor.from_pretrained(snake_case   )

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

        self.assertIsInstance(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        lowerCAmelCase__   :				List[str] 			=				AutoFeatureExtractor.from_pretrained(snake_case   )
        self.assertIsInstance(snake_case			,					snake_case   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        with self.assertRaisesRegex(
            snake_case			,					"bert-base is not a local folder and is not a valid model identifier"   ):
         lowerCAmelCase__   :				Optional[int] 			=				AutoFeatureExtractor.from_pretrained("bert-base"   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        with self.assertRaisesRegex(
            snake_case			,					R"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"   ):
         lowerCAmelCase__   :				Optional[Any] 			=				AutoFeatureExtractor.from_pretrained(snake_case			,					revision="aaaaaa"   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        with self.assertRaisesRegex(
            snake_case			,					"hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json."			,					):
         lowerCAmelCase__   :				Dict 			=				AutoFeatureExtractor.from_pretrained("hf-internal-testing/config-no-model"   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        with self.assertRaises(snake_case   ):
         lowerCAmelCase__   :				Tuple 			=				AutoFeatureExtractor.from_pretrained(
             "hf-internal-testing/test_dynamic_feature_extractor"   )
        # If remote code is disabled, we can't load this config.
        with self.assertRaises(snake_case   ):
         lowerCAmelCase__   :				str 			=				AutoFeatureExtractor.from_pretrained(
             "hf-internal-testing/test_dynamic_feature_extractor"			,					trust_remote_code=snake_case   )

        lowerCAmelCase__   :				Optional[int] 			=				AutoFeatureExtractor.from_pretrained(
            "hf-internal-testing/test_dynamic_feature_extractor"			,					trust_remote_code=snake_case   )
        self.assertEqual(feature_extractor.__class__.__name__			,					"NewFeatureExtractor"   )

        # Test feature extractor can be reloaded.
        with tempfile.TemporaryDirectory() as tmp_dir:
         feature_extractor.save_pretrained(snake_case   )
         lowerCAmelCase__   :				Optional[Any] 			=				AutoFeatureExtractor.from_pretrained(snake_case			,					trust_remote_code=snake_case   )
        self.assertEqual(reloaded_feature_extractor.__class__.__name__			,					"NewFeatureExtractor"   )






       def 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        try:
         AutoConfig.register("custom"			,					snake_case   )
         AutoFeatureExtractor.register(snake_case			,					snake_case   )
         # Trying to register something existing in the Transformers library will raise an error
         with self.assertRaises(snake_case   ):
          AutoFeatureExtractor.register(snake_case			,					snake_case   )

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

        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 			SCREAMING_SNAKE_CASE_	(   self   ):





        """simple docstring"""

        class 			__a					(						__magic_name__       ):





               """simple docstring"""


               __UpperCamelCase					:      Optional[int]    =						True

        try:
         AutoConfig.register("custom"			,					snake_case   )
         AutoFeatureExtractor.register(snake_case			,					snake_case   )
         # If remote code is not set, the default is to use local
         lowerCAmelCase__   :				List[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__   :				Dict 			=				AutoFeatureExtractor.from_pretrained(
             "hf-internal-testing/test_dynamic_feature_extractor"			,					trust_remote_code=snake_case   )
         self.assertEqual(feature_extractor.__class__.__name__			,					"NewFeatureExtractor"   )
         self.assertTrue(feature_extractor.is_local   )

         # If remote is enabled, we load from the Hub
         lowerCAmelCase__   :				Tuple 			=				AutoFeatureExtractor.from_pretrained(
             "hf-internal-testing/test_dynamic_feature_extractor"			,					trust_remote_code=snake_case   )
         self.assertEqual(feature_extractor.__class__.__name__			,					"NewFeatureExtractor"   )
         self.assertTrue(not hasattr(snake_case			,					"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]






