'''simple docstring'''




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        a__ (  A_					):






     def   SCREAMING_SNAKE_CASE__  (					self						:						str       ):





         """simple docstring"""



         __lowerCamelCase            =    SMALL_MODEL_IDENTIFIER
         __lowerCamelCase            =    "pt"
         __lowerCamelCase            =    "tf"






     def   SCREAMING_SNAKE_CASE__  (					self						:						Tuple    ,							a						:						Tuple       ):





         """simple docstring"""



         __lowerCamelCase            =    AutoModel.from_pretrained(self.test_model       )
         model_pt.save_pretrained(snake_case__       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						int    ,							a						:						Any       ):





         """simple docstring"""



         __lowerCamelCase            =    TFAutoModel.from_pretrained(self.test_model    ,							from_pt=snake_case__       )
         model_tf.save_pretrained(snake_case__       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Union[str, Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    "mock_framework"

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

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

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






     def   SCREAMING_SNAKE_CASE__  (					self						:						Union[str, Any]       ):





         """simple docstring"""



         with TemporaryDirectory() as local_pt_ckpt:
             self._setup_pt_ckpt(snake_case__       )
             __lowerCamelCase            =    FeaturesManager.determine_framework(snake_case__       )
             self.assertEqual(snake_case__    ,							self.framework_pt       )

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

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






     def   SCREAMING_SNAKE_CASE__  (					self						:						Union[str, Any]       ):





         """simple docstring"""



         __lowerCamelCase            =    MagicMock(return_value=snake_case__       )
         with patch('''transformers.onnx.features.is_tf_available'''    ,							snake_case__       ):
             __lowerCamelCase            =    FeaturesManager.determine_framework(self.test_model       )
             self.assertEqual(snake_case__    ,							self.framework_pt       )

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

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

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


__lowerCamelCase				=			"""Tobias Carryer"""

from time import time






class     UpperCAmelCase						:



   def __init__(self						:   Dict       ,		snake_case__						:   Optional[Any]       ,		snake_case__						:   Optional[Any]       ,		snake_case__						:   str       ,		snake_case__						:   Optional[int]=int(time()					)					)						->      List[Any]:  # noqa: B008


          '''simple docstring'''


          snake_case			:  Dict     							= multiplier
          snake_case			:  Dict     							= increment
          snake_case			:  Union[str, Any]     							= modulo
          snake_case			:  Tuple     							= seed



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


          '''simple docstring'''


          snake_case			:  Optional[int]     							= (self.multiplier * self.seed + self.increment) % self.modulo
          return self.seed


if __name__ == "__main__":
   # Show the LCG in action.
   __lowerCamelCase				=			LinearCongruentialGenerator(1_66_45_25, 10_13_90_42_23, 2 << 31)
   while True:
      print(lcg.next_number())





