



import inspect
import json
import os
import tempfile
import unittest

from transformers.models.speech_to_text_a import SpeechaTextaTokenizer
from transformers.models.speech_to_text_a.tokenization_speech_to_text_a import VOCAB_FILES_NAMES

from ...test_tokenization_common import TokenizerTesterMixin



class     __snake_case						(					UpperCamelCase_						,unittest.TestCase						):
							_a      				=			SpeechaTextaTokenizer
							_a      				=			False




							def        UpperCAmelCase__      (	self					:	Any):
									super().setUp()

									lowerCAmelCase_      :					str     =			'''<s> <pad> </s> <unk> here@@ a couple of@@ words for the he@@ re@@ vocab'''.split(''' ''')
									lowerCAmelCase_      :					List[Any]     =			['''he re</w> 123''', '''here a 1456''']
									lowerCAmelCase_      :					List[str]     =			dict(zip(A_    ,    range(len(A_))))

									lowerCAmelCase_      :					Tuple     =			{'''pad_token''': '''<pad>''', '''unk_token''': '''<unk>''', '''bos_token''': '''<s>''', '''eos_token''': '''</s>'''}

									lowerCAmelCase_      :					List[str]     =			tempfile.mkdtemp()
									lowerCAmelCase_      :					Union[str, Any]     =			os.path.join(self.tmpdirname    ,    VOCAB_FILES_NAMES['''vocab_file'''])
									lowerCAmelCase_      :					Optional[int]     =			os.path.join(self.tmpdirname    ,    VOCAB_FILES_NAMES['''merges_file'''])

									with open(self.vocab_file    ,    '''w'''    ,    encoding='''utf-8''') as fp:
											fp.write(json.dumps(A_) + '''\n''')

									with open(self.merges_file    ,    '''w''') as fp:
											fp.write('''\n'''.join(A_))




							def        UpperCAmelCase__      (	self					:	Any):
									lowerCAmelCase_      :					int     =			list(self.get_tokenizer().get_vocab().keys())

									self.assertEqual(vocab_keys[0]    ,    '''<s>''')
									self.assertEqual(vocab_keys[1]    ,    '''<pad>''')
									self.assertEqual(vocab_keys[-1]    ,    '''vocab''')
									self.assertEqual(len(A_)    ,    1_4)




							def        UpperCAmelCase__      (	self					:	List[Any]):
									self.assertEqual(self.get_tokenizer().vocab_size    ,    1_4)




							def        UpperCAmelCase__      (	self					:	Optional[Any]):
									lowerCAmelCase_      :					Dict     =			SpeechaTextaTokenizer.from_pretrained(self.tmpdirname)

									# make sure @@ is correctly concatenated
									lowerCAmelCase_      :					Union[str, Any]     =			[4, 6, 8, 7, 1_0]  # ["here@@", "couple", "words", "of@@", "the"]
									lowerCAmelCase_      :					int     =			tokenizer.decode(A_)

									self.assertTrue(output_string == '''herecouple words ofthe''')




							def        UpperCAmelCase__      (	self					:	Union[str, Any]):
									lowerCAmelCase_      :					Tuple     =			SpeechaTextaTokenizer.from_pretrained(self.tmpdirname)

									with tempfile.TemporaryDirectory() as tmp_dirname:
											tokenizer.save_pretrained(A_)
											os.remove(os.path.join(A_    ,    '''merges.txt'''))

											# load tokenizer without merges file should not throw an error
											lowerCAmelCase_      :					List[str]     =			SpeechaTextaTokenizer.from_pretrained(A_)

									with tempfile.TemporaryDirectory() as tmp_dirname:
											# save tokenizer and load again
											tokenizer.save_pretrained(A_)
											lowerCAmelCase_      :					List[str]     =			SpeechaTextaTokenizer.from_pretrained(A_)

									self.assertIsNotNone(A_)







							def        UpperCAmelCase__      (	self					:	Optional[int]):
									if not self.test_slow_tokenizer:
											return

									lowerCAmelCase_      :					str     =			inspect.signature(self.tokenizer_class.__init__)
									lowerCAmelCase_      :					List[str]     =			self.get_tokenizer()

									for parameter_name, parameter in signature.parameters.items():
											if parameter.default != inspect.Parameter.empty and parameter_name != "merges_file":
													self.assertIn(A_    ,    tokenizer.init_kwargs)










from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
A__  :  Any       = 9.8_0_6_6_5


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):

		# Ensure valid instance
		if not isinstance(__UpperCamelCase					,(int, float)			):
				raise TypeError('''Invalid velocity. Should be a positive number.'''			)

		if not isinstance(__UpperCamelCase					,(int, float)			):
				raise TypeError('''Invalid angle. Range is 1-90 degrees.'''			)

		# Ensure valid angle
		if angle > 90 or angle < 1:
				raise ValueError('''Invalid angle. Range is 1-90 degrees.'''			)

		# Ensure valid velocity
		if init_velocity < 0:
				raise ValueError('''Invalid velocity. Should be a positive number.'''			)


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Optional[Any]     =			angle_to_radians(2 * angle			)
		return round(init_velocity**2 * sin(__UpperCamelCase			) / g					,2			)


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Any     =			angle_to_radians(__UpperCamelCase			)
		return round(init_velocity**2 * sin(__UpperCamelCase			) ** 2 / (2 * g)					,2			)


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Dict     =			angle_to_radians(__UpperCamelCase			)
		return round(2 * init_velocity * sin(__UpperCamelCase			) / g					,2			)


def       UpperCamelCase(  ):
		lowerCAmelCase_ ,  lowerCAmelCase_      :					Any     =			25, 20
		assert horizontal_distance(__UpperCamelCase					,__UpperCamelCase			) == 4_0.9_7
		assert max_height(__UpperCamelCase					,__UpperCamelCase			) == 3.7_3
		assert total_time(__UpperCamelCase					,__UpperCamelCase			) == 1.7_4


if __name__ == "__main__":
						from doctest import testmod

						testmod()

						# Get input from user
						A__  :  List[Any]       = float(input('''Initial Velocity: ''').strip())

						# Get input from user
						A__  :  Dict       = float(input('''angle: ''').strip())

						# Print results
						print()
						print('''Results: ''')
						print(F'''Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]''')
						print(F'''Maximum Height: {max_height(init_vel, angle)!s} [m]''')
						print(F'''Total Time: {total_time(init_vel, angle)!s} [s]''')





