





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 	UpperCamelCase_							(  UpperCamelCase__     ):


							def   _snake_case	(				self     :Optional[Any]		) -> Optional[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   SMALL_MODEL_IDENTIFIER
									SCREAMING_SNAKE_CASE__								=   """pt"""
									SCREAMING_SNAKE_CASE__								=   """tf"""


							def   _snake_case	(				self     :List[Any]				,					__A     :Union[str, Any]		) -> List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   AutoModel.from_pretrained(self.test_model		)
									model_pt.save_pretrained(__A		)


							def   _snake_case	(				self     :Optional[int]				,					__A     :Any		) -> List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   TFAutoModel.from_pretrained(self.test_model				,					from_pt=__A		)
									model_tf.save_pretrained(__A		)


							def   _snake_case	(				self     :Union[str, Any]		) -> List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   """mock_framework"""

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

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

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


							def   _snake_case	(				self     :Union[str, Any]		) -> str:



									"""simple docstring"""



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

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

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


							def   _snake_case	(				self     :Tuple		) -> List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MagicMock(return_value=__A		)
									with patch("""transformers.onnx.features.is_tf_available"""				,					__A		):
											SCREAMING_SNAKE_CASE__								=   FeaturesManager.determine_framework(self.test_model		)
											self.assertEqual(__A				,					self.framework_pt		)

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

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

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

from math import factorial, radians







def __UpperCamelCase( _A       :					float	,      _A       :					int = 18	,      _A       :					int = 10     ):
   '''simple docstring'''
   UpperCAmelCase__				:					int 					=	angle_in_degrees - ((angle_in_degrees // 3_6_0.0) * 3_6_0.0)

   # Converting from degrees to radians
   UpperCAmelCase__				:					Dict 					=	radians(_A     )

   UpperCAmelCase__				:					Union[str, Any] 					=	angle_in_radians
   UpperCAmelCase__				:					List[str] 					=	3
   UpperCAmelCase__				:					int 					=	-1

   for _ in range(_A     ):
      result += (b * (angle_in_radians**a)) / factorial(_A     )

      UpperCAmelCase__				:					List[str] 					=	-b  # One positive term and the next will be negative and so on...
      a += 2  # Increased by 2 for every term.

   return round(_A	,      _A     )


if __name__ == "__main__":
  __import__('doctest').testmod()




