code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  
  import torch
  import torch.nn as nn
  
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..utils import BaseOutput
  from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
  from .modeling_utils import ModelMixin
  from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block
  @dataclass
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    torch.FloatTensor
  
  
  
  
  class 						__lowerCAmelCase   (			UpperCAmelCase       ,   UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    @register_to_config
    def __init__(      self:		Dict				,			UpperCamelCase_:		Optional[Union[int, Tuple[int, int]]] = None				,			UpperCamelCase_:		int = 3				,			UpperCamelCase_:		int = 3				,			UpperCamelCase_:		bool = False				,			UpperCamelCase_:		str = "positional"				,			UpperCamelCase_:		int = 0				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		Tuple[str] = ("DownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D")				,			UpperCamelCase_:		Tuple[str] = ("AttnUpBlock2D", "AttnUpBlock2D", "AttnUpBlock2D", "UpBlock2D")				,			UpperCamelCase_:		Tuple[int] = (224, 448, 672, 896)				,			UpperCamelCase_:		int = 2				,			UpperCamelCase_:		float = 1				,			UpperCamelCase_:		int = 1				,			UpperCamelCase_:		str = "conv"				,			UpperCamelCase_:		str = "conv"				,			UpperCamelCase_:		str = "silu"				,			UpperCamelCase_:		Optional[int] = 8				,			UpperCamelCase_:		int = 32				,			UpperCamelCase_:		float = 1e-5				,			UpperCamelCase_:		str = "default"				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		Optional[str] = None				,			UpperCamelCase_:		Optional[int] = None				,			):
       super().__init__()
  
       UpperCamelCase_     =sample_size
       UpperCamelCase_     =block_out_channels[0] * 4
  
       # Check inputs
       if len(UpperCamelCase_					) != len(UpperCamelCase_					):
          raise ValueError(
              f"""Must provide the same number of `down_block_types` as `up_block_types`. `down_block_types`: {down_block_types}. `up_block_types`: {up_block_types}."""					)
  
       if len(UpperCamelCase_					) != len(UpperCamelCase_					):
          raise ValueError(
              f"""Must provide the same number of `block_out_channels` as `down_block_types`. `block_out_channels`: {block_out_channels}. `down_block_types`: {down_block_types}."""					)
  
       # input
       UpperCamelCase_     =nn.Convad(UpperCamelCase_				,			block_out_channels[0]				,			kernel_size=3				,			padding=(1, 1)					)
  
       # time
       if time_embedding_type == "fourier":
          UpperCamelCase_     =GaussianFourierProjection(embedding_size=block_out_channels[0]				,			scale=16					)
          UpperCamelCase_     =2 * block_out_channels[0]
       elif time_embedding_type == "positional":
          UpperCamelCase_     =Timesteps(block_out_channels[0]				,			UpperCamelCase_				,			UpperCamelCase_					)
          UpperCamelCase_     =block_out_channels[0]
  
       UpperCamelCase_     =TimestepEmbedding(UpperCamelCase_				,			UpperCamelCase_					)
  
       # class embedding
       if class_embed_type is None and num_class_embeds is not None:
          UpperCamelCase_     =nn.Embedding(UpperCamelCase_				,			UpperCamelCase_					)
       elif class_embed_type == "timestep":
          UpperCamelCase_     =TimestepEmbedding(UpperCamelCase_				,			UpperCamelCase_					)
       elif class_embed_type == "identity":
          UpperCamelCase_     =nn.Identity(UpperCamelCase_				,			UpperCamelCase_					)
       else:
          UpperCamelCase_     =None
  
       UpperCamelCase_     =nn.ModuleList([]					)
       UpperCamelCase_     =None
       UpperCamelCase_     =nn.ModuleList([]					)
  
       # down
       UpperCamelCase_     =block_out_channels[0]
       for i, down_block_type in enumerate(UpperCamelCase_					):
          UpperCamelCase_     =output_channel
          UpperCamelCase_     =block_out_channels[i]
          UpperCamelCase_     =i == len(UpperCamelCase_					) - 1
  
          UpperCamelCase_     =get_down_block(
              UpperCamelCase_				,			num_layers=UpperCamelCase_				,			in_channels=UpperCamelCase_				,			out_channels=UpperCamelCase_				,			temb_channels=UpperCamelCase_				,			add_downsample=not is_final_block				,			resnet_eps=UpperCamelCase_				,			resnet_act_fn=UpperCamelCase_				,			resnet_groups=UpperCamelCase_				,			attention_head_dim=attention_head_dim if attention_head_dim is not None else output_channel				,			downsample_padding=UpperCamelCase_				,			resnet_time_scale_shift=UpperCamelCase_				,			downsample_type=UpperCamelCase_				,			)
          self.down_blocks.append(UpperCamelCase_					)
  
       # mid
       UpperCamelCase_     =UNetMidBlockaD(
           in_channels=block_out_channels[-1]				,			temb_channels=UpperCamelCase_				,			resnet_eps=UpperCamelCase_				,			resnet_act_fn=UpperCamelCase_				,			output_scale_factor=UpperCamelCase_				,			resnet_time_scale_shift=UpperCamelCase_				,			attention_head_dim=attention_head_dim if attention_head_dim is not None else block_out_channels[-1]				,			resnet_groups=UpperCamelCase_				,			add_attention=UpperCamelCase_				,			)
  
       # up
       UpperCamelCase_     =list(reversed(UpperCamelCase_					)					)
       UpperCamelCase_     =reversed_block_out_channels[0]
       for i, up_block_type in enumerate(UpperCamelCase_					):
          UpperCamelCase_     =output_channel
          UpperCamelCase_     =reversed_block_out_channels[i]
          UpperCamelCase_     =reversed_block_out_channels[min(i + 1				,			len(UpperCamelCase_					) - 1					)]
  
          UpperCamelCase_     =i == len(UpperCamelCase_					) - 1
  
          UpperCamelCase_     =get_up_block(
              UpperCamelCase_				,			num_layers=layers_per_block + 1				,			in_channels=UpperCamelCase_				,			out_channels=UpperCamelCase_				,			prev_output_channel=UpperCamelCase_				,			temb_channels=UpperCamelCase_				,			add_upsample=not is_final_block				,			resnet_eps=UpperCamelCase_				,			resnet_act_fn=UpperCamelCase_				,			resnet_groups=UpperCamelCase_				,			attention_head_dim=attention_head_dim if attention_head_dim is not None else output_channel				,			resnet_time_scale_shift=UpperCamelCase_				,			upsample_type=UpperCamelCase_				,			)
          self.up_blocks.append(UpperCamelCase_					)
          UpperCamelCase_     =output_channel
  
       # out
       UpperCamelCase_     =norm_num_groups if norm_num_groups is not None else min(block_out_channels[0] // 4				,			32					)
       UpperCamelCase_     =nn.GroupNorm(num_channels=block_out_channels[0]				,			num_groups=UpperCamelCase_				,			eps=UpperCamelCase_					)
       UpperCamelCase_     =nn.SiLU()
       UpperCamelCase_     =nn.Convad(block_out_channels[0]				,			UpperCamelCase_				,			kernel_size=3				,			padding=1					)
  
  
  
  
  
    def 					UpperCamelCase__   (      self:		Dict				,			UpperCamelCase_:		torch.FloatTensor				,			UpperCamelCase_:		Union[torch.Tensor, float, int]				,			UpperCamelCase_:		Optional[torch.Tensor] = None				,			UpperCamelCase_:		bool = True				,			):
       # 0. center input if necessary
       if self.config.center_input_sample:
          UpperCamelCase_     =2 * sample - 1.0
  
       # 1. time
       UpperCamelCase_     =timestep
       if not torch.is_tensor(UpperCamelCase_					):
          UpperCamelCase_     =torch.tensor([timesteps]				,			dtype=torch.long				,			device=sample.device					)
       elif torch.is_tensor(UpperCamelCase_					) and len(timesteps.shape					) == 0:
          UpperCamelCase_     =timesteps[None].to(sample.device					)
  
       # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
       UpperCamelCase_     =timesteps * torch.ones(sample.shape[0]				,			dtype=timesteps.dtype				,			device=timesteps.device					)
  
       UpperCamelCase_     =self.time_proj(UpperCamelCase_					)
  
       # timesteps does not contain any weights and will always return f32 tensors
       # but time_embedding might actually be running in fp16. so we need to cast here.
       # there might be better ways to encapsulate this.
       UpperCamelCase_     =t_emb.to(dtype=self.dtype					)
       UpperCamelCase_     =self.time_embedding(UpperCamelCase_					)
  
       if self.class_embedding is not None:
          if class_labels is None:
             raise ValueError("class_labels should be provided when doing class conditioning"					)
  
          if self.config.class_embed_type == "timestep":
             UpperCamelCase_     =self.time_proj(UpperCamelCase_					)
  
          UpperCamelCase_     =self.class_embedding(UpperCamelCase_					).to(dtype=self.dtype					)
          UpperCamelCase_     =emb + class_emb
  
       # 2. pre-process
       UpperCamelCase_     =sample
       UpperCamelCase_     =self.conv_in(UpperCamelCase_					)
  
       # 3. down
       UpperCamelCase_     =(sample,)
       for downsample_block in self.down_blocks:
          if hasattr(UpperCamelCase_				,			"skip_conv"					):
             UpperCamelCase_    ,							UpperCamelCase_    ,							UpperCamelCase_     =downsample_block(
                 hidden_states=UpperCamelCase_				,			temb=UpperCamelCase_				,			skip_sample=UpperCamelCase_					)
          else:
             UpperCamelCase_    ,							UpperCamelCase_     =downsample_block(hidden_states=UpperCamelCase_				,			temb=UpperCamelCase_					)
  
          down_block_res_samples += res_samples
  
       # 4. mid
       UpperCamelCase_     =self.mid_block(UpperCamelCase_				,			UpperCamelCase_					)
  
       # 5. up
       UpperCamelCase_     =None
       for upsample_block in self.up_blocks:
          UpperCamelCase_     =down_block_res_samples[-len(upsample_block.resnets					) :]
          UpperCamelCase_     =down_block_res_samples[: -len(upsample_block.resnets					)]
  
          if hasattr(UpperCamelCase_				,			"skip_conv"					):
             UpperCamelCase_    ,							UpperCamelCase_     =upsample_block(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					)
          else:
             UpperCamelCase_     =upsample_block(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					)
  
          # 6. post-process
       UpperCamelCase_     =self.conv_norm_out(UpperCamelCase_					)
       UpperCamelCase_     =self.conv_act(UpperCamelCase_					)
       UpperCamelCase_     =self.conv_out(UpperCamelCase_					)
  
       if skip_sample is not None:
          sample += skip_sample
  
       if self.config.time_embedding_type == "fourier":
          UpperCamelCase_     =timesteps.reshape((sample.shape[0], *([1] * len(sample.shape[1:]					)))					)
          UpperCamelCase_     =sample / timesteps
  
       if not return_dict:
          return (sample,)
  
       return UNetaDOutput(sample=UpperCamelCase_					)
  
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]''')
  