
"""simple docstring"""





from __future__ import annotations

from functools import lru_cache
from math import ceil

_a								=						100

_a								=						set(range(3, NUM_PRIMES, 2))
primes.add(2)
_a								=						42

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=1_00      )
def  lowerCamelCase__						(     __snake_case      )				->						set[int]:


					"""simple docstring"""





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

					_UpperCamelCase									=    set()
					_UpperCamelCase									=    42
					_UpperCamelCase									=    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  lowerCamelCase__						(     __snake_case = 50_00      )				->						int | None:


					"""simple docstring"""





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


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








"""simple docstring"""





import inspect
import unittest

from huggingface_hub import hf_hub_download

from transformers import ConvNextConfig, UperNetConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
				import torch

				from transformers import UperNetForSemanticSegmentation
				from transformers.models.upernet.modeling_upernet import UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				from PIL import Image

				from transformers import AutoImageProcessor






class        _UpperCAmelCase:



		def __init__(   self							,						__a							,						__a=13							,						__a=32							,						__a=3							,						__a=4							,						__a=[10, 20, 30, 40]							,						__a=[2, 2, 3, 2]							,						__a=True							,						__a=True							,						__a=37							,						__a="gelu"							,						__a=10							,						__a=0.02							,						__a=["stage2", "stage3", "stage4"]							,						__a=3							,						__a=None							,						)			->			Optional[Any]:






							'''simple docstring'''
							_UpperCamelCase									=    parent
							_UpperCamelCase									=    batch_size
							_UpperCamelCase									=    image_size
							_UpperCamelCase									=    num_channels
							_UpperCamelCase									=    num_stages
							_UpperCamelCase									=    hidden_sizes
							_UpperCamelCase									=    depths
							_UpperCamelCase									=    is_training
							_UpperCamelCase									=    use_labels
							_UpperCamelCase									=    intermediate_size
							_UpperCamelCase									=    hidden_act
							_UpperCamelCase									=    type_sequence_label_size
							_UpperCamelCase									=    initializer_range
							_UpperCamelCase									=    out_features
							_UpperCamelCase									=    num_labels
							_UpperCamelCase									=    scope
							_UpperCamelCase									=    num_stages



		def 		UpperCAmelCase				(   self)			->			List[str]:






							'''simple docstring'''
							_UpperCamelCase									=    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

							_UpperCamelCase									=    None
							if self.use_labels:
												_UpperCamelCase									=    ids_tensor([self.batch_size]							,						self.type_sequence_label_size)

							_UpperCamelCase									=    self.get_config()

							return config, pixel_values, labels



		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							return ConvNextConfig(
							    num_channels=self.num_channels							,						num_stages=self.num_stages							,						hidden_sizes=self.hidden_sizes							,						depths=self.depths							,						is_training=self.is_training							,						intermediate_size=self.intermediate_size							,						hidden_act=self.hidden_act							,						out_features=self.out_features							,						)



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							return UperNetConfig(
							    backbone_config=self.get_backbone_config()							,						hidden_size=5_12							,						pool_scales=[1, 2, 3, 6]							,						use_auxiliary_head=__a							,						auxiliary_loss_weight=0.4							,						auxiliary_in_channels=40							,						auxiliary_channels=2_56							,						auxiliary_num_convs=1							,						auxiliary_concat_input=__a							,						loss_ignore_index=2_55							,						num_labels=self.num_labels							,						)



		def 		UpperCAmelCase				(   self							,						__a							,						__a							,						__a)			->			Optional[Any]:






							'''simple docstring'''
							_UpperCamelCase									=    UperNetForSemanticSegmentation(config=__a)
							model.to(__a)
							model.eval()
							_UpperCamelCase									=    model(__a)
							self.parent.assertEqual(
							    result.logits.shape							,						(self.batch_size, self.num_labels, self.image_size, self.image_size))




		def 		UpperCAmelCase				(   self)			->			Dict:






							'''simple docstring'''
							_UpperCamelCase									=    self.prepare_config_and_inputs()
							(
							    (
							    _UpperCamelCase
							)					,    (
							    _UpperCamelCase
							)					,    (
							    _UpperCamelCase
							)					,    
							)									=    config_and_inputs
							_UpperCamelCase									=    {'''pixel_values''': pixel_values}
							return config, inputs_dict






@require_torch
class        _UpperCAmelCase(       lowerCamelCase ,	lowerCamelCase ,	unittest.TestCase      ):
		lowercase__         = (UperNetForSemanticSegmentation,) if is_torch_available() else ()
		lowercase__         = {'image-segmentation': UperNetForSemanticSegmentation} if is_torch_available() else {}
		lowercase__         = False
		lowercase__         = False
		lowercase__         = False
		lowercase__         = False
		lowercase__         = False
		lowercase__         = False



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






							'''simple docstring'''
							_UpperCamelCase									=    UperNetModelTester(self)
							_UpperCamelCase									=    ConfigTester(self							,						config_class=__a							,						has_text_modality=__a							,						hidden_size=37)



		def 		UpperCAmelCase				(   self)			->			Dict:






							'''simple docstring'''
							self.create_and_test_config_common_properties()
							self.config_tester.create_and_test_config_to_json_string()
							self.config_tester.create_and_test_config_to_json_file()
							self.config_tester.create_and_test_config_from_and_save_pretrained()
							self.config_tester.create_and_test_config_with_num_labels()
							self.config_tester.check_config_can_be_init_without_params()
							self.config_tester.check_config_arguments_init()



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							return



		def 		UpperCAmelCase				(   self)			->			str:






							'''simple docstring'''
							_UpperCamelCase					,    _UpperCamelCase									=    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
												_UpperCamelCase									=    model_class(__a)
												_UpperCamelCase									=    inspect.signature(model.forward)
												# signature.parameters is an OrderedDict => so arg_names order is deterministic
												_UpperCamelCase									=    [*signature.parameters.keys()]

												_UpperCamelCase									=    ['''pixel_values''']
												self.assertListEqual(arg_names[:1]							,						__a)



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							_UpperCamelCase									=    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_semantic_segmentation(*__a)



		@unittest.skip(reason='''UperNet does not use inputs_embeds''')
		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							pass



		@unittest.skip(reason='''UperNet does not support input and output embeddings''')
		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							pass



		@unittest.skip(reason='''UperNet does not have a base model''')
		def 		UpperCAmelCase				(   self)			->			Tuple:






							'''simple docstring'''
							pass



		@unittest.skip(reason='''UperNet does not have a base model''')
		def 		UpperCAmelCase				(   self)			->			int:






							'''simple docstring'''
							pass



		@require_torch_multi_gpu
		@unittest.skip(reason='''UperNet has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`''')
		def 		UpperCAmelCase				(   self)			->			Union[str, Any]:






							'''simple docstring'''
							pass



		@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.''')
		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							pass



		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							def check_hidden_states_output(__a							,						__a							,						__a):
												_UpperCamelCase									=    model_class(__a)
												model.to(__a)
												model.eval()

												with torch.no_grad():
																	_UpperCamelCase									=    model(**self._prepare_for_class(__a							,						__a))

												_UpperCamelCase									=    outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

												_UpperCamelCase									=    self.model_tester.num_stages
												self.assertEqual(len(__a)							,						expected_num_stages + 1)

												# ConvNext's feature maps are of shape (batch_size, num_channels, height, width)
												self.assertListEqual(
												    list(hidden_states[0].shape[-2:])							,						[self.model_tester.image_size // 4, self.model_tester.image_size // 4]							,						)

							_UpperCamelCase					,    _UpperCamelCase									=    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
												_UpperCamelCase									=    True
												check_hidden_states_output(__a							,						__a							,						__a)

												# check that output_hidden_states also work using config
												del inputs_dict["output_hidden_states"]
												_UpperCamelCase									=    True

												check_hidden_states_output(__a							,						__a							,						__a)



		def 		UpperCAmelCase				(   self)			->			Optional[Any]:






							'''simple docstring'''
							_UpperCamelCase					,    _UpperCamelCase									=    self.model_tester.prepare_config_and_inputs_for_common()

							_UpperCamelCase									=    _config_zero_init(__a)
							_UpperCamelCase									=    _config_zero_init(configs_no_init.backbone_config)
							for model_class in self.all_model_classes:
												_UpperCamelCase									=    model_class(config=__a)
												for name, param in model.named_parameters():
																	if param.requires_grad:
																						self.assertIn(
																						    ((param.data.mean() * 1e9).round() / 1e9).item()							,						[0.0, 1.0]							,						msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''							,						)



		@unittest.skip(reason='''UperNet does not have tied weights''')
		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							pass




		@slow
		def 		UpperCAmelCase				(   self)			->			Optional[Any]:






							'''simple docstring'''
							for model_name in UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												_UpperCamelCase									=    UperNetForSemanticSegmentation.from_pretrained(__a)
												self.assertIsNotNone(__a)





def  lowerCamelCase__						(     )				->						int:


					"""simple docstring"""





					_UpperCamelCase									=    hf_hub_download(
					    repo_id='''hf-internal-testing/fixtures_ade20k''',	repo_type='''dataset''',	filename='''ADE_val_00000001.jpg'''      )
					_UpperCamelCase									=    Image.open(__snake_case      ).convert('''RGB'''      )
					return image






@require_torch
@require_vision
@slow
class        _UpperCAmelCase(       unittest.TestCase      ):



		def 		UpperCAmelCase				(   self)			->			Optional[int]:






							'''simple docstring'''
							_UpperCamelCase									=    AutoImageProcessor.from_pretrained('''openmmlab/upernet-swin-tiny''')
							_UpperCamelCase									=    UperNetForSemanticSegmentation.from_pretrained('''openmmlab/upernet-swin-tiny''').to(__a)

							_UpperCamelCase									=    prepare_img()
							_UpperCamelCase									=    processor(images=__a							,						return_tensors='''pt''').to(__a)

							with torch.no_grad():
												_UpperCamelCase									=    model(**__a)

							_UpperCamelCase									=    torch.Size((1, model.config.num_labels, 5_12, 5_12))
							self.assertEqual(outputs.logits.shape							,						__a)

							_UpperCamelCase									=    torch.tensor(
							    [[-7.5958, -7.5958, -7.4302], [-7.5958, -7.5958, -7.4302], [-7.4797, -7.4797, -7.3068]]).to(__a)
							self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]							,						__a							,						atol=1e-4))




		def 		UpperCAmelCase				(   self)			->			List[Any]:






							'''simple docstring'''
							_UpperCamelCase									=    AutoImageProcessor.from_pretrained('''openmmlab/upernet-convnext-tiny''')
							_UpperCamelCase									=    UperNetForSemanticSegmentation.from_pretrained('''openmmlab/upernet-convnext-tiny''').to(__a)

							_UpperCamelCase									=    prepare_img()
							_UpperCamelCase									=    processor(images=__a							,						return_tensors='''pt''').to(__a)

							with torch.no_grad():
												_UpperCamelCase									=    model(**__a)

							_UpperCamelCase									=    torch.Size((1, model.config.num_labels, 5_12, 5_12))
							self.assertEqual(outputs.logits.shape							,						__a)

							_UpperCamelCase									=    torch.tensor(
							    [[-8.8110, -8.8110, -8.6521], [-8.8110, -8.8110, -8.6521], [-8.7746, -8.7746, -8.6130]]).to(__a)
							self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]							,						__a							,						atol=1e-4))






