


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 			SCREAMING_SNAKE_CASE__  (    lowercase__      ):
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					)		->      int:
             a_ :		Union[str, Any]							=  SMALL_MODEL_IDENTIFIER
             a_ :		List[Any]							=  'pt'
             a_ :		str							=  'tf'
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					,							SCREAMING_SNAKE_CASE__    :	Dict					)		->      Optional[int]:
             a_ :		List[str]							=  AutoModel.from_pretrained(self.test_model					)
             model_pt.save_pretrained(SCREAMING_SNAKE_CASE__					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					,							SCREAMING_SNAKE_CASE__    :	Optional[Any]					)		->      Union[str, Any]:
             a_ :		int							=  TFAutoModel.from_pretrained(self.test_model					,							from_pt=SCREAMING_SNAKE_CASE__					)
             model_tf.save_pretrained(SCREAMING_SNAKE_CASE__					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Optional[int]					)		->      List[str]:
             a_ :		Optional[int]							=  'mock_framework'

             # Framework provided - return whatever the user provides
             a_ :		Tuple							=  FeaturesManager.determine_framework(self.test_model					,							SCREAMING_SNAKE_CASE__					)
             self.assertEqual(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)

             # Local checkpoint and framework provided - return provided framework
             # PyTorch checkpoint
             with TemporaryDirectory() as local_pt_ckpt:
                    self._setup_pt_ckpt(SCREAMING_SNAKE_CASE__					)
                    a_ :		Union[str, Any]							=  FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)

             # TensorFlow checkpoint
             with TemporaryDirectory() as local_tf_ckpt:
                    self._setup_tf_ckpt(SCREAMING_SNAKE_CASE__					)
                    a_ :		int							=  FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Any					)		->      List[str]:
             # PyTorch checkpoint
             with TemporaryDirectory() as local_pt_ckpt:
                    self._setup_pt_ckpt(SCREAMING_SNAKE_CASE__					)
                    a_ :		Tuple							=  FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE__					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							self.framework_pt					)

             # TensorFlow checkpoint
             with TemporaryDirectory() as local_tf_ckpt:
                    self._setup_tf_ckpt(SCREAMING_SNAKE_CASE__					)
                    a_ :		Union[str, Any]							=  FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE__					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							self.framework_tf					)

             # Invalid local checkpoint
             with TemporaryDirectory() as local_invalid_ckpt:
                    with self.assertRaises(SCREAMING_SNAKE_CASE__					):
                           a_ :		List[str]							=  FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE__					)

      def 	SCREAMING_SNAKE_CASE							(	self    :	Optional[int]					)		->      Optional[Any]:
             a_ :		List[Any]							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             with patch('transformers.onnx.features.is_tf_available'					,							SCREAMING_SNAKE_CASE__					):
                    a_ :		Union[str, Any]							=  FeaturesManager.determine_framework(self.test_model					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							self.framework_pt					)

             # PyTorch not in environment -> use TensorFlow
             a_ :		Union[str, Any]							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             with patch('transformers.onnx.features.is_torch_available'					,							SCREAMING_SNAKE_CASE__					):
                    a_ :		str							=  FeaturesManager.determine_framework(self.test_model					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							self.framework_tf					)

             # Both in environment -> use PyTorch
             a_ :		int							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             a_ :		Optional[Any]							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             with patch('transformers.onnx.features.is_tf_available'					,							SCREAMING_SNAKE_CASE__					), patch(
                 'transformers.onnx.features.is_torch_available'					,							SCREAMING_SNAKE_CASE__					):
                    a_ :		List[Any]							=  FeaturesManager.determine_framework(self.test_model					)
                    self.assertEqual(SCREAMING_SNAKE_CASE__					,							self.framework_pt					)

             # Both not in environment -> raise error
             a_ :		str							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             a_ :		str							=  MagicMock(return_value=SCREAMING_SNAKE_CASE__					)
             with patch('transformers.onnx.features.is_tf_available'					,							SCREAMING_SNAKE_CASE__					), patch(
                 'transformers.onnx.features.is_torch_available'					,							SCREAMING_SNAKE_CASE__					):
                    with self.assertRaises(SCREAMING_SNAKE_CASE__					):
                           a_ :		Optional[Any]							=  FeaturesManager.determine_framework(self.test_model					)






from __future__ import annotations

UpperCAmelCase_				:			Dict   =	[True] * 100_0001
UpperCAmelCase_				:			Any   =	2
while i * i <= 100_0000:
   if seive[i]:
      for j in range(i * i, 100_0001, i):
         UpperCAmelCase_				:			Tuple   =	False
   i += 1







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		bool:

       """simple docstring"""

       return seive[n]







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		bool:

       """simple docstring"""

       return any(digit in '02468' for digit in str(__A    )    )







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int = 1_00_00_00    )     ->		list[int]:

       """simple docstring"""

       a_ :		Dict							=  [2]  # result already includes the number 2.
       for num in range(3  ,   limit + 1  ,   2    ):
              if is_prime(__A    ) and not contains_an_even_digit(__A    ):
                     a_ :		Dict							=  str(__A    )
                     a_ :		Any							=  [int(str_num[j:] + str_num[:j]    ) for j in range(len(__A    )    )]
                     if all(is_prime(__A    ) for i in list_nums    ):
                            result.append(__A    )
       return result







def 	SCREAMING_SNAKE_CASE_						(      )     ->		int:

       """simple docstring"""

       return len(find_circular_primes()    )


if __name__ == "__main__":
   print(F'{len(find_circular_primes()) = }')


