

'''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 					_snake_case		(__SCREAMING_SNAKE_CASE):






			def 		UpperCamelCase__							(  self     ):
				UpperCAmelCase_     :      List[str]						=  SMALL_MODEL_IDENTIFIER
				UpperCAmelCase_     :      List[Any]						=  "pt"
				UpperCAmelCase_     :      List[str]						=  "tf"






			def 		UpperCamelCase__							(  self			,_snake_case     ):
				UpperCAmelCase_     :      str						=  AutoModel.from_pretrained(self.test_model     )
				model_pt.save_pretrained(_snake_case     )






			def 		UpperCamelCase__							(  self			,_snake_case     ):
				UpperCAmelCase_     :      int						=  TFAutoModel.from_pretrained(self.test_model			,from_pt=_snake_case     )
				model_tf.save_pretrained(_snake_case     )






			def 		UpperCamelCase__							(  self     ):
				UpperCAmelCase_     :      List[Any]						=  "mock_framework"

				# Framework provided - return whatever the user provides
				UpperCAmelCase_     :      List[Any]						=  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     )
					UpperCAmelCase_     :      Optional[Any]						=  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     )
					UpperCAmelCase_     :      int						=  FeaturesManager.determine_framework(_snake_case			,_snake_case     )
					self.assertEqual(_snake_case			,_snake_case     )






			def 		UpperCamelCase__							(  self     ):
				# PyTorch checkpoint
				with TemporaryDirectory() as local_pt_ckpt:
					self._setup_pt_ckpt(_snake_case     )
					UpperCAmelCase_     :      List[str]						=  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     )
					UpperCAmelCase_     :      Any						=  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     ):
						UpperCAmelCase_     :      List[Any]						=  FeaturesManager.determine_framework(_snake_case     )






			def 		UpperCamelCase__							(  self     ):
				UpperCAmelCase_     :      Tuple						=  MagicMock(return_value=_snake_case     )
				with patch("transformers.onnx.features.is_tf_available"			,_snake_case     ):
					UpperCAmelCase_     :      Union[str, Any]						=  FeaturesManager.determine_framework(self.test_model     )
					self.assertEqual(_snake_case			,self.framework_pt     )

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

				# Both in environment -> use PyTorch
				UpperCAmelCase_     :      List[Any]						=  MagicMock(return_value=_snake_case     )
				UpperCAmelCase_     :      Union[str, Any]						=  MagicMock(return_value=_snake_case     )
				with patch("transformers.onnx.features.is_tf_available"			,_snake_case     ), patch(
				    "transformers.onnx.features.is_torch_available"			,_snake_case     ):
					UpperCAmelCase_     :      int						=  FeaturesManager.determine_framework(self.test_model     )
					self.assertEqual(_snake_case			,self.framework_pt     )

				# Both not in environment -> raise error
				UpperCAmelCase_     :      Optional[int]						=  MagicMock(return_value=_snake_case     )
				UpperCAmelCase_     :      Any						=  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     ):
						UpperCAmelCase_     :      Dict						=  FeaturesManager.determine_framework(self.test_model     )












def 	UpperCamelCase	(							snake_case__  : float						,snake_case__  : int	):




     '''simple docstring'''






     if digit_amount > 0:
          return round(number - int(snake_case__	)						,snake_case__	)
     return number - int(snake_case__	)


if __name__ == "__main__":
     print(decimal_isolate(1.5_3, 0))
     print(decimal_isolate(3_5.3_4_5, 1))
     print(decimal_isolate(3_5.3_4_5, 2))
     print(decimal_isolate(3_5.3_4_5, 3))
     print(decimal_isolate(-1_4.7_8_9, 3))
     print(decimal_isolate(0, 2))
     print(decimal_isolate(-1_4.1_2_3, 1))
     print(decimal_isolate(-1_4.1_2_3, 2))
     print(decimal_isolate(-1_4.1_2_3, 3))


