






# limitations under the License.


from typing import Optional, Tuple, Union

import torch

from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput

class      UpperCamelCase_							(				UpperCamelCase       ):




						def __init__(    self		,	lowercase		,	lowercase       )			->						Optional[int]:
													super().__init__()
													self.register_modules(unet=lowercase		,	scheduler=lowercase       )







						@torch.no_grad()
						def __call__(    self		,	lowercase = 1		,	lowercase = None		,	lowercase = 50		,	lowercase = "pil"		,	lowercase = True		,	**lowercase		,	)			->						Union[ImagePipelineOutput, Tuple]:
													_a  :    str			=						torch.randn(
													    (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)		,	generator=lowercase		,	)
													_a  :    List[Any]			=						image.to(self.device       )

													# set step values
													self.scheduler.set_timesteps(lowercase       )

													for t in self.progress_bar(self.scheduler.timesteps       ):
																				# 1. predict noise model_output
																				_a  :    List[Any]			=						self.unet(lowercase		,	lowercase       ).sample

																				# 2. predict previous mean of image x_t-1 and add variance depending on eta
																				# eta corresponds to η in paper and should be between [0, 1]
																				# do x_t -> x_t-1
																				_a  :    Optional[int]			=						self.scheduler.step(lowercase		,	lowercase		,	lowercase       ).prev_sample

													_a  :    Dict			=						(image / 2 + 0.5).clamp(0		,	1       )
													_a  :    Dict			=						image.cpu().permute(0		,	2		,	3		,	1       ).numpy()
													if output_type == "pil":
																				_a  :    Optional[Any]			=						self.numpy_to_pil(lowercase       )

													if not return_dict:
																				return (image,), "This is a local test"

													return ImagePipelineOutput(images=lowercase       ), "This is a local test"







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__lowerCamelCase						= 9.8_06_65






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		None:







							"""simple docstring"""





							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    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    Dict			=						angle_to_radians(2 * angle     )
							return round(init_velocity**2 * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    Union[str, Any]			=						angle_to_radians(UpperCAmelCase     )
							return round(init_velocity**2 * sin(UpperCAmelCase     ) ** 2 / (2 * g)    ,	2     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    str			=						angle_to_radians(UpperCAmelCase     )
							return round(2 * init_velocity * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   )     ->		None:







							"""simple docstring"""





							_a		,					_a  :    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
						__lowerCamelCase						= float(input('Initial Velocity: ').strip())

						# Get input from user
						__lowerCamelCase						= 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]''')