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


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







class        UpperCamelCase		(			unittest.TestCase  ):
   def 			_UpperCAmelCase   (			self			)	->      Optional[int]:


        '''simple docstring'''


        lowercase_	:				List[str]													=	0
   def 			_UpperCAmelCase   (			self			)	->      List[str]:


        '''simple docstring'''


        lowercase_	:				List[Any]													=	AutoFeatureExtractor.from_pretrained('facebook/wav2vec2-base-960h'			)
        self.assertIsInstance(__UpperCamelCase     ,__UpperCamelCase			)
   def 			_UpperCAmelCase   (			self			)	->      Union[str, Any]:


        '''simple docstring'''


        lowercase_	:				int													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase			)
        self.assertIsInstance(__UpperCamelCase     ,__UpperCamelCase			)
   def 			_UpperCAmelCase   (			self			)	->      int:


        '''simple docstring'''


        with tempfile.TemporaryDirectory() as tmpdirname:
             lowercase_	:				Tuple													=	WavaVecaConfig()

             # remove feature_extractor_type to make sure config.json alone is enough to load feature processor locally
             lowercase_	:				Tuple													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase			).to_dict()

             config_dict.pop('feature_extractor_type'			)
             lowercase_	:				List[Any]													=	WavaVecaFeatureExtractor(**__UpperCamelCase			)

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

             lowercase_	:				Optional[int]													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase			)

             # make sure private variable is not incorrectly saved
             lowercase_	:				str													=	json.loads(config.to_json_string()			)
             self.assertTrue('_processor_class' not in dict_as_saved			)

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


        '''simple docstring'''


        lowercase_	:				Optional[int]													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase			)
        self.assertIsInstance(__UpperCamelCase     ,__UpperCamelCase			)
   def 			_UpperCAmelCase   (			self			)	->      Union[str, Any]:


        '''simple docstring'''


        with self.assertRaisesRegex(
            __UpperCamelCase     ,'bert-base is not a local folder and is not a valid model identifier'			):
             lowercase_	:				List[str]													=	AutoFeatureExtractor.from_pretrained('bert-base'			)
   def 			_UpperCAmelCase   (			self			)	->      Optional[Any]:


        '''simple docstring'''


        with self.assertRaisesRegex(
            __UpperCamelCase     ,r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'			):
             lowercase_	:				Optional[int]													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase     ,revision='aaaaaa'			)
   def 			_UpperCAmelCase   (			self			)	->      List[str]:


        '''simple docstring'''


        with self.assertRaisesRegex(
            __UpperCamelCase     ,'hf-internal-testing/config-no-model does not appear to have a file named preprocessor_config.json.'     ,):
             lowercase_	:				List[str]													=	AutoFeatureExtractor.from_pretrained('hf-internal-testing/config-no-model'			)
   def 			_UpperCAmelCase   (			self			)	->      Dict:


        '''simple docstring'''


        with self.assertRaises(__UpperCamelCase			):
             lowercase_	:				List[Any]													=	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			):
             lowercase_	:				str													=	AutoFeatureExtractor.from_pretrained(
                 'hf-internal-testing/test_dynamic_feature_extractor'     ,trust_remote_code=__UpperCamelCase			)

        lowercase_	:				List[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			)
             lowercase_	:				Any													=	AutoFeatureExtractor.from_pretrained(__UpperCamelCase     ,trust_remote_code=__UpperCamelCase			)
        self.assertEqual(reloaded_feature_extractor.__class__.__name__     ,'NewFeatureExtractor'			)
   def 			_UpperCAmelCase   (			self			)	->      Union[str, Any]:


        '''simple docstring'''


        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
             lowercase_	:				int													=	CustomFeatureExtractor.from_pretrained(__UpperCamelCase			)
             with tempfile.TemporaryDirectory() as tmp_dir:
                  feature_extractor.save_pretrained(__UpperCamelCase			)
                  lowercase_	:				Dict													=	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 			_UpperCAmelCase   (			self			)	->      Union[str, Any]:


        '''simple docstring'''


        class        UpperCamelCase		(			lowercase_  ):
           lowercase							=  True

        try:
             AutoConfig.register('custom'     ,__UpperCamelCase			)
             AutoFeatureExtractor.register(__UpperCamelCase     ,__UpperCamelCase			)
             # If remote code is not set, the default is to use local
             lowercase_	:				int													=	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.
             lowercase_	:				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(feature_extractor.is_local			)

             # If remote is enabled, we load from the Hub
             lowercase_	:				Union[str, Any]													=	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"""







__SCREAMING_SNAKE_CASE    	={}



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     int     ,			__SCREAMING_SNAKE_CASE							:     int     ,			__SCREAMING_SNAKE_CASE							:     int      ):

     # if we are absent twice, or late 3 consecutive days,
     # no further prize strings are possible
     if late == 3 or absent == 2:
          return 0

     # if we have no days left, and have not failed any other rules,
     # we have a prize string
     if days == 0:
          return 1

     # No easy solution, so now we need to do the recursive calculation

     # First, check if the combination is already in the cache, and
     # if yes, return the stored value from there since we already
     # know the number of possible prize strings from this point on
     lowercase_	:				Any													=	(days, absent, late)
     if key in cache:
          return cache[key]

     # now we calculate the three possible ways that can unfold from
     # this point on, depending on our attendance today

     # 1) if we are late (but not absent), the "absent" counter stays as
     # it is, but the "late" counter increases by one
     lowercase_	:				Optional[int]													=	_calculate(days - 1     ,			__SCREAMING_SNAKE_CASE     ,			late + 1      )

     # 2) if we are absent, the "absent" counter increases by 1, and the
     # "late" counter resets to 0
     lowercase_	:				Any													=	_calculate(days - 1     ,			absent + 1     ,			0      )

     # 3) if we are on time, this resets the "late" counter and keeps the
     # absent counter
     lowercase_	:				Dict													=	_calculate(days - 1     ,			__SCREAMING_SNAKE_CASE     ,			0      )

     lowercase_	:				str													=	state_late + state_absent + state_ontime

     lowercase_	:				Tuple													=	prizestrings
     return prizestrings



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     int = 30      ):
     return _calculate(__SCREAMING_SNAKE_CASE     ,			absent=0     ,			late=0      )


if __name__ == "__main__":
       print(solution())

