


'''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):







    """simple docstring"""



    def __lowercase   (   self    :  Optional[Any]		)   ->  Tuple:
      lowerCAmelCase_			:      Tuple			=   SMALL_MODEL_IDENTIFIER
      lowerCAmelCase_			:      Union[str, Any]			=   """pt"""
      lowerCAmelCase_			:      Dict			=   """tf"""

    def __lowercase   (   self    :  str    ,						lowerCamelCase    :  Dict		)   ->  Union[str, Any]:
      lowerCAmelCase_			:      str			=   AutoModel.from_pretrained(self.test_model		)
      model_pt.save_pretrained(lowerCamelCase		)

    def __lowercase   (   self    :  List[str]    ,						lowerCamelCase    :  List[str]		)   ->  int:
      lowerCAmelCase_			:      List[Any]			=   TFAutoModel.from_pretrained(self.test_model    ,						from_pt=lowerCamelCase		)
      model_tf.save_pretrained(lowerCamelCase		)

    def __lowercase   (   self    :  Union[str, Any]		)   ->  int:
      lowerCAmelCase_			:      Tuple			=   """mock_framework"""

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

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

    def __lowercase   (   self    :  str		)   ->  str:
      # PyTorch checkpoint
      with TemporaryDirectory() as local_pt_ckpt:
        self._setup_pt_ckpt(lowerCamelCase		)
        lowerCAmelCase_			:      Dict			=   FeaturesManager.determine_framework(lowerCamelCase		)
        self.assertEqual(lowerCamelCase    ,						self.framework_pt		)

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

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





    def __lowercase   (   self    :  List[Any]		)   ->  int:
      lowerCAmelCase_			:      Optional[Any]			=   MagicMock(return_value=lowerCamelCase		)
      with patch("""transformers.onnx.features.is_tf_available"""    ,						lowerCamelCase		):
        lowerCAmelCase_			:      List[Any]			=   FeaturesManager.determine_framework(self.test_model		)
        self.assertEqual(lowerCamelCase    ,						self.framework_pt		)

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

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

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







'''simple docstring'''






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





  lowerCAmelCase_			:      Optional[Any]			=   3
  lowerCAmelCase_			:      Dict			=   0
  while a < n:
    if a % 3 == 0 or a % 5 == 0:
      result += a
    elif a % 15 == 0:
      result -= a
    a += 1
  return result


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



