



'''simple docstring'''







from typing import List, Optional, Union

import numpy as np

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


lowercase__     :  Union[str, Any]    					=			logging.get_logger(__name__)

class       lowerCamelCase_							(	lowerCAmelCase_  ):






   '''simple docstring'''

   A :     Any				=	["input_values", "attention_mask"]


   def __init__(  self     ,						__UpperCamelCase=1     ,						__UpperCamelCase=1_60_00     ,						__UpperCamelCase=0.0     ,						__UpperCamelCase=False     ,						__UpperCamelCase=True     ,						**__UpperCamelCase     ,						):
       super().__init__(feature_size=__UpperCamelCase     ,						sampling_rate=__UpperCamelCase     ,						padding_value=__UpperCamelCase     ,						**__UpperCamelCase )
       UpperCamelCase__      =			return_attention_mask
       UpperCamelCase__      =			do_normalize


   @staticmethod
   def 	_UpperCamelCase       (  __UpperCamelCase     ,						__UpperCamelCase     ,						__UpperCamelCase = 0.0 ):
       if attention_mask is not None:
           UpperCamelCase__      =			np.array(__UpperCamelCase     ,						np.intaa )
           UpperCamelCase__      =			[]

           for vector, length in zip(__UpperCamelCase     ,						attention_mask.sum(-1 ) ):
               UpperCamelCase__      =			(vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1e-7 )
               if length < normed_slice.shape[0]:
                   UpperCamelCase__      =			padding_value

               normed_input_values.append(__UpperCamelCase )
       else:
           UpperCamelCase__      =			[(x - x.mean()) / np.sqrt(x.var() + 1e-7 ) for x in input_values]

       return normed_input_values







   def __call__(  self     ,						__UpperCamelCase     ,						__UpperCamelCase = False     ,						__UpperCamelCase = None     ,						__UpperCamelCase = False     ,						__UpperCamelCase = None     ,						__UpperCamelCase = None     ,						__UpperCamelCase = None     ,						__UpperCamelCase = None     ,						**__UpperCamelCase     ,						):

       if sampling_rate is not None:
           if sampling_rate != self.sampling_rate:
               raise ValueError(
                   f'The model corresponding to this feature extractor: {self} was trained using a sampling rate of'
                   f' {self.sampling_rate}. Please make sure that the provided `raw_speech` input was sampled with'
                   f' {self.sampling_rate} and not {sampling_rate}.' )
       else:
           logger.warning(
               "It is strongly recommended to pass the ``sampling_rate`` argument to this function. "
               "Failing to do so can result in silent errors that might be hard to debug." )

       UpperCamelCase__      =			isinstance(__UpperCamelCase     ,						np.ndarray ) and len(raw_speech.shape ) > 1
       if is_batched_numpy and len(raw_speech.shape ) > 2:
           raise ValueError(f'Only mono-channel audio is supported for input to {self}' )
       UpperCamelCase__      =			is_batched_numpy or (
           isinstance(__UpperCamelCase     ,						(list, tuple) ) and (isinstance(raw_speech[0]     ,						(np.ndarray, tuple, list) ))
       )

       # always return batch
       if not is_batched:
           UpperCamelCase__      =			[raw_speech]

       # convert into correct format for padding
       UpperCamelCase__      =			BatchFeature({"input_values": raw_speech} )

       UpperCamelCase__      =			self.pad(
           __UpperCamelCase     ,						padding=__UpperCamelCase     ,						max_length=__UpperCamelCase     ,						truncation=__UpperCamelCase     ,						pad_to_multiple_of=__UpperCamelCase     ,						return_attention_mask=__UpperCamelCase     ,						)

       # convert input values to correct format
       UpperCamelCase__      =			padded_inputs["input_values"]
       if not isinstance(input_values[0]     ,						np.ndarray ):
           UpperCamelCase__      =			[np.asarray(__UpperCamelCase     ,						dtype=np.floataa ) for array in input_values]
       elif (
           not isinstance(__UpperCamelCase     ,						np.ndarray )
           and isinstance(input_values[0]     ,						np.ndarray )
           and input_values[0].dtype is np.dtype(np.floataa )
       ):
           UpperCamelCase__      =			[array.astype(np.floataa ) for array in input_values]
       elif isinstance(__UpperCamelCase     ,						np.ndarray ) and input_values.dtype is np.dtype(np.floataa ):
           UpperCamelCase__      =			input_values.astype(np.floataa )

       # convert attention_mask to correct format
       UpperCamelCase__      =			padded_inputs.get("attention_mask" )
       if attention_mask is not None:
           UpperCamelCase__      =			[np.asarray(__UpperCamelCase     ,						dtype=np.intaa ) for array in attention_mask]

       # zero-mean and unit-variance normalization
       if self.do_normalize:
           UpperCamelCase__      =			(
               attention_mask
               if self._get_padding_strategies(__UpperCamelCase     ,						max_length=__UpperCamelCase ) is not PaddingStrategy.DO_NOT_PAD
               else None
           )
           UpperCamelCase__      =			self.zero_mean_unit_var_norm(
               padded_inputs["input_values"]     ,						attention_mask=__UpperCamelCase     ,						padding_value=self.padding_value )

       if return_tensors is not None:
           UpperCamelCase__      =			padded_inputs.convert_to_tensors(__UpperCamelCase )

       return padded_inputs









'''simple docstring'''







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
lowercase__     :  str    					=			9.8_0_6_6_5





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):

    # Ensure valid instance
    if not isinstance(lowerCAmelCase_					,  (int, float)	):
        raise TypeError("Invalid velocity. Should be a positive number."	)

    if not isinstance(lowerCAmelCase_					,  (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 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(2 * angle	)
    return round(init_velocity**2 * sin(lowerCAmelCase_	) / g					,  2	)





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(lowerCAmelCase_	)
    return round(init_velocity**2 * sin(lowerCAmelCase_	) ** 2 / (2 * g)					,  2	)





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(lowerCAmelCase_	)
    return round(2 * init_velocity * sin(lowerCAmelCase_	) / g					,  2	)





def 						snake_case__ ():
    UpperCamelCase__    ,  UpperCamelCase__      =			25, 20
    assert horizontal_distance(lowerCAmelCase_					,  lowerCAmelCase_	) == 40.97
    assert max_height(lowerCAmelCase_					,  lowerCAmelCase_	) == 3.73
    assert total_time(lowerCAmelCase_					,  lowerCAmelCase_	) == 1.74


if __name__ == "__main__":
      from doctest import testmod

      testmod()

      # Get input from user
      lowercase__     :  Union[str, Any]    					=			float(input('Initial Velocity: ').strip())

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




