



"""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  __lowercase  (       _UpperCAmelCase):







						"""simple docstring"""







						def     __UpperCamelCase				(self							):
											snake_case_       :		int			       =       SMALL_MODEL_IDENTIFIER
											snake_case_       :		str			       =       """pt"""
											snake_case_       :		Union[str, Any]			       =       """tf"""







						def     __UpperCamelCase				(self ,		lowercase__							):
											snake_case_       :		List[Any]			       =       AutoModel.from_pretrained(self.test_model							)
											model_pt.save_pretrained(SCREAMING_SNAKE_CASE_							)







						def     __UpperCamelCase				(self ,		lowercase__							):
											snake_case_       :		Optional[Any]			       =       TFAutoModel.from_pretrained(self.test_model ,		from_pt=SCREAMING_SNAKE_CASE_							)
											model_tf.save_pretrained(SCREAMING_SNAKE_CASE_							)







						def     __UpperCamelCase				(self							):
											snake_case_       :		int			       =       """mock_framework"""

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







						def     __UpperCamelCase				(self							):
											# PyTorch checkpoint
											with TemporaryDirectory() as local_pt_ckpt:
																self._setup_pt_ckpt(SCREAMING_SNAKE_CASE_							)
																snake_case_       :		Any			       =       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_							)
																snake_case_       :		Any			       =       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_							):
																					snake_case_       :		Any			       =       FeaturesManager.determine_framework(SCREAMING_SNAKE_CASE_							)







						def     __UpperCamelCase				(self							):
											snake_case_       :		Tuple			       =       MagicMock(return_value=SCREAMING_SNAKE_CASE_							)
											with patch("""transformers.onnx.features.is_tf_available""" ,		SCREAMING_SNAKE_CASE_							):
																snake_case_       :		Any			       =       FeaturesManager.determine_framework(self.test_model							)
																self.assertEqual(SCREAMING_SNAKE_CASE_ ,		self.framework_pt							)

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

											# Both in environment -> use PyTorch
											snake_case_       :		str			       =       MagicMock(return_value=SCREAMING_SNAKE_CASE_							)
											snake_case_       :		str			       =       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_							):
																snake_case_       :		Tuple			       =       FeaturesManager.determine_framework(self.test_model							)
																self.assertEqual(SCREAMING_SNAKE_CASE_ ,		self.framework_pt							)

											# Both not in environment -> raise error
											snake_case_       :		Any			       =       MagicMock(return_value=SCREAMING_SNAKE_CASE_							)
											snake_case_       :		Any			       =       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_							):
																					snake_case_       :		Optional[Any]			       =       FeaturesManager.determine_framework(self.test_model							)






import os

# Precomputes a list of the 100 first triangular numbers
__a         =   [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)]




def 							a		(				):


				'''simple docstring'''
				lowercase_	    =   os.path.dirname(os.path.realpath(snake_case__   )   )
				lowercase_	    =   os.path.join(snake_case__		,  '''words.txt'''   )

				lowercase_	    =   ''''''
				with open(snake_case__   ) as f:
								lowercase_	    =   f.readline()

				lowercase_	    =   [word.strip('''"'''   ) for word in words.strip('''\r\n'''   ).split(''','''   )]
				lowercase_	    =   [
				    word
				    for word in [sum(ord(snake_case__   ) - 64 for x in word   ) for word in words]
				    if word in TRIANGULAR_NUMBERS
				]
				return len(snake_case__   )


if __name__ == "__main__":
						print(solution())




