

from tempfile import TemporaryDirectory
from unittest import TestCase
from unittest.mock import MagicMock, patch

from transformers import AutoModel, TFAutoModel
from transformers.onnx import FeaturesManager
from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch







@require_torch
@require_tf
class 					lowercase							(			a_     ):




				def        a				(   self			):
											snake_case_     							=       SMALL_MODEL_IDENTIFIER
											snake_case_     							=       'pt'
											snake_case_     							=       'tf'




				def        a				(   self ,  snake_case			):
											snake_case_     							=       AutoModel.from_pretrained(self.test_model			)
											model_pt.save_pretrained(lowerCAmelCase_			)




				def        a				(   self ,  snake_case			):
											snake_case_     							=       TFAutoModel.from_pretrained(self.test_model ,  from_pt=lowerCAmelCase_			)
											model_tf.save_pretrained(lowerCAmelCase_			)




				def        a				(   self			):
											snake_case_     							=       'mock_framework'

											# Framework provided - return whatever the user provides
											snake_case_     							=       FeaturesManager.determine_framework(self.test_model ,  lowerCAmelCase_			)
											self.assertEqual(lowerCAmelCase_ ,  lowerCAmelCase_			)

											# Local checkpoint and framework provided - return provided framework
											# PyTorch checkpoint
											with TemporaryDirectory() as local_pt_ckpt:
																		self._setup_pt_ckpt(lowerCAmelCase_			)
																		snake_case_     							=       FeaturesManager.determine_framework(lowerCAmelCase_ ,  lowerCAmelCase_			)
																		self.assertEqual(lowerCAmelCase_ ,  lowerCAmelCase_			)

											# TensorFlow checkpoint
											with TemporaryDirectory() as local_tf_ckpt:
																		self._setup_tf_ckpt(lowerCAmelCase_			)
																		snake_case_     							=       FeaturesManager.determine_framework(lowerCAmelCase_ ,  lowerCAmelCase_			)
																		self.assertEqual(lowerCAmelCase_ ,  lowerCAmelCase_			)




				def        a				(   self			):
											# PyTorch checkpoint
											with TemporaryDirectory() as local_pt_ckpt:
																		self._setup_pt_ckpt(lowerCAmelCase_			)
																		snake_case_     							=       FeaturesManager.determine_framework(lowerCAmelCase_			)
																		self.assertEqual(lowerCAmelCase_ ,  self.framework_pt			)

											# TensorFlow checkpoint
											with TemporaryDirectory() as local_tf_ckpt:
																		self._setup_tf_ckpt(lowerCAmelCase_			)
																		snake_case_     							=       FeaturesManager.determine_framework(lowerCAmelCase_			)
																		self.assertEqual(lowerCAmelCase_ ,  self.framework_tf			)

											# Invalid local checkpoint
											with TemporaryDirectory() as local_invalid_ckpt:
																		with self.assertRaises(lowerCAmelCase_			):
																									snake_case_     							=       FeaturesManager.determine_framework(lowerCAmelCase_			)




				def        a				(   self			):
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											with patch('transformers.onnx.features.is_tf_available' ,  lowerCAmelCase_			):
																		snake_case_     							=       FeaturesManager.determine_framework(self.test_model			)
																		self.assertEqual(lowerCAmelCase_ ,  self.framework_pt			)

											# PyTorch not in environment -> use TensorFlow
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											with patch('transformers.onnx.features.is_torch_available' ,  lowerCAmelCase_			):
																		snake_case_     							=       FeaturesManager.determine_framework(self.test_model			)
																		self.assertEqual(lowerCAmelCase_ ,  self.framework_tf			)

											# Both in environment -> use PyTorch
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											with patch('transformers.onnx.features.is_tf_available' ,  lowerCAmelCase_			), patch(
											    'transformers.onnx.features.is_torch_available' ,  lowerCAmelCase_			):
																		snake_case_     							=       FeaturesManager.determine_framework(self.test_model			)
																		self.assertEqual(lowerCAmelCase_ ,  self.framework_pt			)

											# Both not in environment -> raise error
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											snake_case_     							=       MagicMock(return_value=lowerCAmelCase_			)
											with patch('transformers.onnx.features.is_tf_available' ,  lowerCAmelCase_			), patch(
											    'transformers.onnx.features.is_torch_available' ,  lowerCAmelCase_			):
																		with self.assertRaises(lowerCAmelCase_			):
																									snake_case_     							=       FeaturesManager.determine_framework(self.test_model			)








'''simple docstring'''





from __future__ import annotations

from functools import lru_cache
from math import ceil

UpperCAmelCase__  			=				1_0_0

UpperCAmelCase__  			=				set(range(3, NUM_PRIMES, 2))
primes.add(2)
UpperCAmelCase__  			=				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=100 )
def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: int ):






			"""simple docstring"""




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

			__A=	set()
			__A=	42
			__A=	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__(				_SCREAMING_SNAKE_CASE					: int = 5000 ):






			"""simple docstring"""




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


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



