






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

import transformers
import transformers.models.auto
from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig
from transformers.models.bert.configuration_bert import BertConfig
from transformers.models.roberta.configuration_roberta import RobertaConfig
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


__snake_case    :    Optional[int]         =     get_tests_dir("""fixtures/dummy-config.json""")


class     __SCREAMING_SNAKE_CASE					(   unittest.TestCase):






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						0






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												self.assertIsNotNone(transformers.models.auto.__spec__   )
												self.assertIsNotNone(importlib.util.find_spec('transformers.models.auto'   )   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						AutoConfig.from_pretrained('bert-base-uncased'   )
												self.assertIsInstance(_UpperCamelCase     ,						_UpperCamelCase   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase   )
												self.assertIsInstance(_UpperCamelCase     ,						_UpperCamelCase   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase   )
												self.assertIsInstance(_UpperCamelCase     ,						_UpperCamelCase   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						AutoConfig.for_model('roberta'   )
												self.assertIsInstance(_UpperCamelCase     ,						_UpperCamelCase   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												with tempfile.TemporaryDirectory() as tmp_dir:
																		# This model name contains bert and roberta, but roberta ends up being picked.
																		lowerCAmelCase__    						=						os.path.join(_UpperCamelCase     ,						'fake-roberta'   )
																		os.makedirs(_UpperCamelCase     ,						exist_ok=_UpperCamelCase   )
																		with open(os.path.join(_UpperCamelCase     ,						'config.json'   )     ,						'w'   ) as f:
																								f.write(json.dumps({}   )   )
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase   )
																		self.assertEqual(type(_UpperCamelCase   )     ,						_UpperCamelCase   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												try:
																		AutoConfig.register('custom'     ,						_UpperCamelCase   )
																		# Wrong model type will raise an error
																		with self.assertRaises(_UpperCamelCase   ):
																								AutoConfig.register('model'     ,						_UpperCamelCase   )
																		# Trying to register something existing in the Transformers library will raise an error
																		with self.assertRaises(_UpperCamelCase   ):
																								AutoConfig.register('bert'     ,						_UpperCamelCase   )

																		# Now that the config is registered, it can be used as any other config with the auto-API
																		lowerCAmelCase__    						=						CustomConfig()
																		with tempfile.TemporaryDirectory() as tmp_dir:
																								config.save_pretrained(_UpperCamelCase   )
																								lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase   )
																								self.assertIsInstance(_UpperCamelCase     ,						_UpperCamelCase   )

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






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    _UpperCamelCase     ,						'bert-base is not a local folder and is not a valid model identifier'   ):
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('bert-base'   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    _UpperCamelCase     ,						r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'   ):
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase     ,						revision='aaaaaa'   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    _UpperCamelCase     ,						'hf-internal-testing/no-config-test-repo does not appear to have a file named config.json.'     ,						):
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/no-config-test-repo'   )






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												# If remote code is not set, we will time out when asking whether to load the model.
												with self.assertRaises(_UpperCamelCase   ):
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'   )
												# If remote code is disabled, we can't load this config.
												with self.assertRaises(_UpperCamelCase   ):
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'     ,						trust_remote_code=_UpperCamelCase   )

												lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'     ,						trust_remote_code=_UpperCamelCase   )
												self.assertEqual(config.__class__.__name__     ,						'NewModelConfig'   )

												# Test config can be reloaded.
												with tempfile.TemporaryDirectory() as tmp_dir:
																		config.save_pretrained(_UpperCamelCase   )
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained(_UpperCamelCase     ,						trust_remote_code=_UpperCamelCase   )
												self.assertEqual(reloaded_config.__class__.__name__     ,						'NewModelConfig'   )







						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""


												class     __SCREAMING_SNAKE_CASE					(   __lowercase):
																		_SCREAMING_SNAKE_CASE	:       int   =					'''new-model'''

												try:
																		AutoConfig.register('new-model'     ,						_UpperCamelCase   )
																		# If remote code is not set, the default is to use local
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'   )
																		self.assertEqual(config.__class__.__name__     ,						'NewModelConfigLocal'   )

																		# If remote code is disabled, we load the local one.
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'     ,						trust_remote_code=_UpperCamelCase   )
																		self.assertEqual(config.__class__.__name__     ,						'NewModelConfigLocal'   )

																		# If remote is enabled, we load from the Hub
																		lowerCAmelCase__    						=						AutoConfig.from_pretrained('hf-internal-testing/test_dynamic_model'     ,						trust_remote_code=_UpperCamelCase   )
																		self.assertEqual(config.__class__.__name__     ,						'NewModelConfig'   )

												finally:
																		if "new-model" in CONFIG_MAPPING._extra_content:
																								del CONFIG_MAPPING._extra_content["new-model"]













from __future__ import annotations

from functools import lru_cache
from math import ceil

__snake_case    :    Union[str, Any]         =     1_00

__snake_case    :    Tuple         =     set(range(3, NUM_PRIMES, 2))
primes.add(2)
__snake_case    :    int

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
					if prime not in primes:
										continue
					primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))







@lru_cache(maxsize=100		)
def 	_UpperCamelCase   (    UpperCamelCase_       :					int		)  ->   set[int]:

						"""simple docstring"""



						if number_to_partition < 0:
												return set()
						elif number_to_partition == 0:
												return {1}

						lowerCAmelCase__    						=						set()
						lowerCAmelCase__    						=						42
						lowerCAmelCase__    						=						42

						for prime in primes:
												if prime > number_to_partition:
																		continue
												for sub in partition(number_to_partition - prime		):
																		ret.add(sub * prime		)

						return ret







def 	_UpperCamelCase   (    UpperCamelCase_       :					int = 5000		)  ->   int | None:

						"""simple docstring"""



						for number_to_partition in range(1    ,       UpperCamelCase_		):
												if len(partition(UpperCamelCase_		)		) > number_unique_partitions:
																		return number_to_partition
						return None


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





