code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  from typing import Optional
  
  import torch
  from PIL import Image
  from tqdm.auto import tqdm
  from transformers import CLIPTextModel, CLIPTokenizer
  
  from diffusers import AutoencoderKL, DDIMScheduler, DiffusionPipeline, UNetaDConditionModel
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.utils import (
      deprecate,
  )
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    def __init__(      self:		str				,			UpperCamelCase_:		AutoencoderKL				,			UpperCamelCase_:		CLIPTextModel				,			UpperCamelCase_:		CLIPTokenizer				,			UpperCamelCase_:		UNetaDConditionModel				,			UpperCamelCase_:		DDIMScheduler				,			UpperCamelCase_:		float = 0.93				,			UpperCamelCase_:		bool = True				,			):
       UpperCamelCase_     =mixing_coeff
       UpperCamelCase_     =leapfrog_steps
  
       super().__init__()
       self.register_modules(
           vae=UpperCamelCase_				,			text_encoder=UpperCamelCase_				,			tokenizer=UpperCamelCase_				,			unet=UpperCamelCase_				,			scheduler=UpperCamelCase_				,			)
  
       UpperCamelCase_     =2 ** (len(self.vae.config.block_out_channels					) - 1)
       UpperCamelCase_     =VaeImageProcessor(vae_scale_factor=self.vae_scale_factor					)
    def 					UpperCamelCase__   (      self:		Optional[int]				,			UpperCamelCase_:		str				,			UpperCamelCase_:		Optional[str] = None				,			UpperCamelCase_:		bool = False					):
       UpperCamelCase_     =self.tokenizer(
           UpperCamelCase_				,			padding="max_length"				,			max_length=self.tokenizer.model_max_length				,			truncation=UpperCamelCase_				,			return_tensors="pt"				,			)
  
       UpperCamelCase_     =self.text_encoder(text_inputs.input_ids.to(self.device					)					).last_hidden_state
  
       UpperCamelCase_     =prompt_embeds.to(dtype=self.text_encoder.dtype				,			device=self.device					)
  
       if do_classifier_free_guidance:
          UpperCamelCase_     ="" if negative_prompt is None else negative_prompt
  
          UpperCamelCase_     =self.tokenizer(
              UpperCamelCase_				,			padding="max_length"				,			max_length=self.tokenizer.model_max_length				,			truncation=UpperCamelCase_				,			return_tensors="pt"				,			)
  
          UpperCamelCase_     =self.text_encoder(uncond_input.input_ids.to(self.device					)					).last_hidden_state
  
          UpperCamelCase_     =torch.cat([negative_prompt_embeds, prompt_embeds]					)
  
       return prompt_embeds
    def 					UpperCamelCase__   (      self:		List[Any]				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor					):
       UpperCamelCase_     =self.mixing_coeff * x + (1 - self.mixing_coeff) * y
       UpperCamelCase_     =self.mixing_coeff * y + (1 - self.mixing_coeff) * x
  
       return [x, y]
    def 					UpperCamelCase__   (      self:		List[str]				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor					):
       UpperCamelCase_     =(y - (1 - self.mixing_coeff) * x) / self.mixing_coeff
       UpperCamelCase_     =(x - (1 - self.mixing_coeff) * y) / self.mixing_coeff
  
       return [x, y]
    def 					UpperCamelCase__   (      self:		int				,			UpperCamelCase_:		torch.Tensor					):
       # as self.alphas_cumprod is always in cpu
       UpperCamelCase_     =int(UpperCamelCase_					)
  
       UpperCamelCase_     =self.scheduler.alphas_cumprod[t] if t >= 0 else self.scheduler.final_alpha_cumprod
  
       return alpha_prod, 1 - alpha_prod
    def 					UpperCamelCase__   (      self:		Any				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			):
       UpperCamelCase_     =timestep - self.scheduler.config.num_train_timesteps / self.scheduler.num_inference_steps
  
       UpperCamelCase_    ,							UpperCamelCase_     =self._get_alpha_and_beta(UpperCamelCase_					)
       UpperCamelCase_    ,							UpperCamelCase_     =self._get_alpha_and_beta(UpperCamelCase_					)
  
       UpperCamelCase_     =(alpha_prod_t_prev / alpha_prod_t) ** 0.5
       UpperCamelCase_     =-a_t * (beta_prod_t**0.5) + beta_prod_t_prev**0.5
  
       UpperCamelCase_     =(base - b_t * model_output) / a_t
  
       return model_input, next_model_input.to(base.dtype					)
    def 					UpperCamelCase__   (      self:		Optional[Any]				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			):
       UpperCamelCase_     =timestep - self.scheduler.config.num_train_timesteps / self.scheduler.num_inference_steps
  
       UpperCamelCase_    ,							UpperCamelCase_     =self._get_alpha_and_beta(UpperCamelCase_					)
       UpperCamelCase_    ,							UpperCamelCase_     =self._get_alpha_and_beta(UpperCamelCase_					)
  
       UpperCamelCase_     =(alpha_prod_t_prev / alpha_prod_t) ** 0.5
       UpperCamelCase_     =-a_t * (beta_prod_t**0.5) + beta_prod_t_prev**0.5
       UpperCamelCase_     =a_t * base + b_t * model_output
  
       return model_input, next_model_input.to(base.dtype					)
    @torch.no_grad()
    def 					UpperCamelCase__   (      self:		Tuple				,			UpperCamelCase_:		torch.Tensor					):
       UpperCamelCase_     =1 / self.vae.config.scaling_factor * latents
       UpperCamelCase_     =self.vae.decode(UpperCamelCase_					).sample
       UpperCamelCase_     =(image / 2 + 0.5).clamp(0				,			1					)
       return image
    @torch.no_grad()
    def 					UpperCamelCase__   (      self:		Optional[int]				,			UpperCamelCase_:		Image.Image				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		torch.Tensor				,			UpperCamelCase_:		float				,			UpperCamelCase_:		Optional[torch.Generator] = None				,			):
       UpperCamelCase_     =guidance_scale > 1.0
  
       UpperCamelCase_     =image.to(device=self.device				,			dtype=text_embeds.dtype					)
       UpperCamelCase_     =self.vae.encode(UpperCamelCase_					).latent_dist.sample(UpperCamelCase_					)
  
       UpperCamelCase_     =self.vae.config.scaling_factor * latent
  
       UpperCamelCase_     =[latent.clone(), latent.clone()]
  
       for i, t in tqdm(enumerate(UpperCamelCase_					)				,			total=len(UpperCamelCase_					)					):
          UpperCamelCase_     =self.noise_mixing_layer(x=coupled_latents[0]				,			y=coupled_latents[1]					)
  
          # j - model_input index, k - base index
          for j in range(2					):
             UpperCamelCase_     =j ^ 1
  
             if self.leapfrog_steps:
                if i % 2 == 0:
                   UpperCamelCase_    ,							UpperCamelCase_     =j, k
  
             UpperCamelCase_     =coupled_latents[j]
             UpperCamelCase_     =coupled_latents[k]
  
             UpperCamelCase_     =torch.cat([model_input] * 2					) if do_classifier_free_guidance else model_input
  
             UpperCamelCase_     =self.unet(UpperCamelCase_				,			UpperCamelCase_				,			encoder_hidden_states=UpperCamelCase_					).sample
  
             if do_classifier_free_guidance:
                UpperCamelCase_    ,							UpperCamelCase_     =noise_pred.chunk(2					)
                UpperCamelCase_     =noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
  
             UpperCamelCase_    ,							UpperCamelCase_     =self.noise_step(
                 base=UpperCamelCase_				,			model_input=UpperCamelCase_				,			model_output=UpperCamelCase_				,			timestep=UpperCamelCase_				,			)
  
             UpperCamelCase_     =model_input
  
       return coupled_latents
  
  
  
  
  
    @torch.no_grad()
    def __call__(      self:		List[str]				,			UpperCamelCase_:		str				,			UpperCamelCase_:		str				,			UpperCamelCase_:		Image.Image				,			UpperCamelCase_:		float = 3.0				,			UpperCamelCase_:		int = 50				,			UpperCamelCase_:		float = 0.8				,			UpperCamelCase_:		Optional[str] = None				,			UpperCamelCase_:		Optional[torch.Generator] = None				,			UpperCamelCase_:		Optional[str] = "pil"				,			):
       UpperCamelCase_     =guidance_scale > 1.0
  
       UpperCamelCase_     =self.image_processor.preprocess(UpperCamelCase_					)
  
       UpperCamelCase_     =self._encode_prompt(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					)
       UpperCamelCase_     =self._encode_prompt(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					)
  
       self.scheduler.set_timesteps(UpperCamelCase_				,			self.device					)
  
       UpperCamelCase_     =num_inference_steps - int(num_inference_steps * strength					)
       UpperCamelCase_     =self.scheduler.timesteps[t_limit:]
       UpperCamelCase_     =fwd_timesteps.flip(0					)
  
       UpperCamelCase_     =self.prepare_latents(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					)
  
       for i, t in tqdm(enumerate(UpperCamelCase_					)				,			total=len(UpperCamelCase_					)					):
          # j - model_input index, k - base index
          for k in range(2					):
             UpperCamelCase_     =k ^ 1
  
             if self.leapfrog_steps:
                if i % 2 == 1:
                   UpperCamelCase_    ,							UpperCamelCase_     =j, k
  
             UpperCamelCase_     =coupled_latents[j]
             UpperCamelCase_     =coupled_latents[k]
  
             UpperCamelCase_     =torch.cat([model_input] * 2					) if do_classifier_free_guidance else model_input
  
             UpperCamelCase_     =self.unet(UpperCamelCase_				,			UpperCamelCase_				,			encoder_hidden_states=UpperCamelCase_					).sample
  
             if do_classifier_free_guidance:
                UpperCamelCase_    ,							UpperCamelCase_     =noise_pred.chunk(2					)
                UpperCamelCase_     =noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
  
             UpperCamelCase_    ,							UpperCamelCase_     =self.denoise_step(
                 base=UpperCamelCase_				,			model_input=UpperCamelCase_				,			model_output=UpperCamelCase_				,			timestep=UpperCamelCase_				,			)
  
             UpperCamelCase_     =model_input
  
          UpperCamelCase_     =self.denoise_mixing_layer(x=coupled_latents[0]				,			y=coupled_latents[1]					)
  
       # either one is fine
       UpperCamelCase_     =coupled_latents[0]
  
       if output_type not in ["latent", "pt", "np", "pil"]:
          UpperCamelCase_     =(
              f"""the output_type {output_type} is outdated. Please make sure to set it to one of these instead: """
              "`pil`, `np`, `pt`, `latent`"
          )
          deprecate("Unsupported output_type"				,			"1.0.0"				,			UpperCamelCase_				,			standard_warn=UpperCamelCase_					)
          UpperCamelCase_     ="np"
  
       if output_type == "latent":
          UpperCamelCase_     =final_latent
       else:
          UpperCamelCase_     =self.decode_latents(UpperCamelCase_					)
          UpperCamelCase_     =self.image_processor.postprocess(UpperCamelCase_				,			output_type=UpperCamelCase_					)
  
       return image
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  from math import radians as angle_to_radians
  from math import sin
  
  # Acceleration Constant on Earth (unit m/s^2)
  A_			  =    9.80665
  
  
  
  
  def 						_UpperCamelCase			(  A    ,       A			):
  
     # Ensure valid instance
     if not isinstance(A    ,       (int, float)			):
        raise TypeError("Invalid velocity. Should be a positive number."			)
  
     if not isinstance(A    ,       (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			(  A    ,       A			):
     check_args(A    ,       A			)
     UpperCamelCase_     =angle_to_radians(2 * angle			)
     return round(init_velocity**2 * sin(A			) / g    ,       2			)
  
  
  
  
  def 						_UpperCamelCase			(  A    ,       A			):
     check_args(A    ,       A			)
     UpperCamelCase_     =angle_to_radians(A			)
     return round(init_velocity**2 * sin(A			) ** 2 / (2 * g)    ,       2			)
  
  
  
  
  def 						_UpperCamelCase			(  A    ,       A			):
     check_args(A    ,       A			)
     UpperCamelCase_     =angle_to_radians(A			)
     return round(2 * init_velocity * sin(A			) / g    ,       2			)
  
  
  
  
  def 						_UpperCamelCase			(  ):
     UpperCamelCase_    ,							UpperCamelCase_     =25, 20
     assert horizontal_distance(A    ,       A			) == 40.97
     assert max_height(A    ,       A			) == 3.73
     assert total_time(A    ,       A			) == 1.74
  
  
  if __name__ == "__main__":
      from doctest import testmod
  
      testmod()
  
      # Get input from user
      A_			  =    float(input("Initial Velocity: ").strip())
  
      # Get input from user
      A_			  =    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]''')
  