



from typing import List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
						import torch

A__  :  List[Any]       = logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
						from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):


						def       UpperCamelCase(  cls							:		Optional[int]			):
								return cls


def       UpperCamelCase(  __UpperCamelCase							:		Union[Tuple, List]					,__UpperCamelCase							:		Optional[Union[List["torch.Generator"], "torch.Generator"]] = None					,__UpperCamelCase							:		Optional["torch.device"] = None					,__UpperCamelCase							:		Optional["torch.dtype"] = None					,__UpperCamelCase							:		Optional["torch.layout"] = None					,):
		lowerCAmelCase_      :					Optional[int]     =			device
		lowerCAmelCase_      :					Optional[int]     =			shape[0]

		lowerCAmelCase_      :					Dict     =			layout or torch.strided
		lowerCAmelCase_      :					Optional[int]     =			device or torch.device('''cpu'''			)

		if generator is not None:
				lowerCAmelCase_      :					Tuple     =			generator.device.type if not isinstance(__UpperCamelCase					,__UpperCamelCase			) else generator[0].device.type
				if gen_device_type != device.type and gen_device_type == "cpu":
						lowerCAmelCase_      :					int     =			'''cpu'''
						if device != "mps":
								logger.info(
								    f"""The passed generator was created on 'cpu' even though a tensor on {device} was expected."""
								    f""" Tensors will be created on 'cpu' and then moved to {device}. Note that one can probably"""
								    f""" slighly speed up this function by passing a generator that was created on the {device} device."""			)
				elif gen_device_type != device.type and gen_device_type == "cuda":
						raise ValueError(f"""Cannot generate a {device} tensor from a generator of type {gen_device_type}."""			)

		if isinstance(__UpperCamelCase					,__UpperCamelCase			):
				lowerCAmelCase_      :					Tuple     =			(1,) + shape[1:]
				lowerCAmelCase_      :					List[Any]     =			[
				    torch.randn(__UpperCamelCase					,generator=generator[i]					,device=__UpperCamelCase					,dtype=__UpperCamelCase					,layout=__UpperCamelCase			)
				    for i in range(__UpperCamelCase			)
				]
				lowerCAmelCase_      :					Any     =			torch.cat(__UpperCamelCase					,dim=0			).to(__UpperCamelCase			)
		else:
				lowerCAmelCase_      :					Any     =			torch.randn(__UpperCamelCase					,generator=__UpperCamelCase					,device=__UpperCamelCase					,dtype=__UpperCamelCase					,layout=__UpperCamelCase			).to(__UpperCamelCase			)

		return latents





def       UpperCamelCase(  __UpperCamelCase							:		Optional[Any]			):
		if is_torch_version('''<'''					,'''2.0.0'''			) or not hasattr(__UpperCamelCase					,'''_dynamo'''			):
				return False
		return isinstance(__UpperCamelCase					,torch._dynamo.eval_frame.OptimizedModule			)










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





