



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



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



     """simple docstring"""
     _snake_case   	=      SMALL_MODEL_IDENTIFIER
     _snake_case   	=      '''pt'''
     _snake_case   	=      '''tf'''



   def    __UpperCAmelCase    (       self    :	int							,       __lowerCamelCase    :	Any				):



     """simple docstring"""
     _snake_case   	=      AutoModel.from_pretrained(self.test_model				)
     model_pt.save_pretrained(__lowerCamelCase				)



   def    __UpperCAmelCase    (       self    :	List[str]							,       __lowerCamelCase    :	int				):



     """simple docstring"""
     _snake_case   	=      TFAutoModel.from_pretrained(self.test_model							,       from_pt=__lowerCamelCase				)
     model_tf.save_pretrained(__lowerCamelCase				)



   def    __UpperCAmelCase    (       self    :	Optional[Any]				):



     """simple docstring"""
     _snake_case   	=      '''mock_framework'''

     # Framework provided - return whatever the user provides
     _snake_case   	=      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				)
       _snake_case   	=      FeaturesManager.determine_framework(__lowerCamelCase							,       __lowerCamelCase				)
       self.assertEqual(__lowerCamelCase							,       __lowerCamelCase				)

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



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



     """simple docstring"""
     # PyTorch checkpoint
     with TemporaryDirectory() as local_pt_ckpt:
       self._setup_pt_ckpt(__lowerCamelCase				)
       _snake_case   	=      FeaturesManager.determine_framework(__lowerCamelCase				)
       self.assertEqual(__lowerCamelCase							,       self.framework_pt				)

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

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





   def    __UpperCAmelCase    (       self    :	int				):



     """simple docstring"""
     _snake_case   	=      MagicMock(return_value=__lowerCamelCase				)
     with patch('''transformers.onnx.features.is_tf_available'''							,       __lowerCamelCase				):
       _snake_case   	=      FeaturesManager.determine_framework(self.test_model				)
       self.assertEqual(__lowerCamelCase							,       self.framework_pt				)

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

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

     # Both not in environment -> raise error
     _snake_case   	=      MagicMock(return_value=__lowerCamelCase				)
     _snake_case   	=      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				):
         _snake_case   	=      FeaturesManager.determine_framework(self.test_model				)










"""simple docstring"""






from math import sqrt




def 			snake_case		(		lowerCAmelCase_ = 1000000	)						->				int:
  _snake_case   	=      0
  _snake_case   	=      0
  _snake_case   	=      42

  while num_cuboids <= limit:
    max_cuboid_size += 1
    for sum_shortest_sides in range(2  ,						2 * max_cuboid_size + 1	):
      if sqrt(sum_shortest_sides**2 + max_cuboid_size**2	).is_integer():
        num_cuboids += (
            min(lowerCAmelCase_  ,						sum_shortest_sides // 2	)
            - max(1  ,						sum_shortest_sides - max_cuboid_size	)
            + 1
        )

  return max_cuboid_size


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





