






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

  def 						A__		(   self   )						->   List[str]:



        """simple docstring"""






        UpperCamelCase       						=      SMALL_MODEL_IDENTIFIER
        UpperCamelCase       						=      '''pt'''
        UpperCamelCase       						=      '''tf'''

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



        """simple docstring"""






        UpperCamelCase       						=      AutoModel.from_pretrained(self.test_model   )
        model_pt.save_pretrained(_SCREAMING_SNAKE_CASE   )

  def 						A__		(   self    ,	_SCREAMING_SNAKE_CASE   )						->   Dict:



        """simple docstring"""






        UpperCamelCase       						=      TFAutoModel.from_pretrained(self.test_model    ,	from_pt=_SCREAMING_SNAKE_CASE   )
        model_tf.save_pretrained(_SCREAMING_SNAKE_CASE   )

  def 						A__		(   self   )						->   Dict:



        """simple docstring"""






        UpperCamelCase       						=      '''mock_framework'''

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

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

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

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



        """simple docstring"""






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

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

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


  def 						A__		(   self   )						->   str:



        """simple docstring"""






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

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

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

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








'''simple docstring'''

def 					lowercase__				(   __UpperCamelCase	,		__UpperCamelCase					)->				str:
      if not isinstance(__UpperCamelCase	,		__UpperCamelCase					):
            raise ValueError("""iterations must be defined as integers"""					)
      if not isinstance(__UpperCamelCase	,		__UpperCamelCase					) or not number >= 1:
            raise ValueError(
                """starting number must be
                         and integer and be more than 0"""					)
      if not iterations >= 1:
            raise ValueError("""Iterations must be done more than 0 times to play FizzBuzz"""					)

      UpperCamelCase       						=      """"""
      while number <= iterations:
            if number % 3 == 0:
                  out += "Fizz"
            if number % 5 == 0:
                  out += "Buzz"
            if 0 not in (number % 3, number % 5):
                  out += str(__UpperCamelCase					)

            # print(out)
            number += 1
            out += " "
      return out


if __name__ == "__main__":
     import doctest

     doctest.testmod()
