


from typing import Tuple, Union

from ...modeling_outputs import BackboneOutput
from ...modeling_utils import PreTrainedModel
from ...utils import is_timm_available, is_torch_available, requires_backends
from ...utils.backbone_utils import BackboneMixin
from .configuration_timm_backbone import TimmBackboneConfig


if is_timm_available():
			import timm


if is_torch_available():
			from torch import Tensor

class     a		(_lowerCAmelCase					,    _lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							Optional[Any]					  =  "pixel_values"
							__UpperCAmelCase   :							List[Any]					  =  False
							__UpperCAmelCase   :							int					  =  TimmBackboneConfig

							def __init__(							self	:  Dict   ,     lowerCamelCase	:  List[str]   ,     **lowerCamelCase	:  List[str]    )     ->   Optional[int]:
														requires_backends(self   ,     "timm"    )
														super().__init__(lowerCamelCase    )
														__snake_case		:      List[str]										=       config

														if config.backbone is None:
																					raise ValueError("backbone is not set in the config. Please set it to a timm model name."    )

														if config.backbone not in timm.list_models():
																					raise ValueError(F'backbone {config.backbone} is not supported by timm.'    )

														if hasattr(lowerCamelCase   ,     "out_features"    ) and config.out_features is not None:
																					raise ValueError("out_features is not supported by TimmBackbone. Please use out_indices instead."    )

														__snake_case		:      List[str]										=       getattr(lowerCamelCase   ,     "use_pretrained_backbone"   ,     lowerCamelCase    )
														if pretrained is None:
																					raise ValueError("use_pretrained_backbone is not set in the config. Please set it to True or False."    )

														# We just take the final layer by default. This matches the default for the transformers models.
														__snake_case		:      Optional[int]										=       config.out_indices if getattr(lowerCamelCase   ,     "out_indices"   ,     lowerCamelCase    ) is not None else (-1,)

														__snake_case		:      List[str]										=       timm.create_model(
														    config.backbone   ,     pretrained=lowerCamelCase   ,     features_only=config.features_only   ,     in_chans=config.num_channels   ,     out_indices=lowerCamelCase   ,     **lowerCamelCase   ,     )
														# These are used to control the output of the model when called. If output_hidden_states is True, then
														# return_layers is modified to include all layers.
														__snake_case		:      Union[str, Any]										=       self._backbone.return_layers
														__snake_case		:      str										=       {layer["module"]: str(lowerCamelCase    ) for i, layer in enumerate(self._backbone.feature_info.info    )}
														super()._init_backbone(lowerCamelCase    )

							@classmethod
							def    __snake_case (							cls	:  List[str]   ,     lowerCamelCase	:  Union[str, Any]   ,     *lowerCamelCase	:  Tuple   ,     **lowerCamelCase	:  Optional[Any]    )     ->   Dict:
														requires_backends(cls   ,     ["vision", "timm"]    )
														from ...models.timm_backbone import TimmBackboneConfig

														__snake_case		:      List[str]										=       kwargs.pop("config"   ,     TimmBackboneConfig()    )

														__snake_case		:      Any										=       kwargs.pop("use_timm_backbone"   ,     lowerCamelCase    )
														if not use_timm:
																					raise ValueError("use_timm_backbone must be True for timm backbones"    )

														__snake_case		:      Optional[int]										=       kwargs.pop("num_channels"   ,     config.num_channels    )
														__snake_case		:      Optional[Any]										=       kwargs.pop("features_only"   ,     config.features_only    )
														__snake_case		:      Any										=       kwargs.pop("use_pretrained_backbone"   ,     config.use_pretrained_backbone    )
														__snake_case		:      Any										=       kwargs.pop("out_indices"   ,     config.out_indices    )
														__snake_case		:      str										=       TimmBackboneConfig(
														    backbone=lowerCamelCase   ,     num_channels=lowerCamelCase   ,     features_only=lowerCamelCase   ,     use_pretrained_backbone=lowerCamelCase   ,     out_indices=lowerCamelCase   ,     )
														return super()._from_config(lowerCamelCase   ,     **lowerCamelCase    )

							def    __snake_case (							self	:  str   ,     lowerCamelCase	:  Optional[Any]    )     ->   List[str]:
														pass






							def    __snake_case (							self	:  int   ,     lowerCamelCase	:  Dict   ,     lowerCamelCase	:  List[Any]=None   ,     lowerCamelCase	:  Optional[Any]=None   ,     lowerCamelCase	:  int=None   ,     **lowerCamelCase	:  List[str]    )     ->   Union[BackboneOutput, Tuple[Tensor, ...]]:
														__snake_case		:      Tuple										=       return_dict if return_dict is not None else self.config.use_return_dict
														__snake_case		:      str										=       (
														    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
														)
														__snake_case		:      Optional[Any]										=       output_attentions if output_attentions is not None else self.config.output_attentions

														if output_attentions:
																					raise ValueError("Cannot output attentions for timm backbones at the moment"    )

														if output_hidden_states:
																					# We modify the return layers to include all the stages of the backbone
																					__snake_case		:      List[str]										=       self._all_layers
																					__snake_case		:      str										=       self._backbone(lowerCamelCase   ,     **lowerCamelCase    )
																					__snake_case		:      int										=       self._return_layers
																					__snake_case		:      int										=       tuple(hidden_states[i] for i in self.out_indices    )
														else:
																					__snake_case		:      Any										=       self._backbone(lowerCamelCase   ,     **lowerCamelCase    )
																					__snake_case		:      str										=       None

														__snake_case		:      Any										=       tuple(lowerCamelCase    )
														__snake_case		:      Tuple										=       tuple(lowerCamelCase    ) if hidden_states is not None else None

														if not return_dict:
																					__snake_case		:      Dict										=       (feature_maps,)
																					if output_hidden_states:
																												__snake_case		:      str										=       output + (hidden_states,)
																					return output

														return BackboneOutput(feature_maps=lowerCamelCase   ,     hidden_states=lowerCamelCase   ,     attentions=lowerCamelCase    )





from __future__ import annotations

from functools import lru_cache
from math import ceil

_snake_case					:		Tuple      =    100

_snake_case					:		int      =    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=1_0_0     )
def     lowerCAmelCase_					( __lowerCamelCase     ):
							if number_to_partition < 0:
														return set()
							elif number_to_partition == 0:
														return {1}

							__snake_case		:      set[int]										=       set()
							__snake_case		:      int
							__snake_case		:      int

							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_					( __lowerCamelCase = 5_0_0_0     ):
							for number_to_partition in range(1							,     __lowerCamelCase     ):
														if len(partition(__lowerCamelCase     )     ) > number_unique_partitions:
																					return number_to_partition
							return None


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

