

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


a_						     =    get_tests_dir('fixtures')
a_						     =    get_tests_dir('fixtures/dummy_feature_extractor_config.json')
a_						     =    get_tests_dir('fixtures/dummy-config.json')






class _UpperCamelCase							(							unittest.TestCase   ):
			'''simple docstring'''







			def 							__UpperCamelCase (			self							: Union[str, Any]	)							->       Optional[Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE   :      Optional[int]				     =       0
			def 							__UpperCamelCase (			self							: int	)							->       Tuple:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE   :      Optional[Any]				     =       AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h"	)
				self.assertIsInstance(a      ,      a	)
			def 							__UpperCamelCase (			self							: List[Any]	)							->       Union[str, Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE   :      Optional[Any]				     =       AutoFeatureExtractor.from_pretrained(a	)
				self.assertIsInstance(a      ,      a	)
			def 							__UpperCamelCase (			self							: int	)							->       Optional[int]:

				"""simple docstring"""

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

					# remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
					SCREAMING_SNAKE_CASE   :      Optional[Any]				     =       AutoFeatureExtractor.from_pretrained(a	).to_dict()

					config_dict.pop("feature_extractor_type"	)
					SCREAMING_SNAKE_CASE   :      int				     =       WavaVecaFeatureExtractor(**a	)

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

					SCREAMING_SNAKE_CASE   :      Union[str, Any]				     =       AutoFeatureExtractor.from_pretrained(a	)

					# make sure private variable is not incorrectly saved
					SCREAMING_SNAKE_CASE   :      Tuple				     =       json.loads(config.to_json_string()	)
					self.assertTrue("_processor_class" not in dict_as_saved	)

				self.assertIsInstance(a      ,      a	)
			def 							__UpperCamelCase (			self							: Optional[Any]	)							->       Any:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE   :      Any				     =       AutoFeatureExtractor.from_pretrained(a	)
				self.assertIsInstance(a      ,      a	)
			def 							__UpperCamelCase (			self							: Any	)							->       Union[str, Any]:

				"""simple docstring"""

				with self.assertRaisesRegex(
				    a      ,      "bert-base is not a local folder and is not a valid model identifier"	):
					SCREAMING_SNAKE_CASE   :      Any				     =       AutoFeatureExtractor.from_pretrained("bert-base"	)
			def 							__UpperCamelCase (			self							: Union[str, Any]	)							->       str:

				"""simple docstring"""

				with self.assertRaisesRegex(
				    a      ,      R"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"	):
					SCREAMING_SNAKE_CASE   :      Any				     =       AutoFeatureExtractor.from_pretrained(a      ,      revision="aaaaaa"	)
			def 							__UpperCamelCase (			self							: str	)							->       str:

				"""simple docstring"""

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

				"""simple docstring"""

				with self.assertRaises(a	):
					SCREAMING_SNAKE_CASE   :      str				     =       AutoFeatureExtractor.from_pretrained(
					    "hf-internal-testing/test_dynamic_feature_extractor"	)
				# If remote code is disabled, we can't load this config.
				with self.assertRaises(a	):
					SCREAMING_SNAKE_CASE   :      List[Any]				     =       AutoFeatureExtractor.from_pretrained(
					    "hf-internal-testing/test_dynamic_feature_extractor"      ,      trust_remote_code=a	)

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

				# Test feature extractor can be reloaded.
				with tempfile.TemporaryDirectory() as tmp_dir:
					feature_extractor.save_pretrained(a	)
					SCREAMING_SNAKE_CASE   :      Any				     =       AutoFeatureExtractor.from_pretrained(a      ,      trust_remote_code=a	)
				self.assertEqual(reloaded_feature_extractor.__class__.__name__      ,      "NewFeatureExtractor"	)
			def 							__UpperCamelCase (			self							: int	)							->       Tuple:

				"""simple docstring"""

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

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

				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 							__UpperCamelCase (			self							: List[Any]	)							->       List[Any]:

				"""simple docstring"""

				class _UpperCamelCase							(							__A   ):
							'''simple docstring'''







							lowerCamelCase__           =True

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

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


def  lowerCamelCase__ (					_a = 50):
	SCREAMING_SNAKE_CASE   :      int				     =       [1] * (length + 1)

	for row_length in range(length + 1):
		for tile_length in range(2							,			5):
			for tile_start in range(row_length - tile_length + 1):
				ways_number[row_length] += ways_number[
				    row_length - tile_start - tile_length
				]

	return ways_number[length]


if __name__ == "__main__":
			print(F'''{solution() = }''')