



'''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 						_UpperCamelCase  (							_SCREAMING_SNAKE_CASE    ):


			'''simple docstring'''

			def UpperCamelCase__					(							self     : Optional[Any]						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		Tuple           =		SMALL_MODEL_IDENTIFIER
					__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		"""pt"""
					__SCREAMING_SNAKE_CASE       :		Dict           =		"""tf"""

			def UpperCamelCase__					(							self     : str							,     lowerCAmelCase__     : Dict						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		str           =		AutoModel.from_pretrained(self.test_model						)
					model_pt.save_pretrained(lowerCAmelCase__						)

			def UpperCamelCase__					(							self     : List[str]							,     lowerCAmelCase__     : List[str]						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		List[Any]           =		TFAutoModel.from_pretrained(self.test_model							,     from_pt=lowerCAmelCase__						)
					model_tf.save_pretrained(lowerCAmelCase__						)

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





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		Tuple           =		"""mock_framework"""

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

					# TensorFlow checkpoint
					with TemporaryDirectory() as local_tf_ckpt:
							self._setup_tf_ckpt(lowerCAmelCase__						)
							__SCREAMING_SNAKE_CASE       :		int           =		FeaturesManager.determine_framework(lowerCAmelCase__							,     lowerCAmelCase__						)
							self.assertEqual(lowerCAmelCase__							,     lowerCAmelCase__						)

			def UpperCamelCase__					(							self     : str						):





					"""simple docstring"""






					with TemporaryDirectory() as local_pt_ckpt:
							self._setup_pt_ckpt(lowerCAmelCase__						)
							__SCREAMING_SNAKE_CASE       :		Dict           =		FeaturesManager.determine_framework(lowerCAmelCase__						)
							self.assertEqual(lowerCAmelCase__							,     self.framework_pt						)

					# TensorFlow checkpoint
					with TemporaryDirectory() as local_tf_ckpt:
							self._setup_tf_ckpt(lowerCAmelCase__						)
							__SCREAMING_SNAKE_CASE       :		str           =		FeaturesManager.determine_framework(lowerCAmelCase__						)
							self.assertEqual(lowerCAmelCase__							,     self.framework_tf						)

					# Invalid local checkpoint
					with TemporaryDirectory() as local_invalid_ckpt:
							with self.assertRaises(lowerCAmelCase__						):
									__SCREAMING_SNAKE_CASE       :		Tuple           =		FeaturesManager.determine_framework(lowerCAmelCase__						)



			def UpperCamelCase__					(							self     : List[Any]						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		MagicMock(return_value=lowerCAmelCase__						)
					with patch("""transformers.onnx.features.is_tf_available"""							,     lowerCAmelCase__						):
							__SCREAMING_SNAKE_CASE       :		List[Any]           =		FeaturesManager.determine_framework(self.test_model						)
							self.assertEqual(lowerCAmelCase__							,     self.framework_pt						)

					# PyTorch not in environment -> use TensorFlow
					__SCREAMING_SNAKE_CASE       :		List[Any]           =		MagicMock(return_value=lowerCAmelCase__						)
					with patch("""transformers.onnx.features.is_torch_available"""							,     lowerCAmelCase__						):
							__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		FeaturesManager.determine_framework(self.test_model						)
							self.assertEqual(lowerCAmelCase__							,     self.framework_tf						)

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

					# Both not in environment -> raise error
					__SCREAMING_SNAKE_CASE       :		Dict           =		MagicMock(return_value=lowerCAmelCase__						)
					__SCREAMING_SNAKE_CASE       :		Tuple           =		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__						):
									__SCREAMING_SNAKE_CASE       :		List[str]           =		FeaturesManager.determine_framework(self.test_model						)



'''simple docstring'''






from math import ceil







def 				UpperCamelCase_			(    A__					:   int = 10_01					):
  '''simple docstring'''





  lowerCAmelCase_			:      List[Any]			=   1

  for i in range(1							,    int(ceil(n / 2.0					)					)					):
    lowerCAmelCase_			:      int			=   2 * i + 1
    lowerCAmelCase_			:      Tuple			=   2 * i
    lowerCAmelCase_			:      Tuple			=   total + 4 * odd**2 - 6 * even

  return total


if __name__ == "__main__":
  import sys

  if len(sys.argv) == 1:
    print(solution())
  else:
    try:
      __A					:  str											=      int(sys.argv[1])
      print(solution(n))
    except ValueError:
      print("Invalid entry - please enter a number")



