



import torch

from accelerate import Accelerator, DistributedType



class     __snake_case						:






							"""simple docstring"""




							def __enter__(	self					:	Any):






									if self.enabled:
											lowerCAmelCase_      :					Union[str, Any]     =			self.model.no_sync()
											self.model_sync_obj.__enter__()

									return self




							def __exit__(	self					:	int    ,    A_					:	List[Any]    ,    A_					:	Dict    ,    A_					:	Union[str, Any]):






									if self.enabled:
											# Average all models on exit
											self._sync_and_avg_model_params()
											self.model_sync_obj.__exit__(A_    ,    A_    ,    A_)




							def __init__(	self					:	int    ,    A_					:	List[str]    ,    A_					:	int    ,    A_					:	str    ,    A_					:	Optional[Any] = True):






									if accelerator.distributed_type not in [
									    DistributedType.NO,
									    DistributedType.MULTI_CPU,
									    DistributedType.MULTI_GPU,
									]:
											raise NotImplementedError('''LocalSGD is supported only for CPUs and GPUs (no DeepSpeed or MegatronLM)''')
									lowerCAmelCase_      :					Optional[int]     =			enabled and accelerator.distributed_type != DistributedType.NO
									lowerCAmelCase_      :					str     =			0
									if self.enabled:
											lowerCAmelCase_      :					str     =			accelerator
											lowerCAmelCase_      :					Tuple     =			model
											lowerCAmelCase_      :					str     =			local_sgd_steps




							def        UpperCAmelCase__      (	self					:	Tuple):
									self.num_steps += 1
									if not self.enabled:
											return

									if self.num_steps % self.local_sgd_steps == 0:
											self._sync_and_avg_model_params()







							def        UpperCAmelCase__      (	self					:	str):
									self.accelerator.wait_for_everyone()
									with self.accelerator.autocast():
											for param in self.model.parameters():
													lowerCAmelCase_      :					Any     =			self.accelerator.reduce(param.data    ,    reduction='''mean''')










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





