





"""simple docstring"""





from typing import List, Optional, Union

import numpy as np

from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
from ....feature_extraction_sequence_utils import SequenceFeatureExtractor
from ....feature_extraction_utils import BatchFeature
from ....file_utils import PaddingStrategy, TensorType
from ....utils import logging


_UpperCamelCase							=      logging.get_logger(__name__)
class 		SCREAMING_SNAKE_CASE_							(    snake_case__   ):
				"""simple docstring"""
				__snake_case   :       Dict	 =		["""input_features""", """attention_mask"""]




				def __init__(     self  :str						,    __lowercase  :Any=80						,    __lowercase  :str=1_6000						,    __lowercase  :int=0.0						,    __lowercase  :Optional[Any]=10						,    __lowercase  :List[Any]=25						,    __lowercase  :str="hamming_window"						,    __lowercase  :Optional[int]=32768.0						,    __lowercase  :str=0.97						,    __lowercase  :Any=1.0						,    __lowercase  :List[str]=True						,    __lowercase  :Union[str, Any]=True						,    __lowercase  :List[Any]=False						,    **__lowercase  :Tuple						,    ):
											super().__init__(feature_size=__lowercase						,    sampling_rate=__lowercase						,    padding_value=__lowercase						,    **__lowercase			)

											__lowerCamelCase      :      List[str]         =feature_size
											__lowerCamelCase      :      Any         =sampling_rate
											__lowerCamelCase      :      Optional[int]         =padding_value
											__lowerCamelCase      :      Optional[int]         =hop_length
											__lowerCamelCase      :      Dict         =win_length
											__lowerCamelCase      :      Dict         =frame_signal_scale
											__lowerCamelCase      :      List[Any]         =preemphasis_coeff
											__lowerCamelCase      :      Optional[int]         =mel_floor
											__lowerCamelCase      :      Optional[int]         =normalize_means
											__lowerCamelCase      :      Dict         =normalize_vars
											__lowerCamelCase      :      Optional[int]         =win_function
											__lowerCamelCase      :      Dict         =return_attention_mask

											__lowerCamelCase      :      str         =win_length * sampling_rate // 1000
											__lowerCamelCase      :      Dict         =hop_length * sampling_rate // 1000

											__lowerCamelCase      :      List[str]         =optimal_fft_length(self.sample_size			)
											__lowerCamelCase      :      Optional[Any]         =(self.n_fft // 2) + 1




				def 					__lowercase  (     self  :Any						,    __lowercase  :np.array			):
											if self.win_function == "hamming_window":
																		__lowerCamelCase      :      str         =window_function(window_length=self.sample_size						,    name=self.win_function						,    periodic=__lowercase			)
											else:
																		__lowerCamelCase      :      Union[str, Any]         =window_function(window_length=self.sample_size						,    name=self.win_function			)

											__lowerCamelCase      :      List[Any]         =mel_filter_bank(
											    num_frequency_bins=self.n_freqs						,    num_mel_filters=self.feature_size						,    min_frequency=0.0						,    max_frequency=self.sampling_rate / 2.0						,    sampling_rate=self.sampling_rate						,    )

											__lowerCamelCase      :      Dict         =spectrogram(
											    one_waveform * self.frame_signal_scale						,    window=__lowercase						,    frame_length=self.sample_size						,    hop_length=self.sample_stride						,    fft_length=self.n_fft						,    center=__lowercase						,    preemphasis=self.preemphasis_coeff						,    mel_filters=__lowercase						,    mel_floor=self.mel_floor						,    log_mel='''log'''						,    )
											return msfc_features.T




				def 					__lowercase  (     self  :Optional[Any]						,    __lowercase  :Any						,    __lowercase  :Any						,    __lowercase  :Any			):
											# make sure we normalize float32 arrays
											if self.normalize_means:
																		__lowerCamelCase      :      str         =x[:input_length].mean(axis=0			)
																		__lowerCamelCase      :      Optional[int]         =np.subtract(__lowercase						,    __lowercase			)
											if self.normalize_vars:
																		__lowerCamelCase      :      int         =x[:input_length].std(axis=0			)
																		__lowerCamelCase      :      Union[str, Any]         =np.divide(__lowercase						,    __lowercase			)

											if input_length < x.shape[0]:
																		__lowerCamelCase      :      List[Any]         =padding_value

											# make sure array is in float32
											__lowerCamelCase      :      List[Any]         =x.astype(np.floataa			)

											return x




				def 					__lowercase  (     self  :Optional[int]						,    __lowercase  :List[np.ndarray]						,    __lowercase  :Optional[np.ndarray] = None			):
											__lowerCamelCase      :      int         =attention_mask.sum(-1			) if attention_mask is not None else [x.shape[0] for x in input_features]
											return [self._normalize_one(__lowercase						,    __lowercase						,    self.padding_value			) for x, n in zip(__lowercase						,    __lowercase			)]




				def __call__(     self  :Dict						,    __lowercase  :Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]]						,    __lowercase  :Union[bool, str, PaddingStrategy] = False						,    __lowercase  :Optional[int] = None						,    __lowercase  :bool = False						,    __lowercase  :Optional[int] = None						,    __lowercase  :Optional[bool] = None						,    __lowercase  :Optional[Union[str, TensorType]] = None						,    __lowercase  :Optional[int] = None						,    **__lowercase  :Dict						,    ):

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

											__lowerCamelCase      :      Tuple         =isinstance(__lowercase						,    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}'			)
											__lowerCamelCase      :      Union[str, Any]         =is_batched_numpy or (
											    isinstance(__lowercase						,    (list, tuple)			) and (isinstance(raw_speech[0]						,    (np.ndarray, tuple, list)			))
											)

											if is_batched:
																		__lowerCamelCase      :      Dict         =[np.asarray(__lowercase						,    dtype=np.floataa			) for speech in raw_speech]
											elif not is_batched and not isinstance(__lowercase						,    np.ndarray			):
																		__lowerCamelCase      :      Optional[int]         =np.asarray(__lowercase						,    dtype=np.floataa			)
											elif isinstance(__lowercase						,    np.ndarray			) and raw_speech.dtype is np.dtype(np.floataa			):
																		__lowerCamelCase      :      List[str]         =raw_speech.astype(np.floataa			)

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

											# extract fbank features
											__lowerCamelCase      :      str         =[self._extract_mfsc_features(__lowercase			) for one_waveform in raw_speech]

											# convert into correct format for padding
											__lowerCamelCase      :      Optional[Any]         =BatchFeature({'''input_features''': features}			)

											__lowerCamelCase      :      List[Any]         =self.pad(
											    __lowercase						,    padding=__lowercase						,    max_length=__lowercase						,    truncation=__lowercase						,    pad_to_multiple_of=__lowercase						,    return_attention_mask=__lowercase						,    **__lowercase						,    )
											# make sure list is in array format
											__lowerCamelCase      :      Optional[int]         =padded_inputs.get('''input_features'''			)
											if isinstance(input_features[0]						,    __lowercase			):
																		__lowerCamelCase      :      Optional[int]         =[np.asarray(__lowercase						,    dtype=np.floataa			) for feature in input_features]

											__lowerCamelCase      :      Union[str, Any]         =padded_inputs.get('''attention_mask'''			)
											if attention_mask is not None:
																		__lowerCamelCase      :      str         =[np.asarray(__lowercase						,    dtype=np.intaa			) for array in attention_mask]

											if self.normalize_means or self.normalize_vars:
																		__lowerCamelCase      :      Optional[Any]         =(
																		    np.array(__lowercase						,    dtype=np.intaa			)
																		    if self._get_padding_strategies(__lowercase						,    max_length=__lowercase			) is not PaddingStrategy.DO_NOT_PAD
																		    and padding
																		    else None
																		)
																		__lowerCamelCase      :      Dict         =self.normalize(
																		    padded_inputs['''input_features''']						,    attention_mask=__lowercase			)

											if return_tensors is not None:
																		__lowerCamelCase      :      int         =padded_inputs.convert_to_tensors(__lowercase			)

											return padded_inputs











"""simple docstring"""





import math
from datetime import datetime, timedelta



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							int   ):


							'''simple docstring'''







							__lowerCamelCase      :      Any         =year % 19
							__lowerCamelCase      :      Optional[Any]         =year % 4
							__lowerCamelCase      :      Tuple         =year % 7
							__lowerCamelCase      :      Optional[int]         =math.floor(year / 100   )
							__lowerCamelCase      :      List[str]         =math.floor((13 + 8 * leap_day_inhibits) / 25   )
							__lowerCamelCase      :      Any         =leap_day_inhibits / 4
							__lowerCamelCase      :      Optional[Any]         =(
							    15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
							) % 30
							__lowerCamelCase      :      Optional[Any]         =(4 + leap_day_inhibits - leap_day_reinstall_number) % 7

							# days to be added to March 21
							__lowerCamelCase      :      Any         =(19 * metonic_cycle + secular_moon_shift) % 30

							# PHM -> Paschal Full Moon
							__lowerCamelCase      :      str         =(
							    2 * julian_leap_year
							    + 4 * non_leap_year
							    + 6 * days_to_add
							    + century_starting_point
							) % 7

							if days_to_add == 29 and days_from_phm_to_sunday == 6:
														return datetime(SCREAMING_SNAKE_CASE    ,						4    ,						19   )
							elif days_to_add == 28 and days_from_phm_to_sunday == 6:
														return datetime(SCREAMING_SNAKE_CASE    ,						4    ,						18   )
							else:
														return datetime(SCREAMING_SNAKE_CASE    ,						3    ,						22   ) + timedelta(
														    days=int(days_to_add + days_from_phm_to_sunday   )   )


if __name__ == "__main__":
							for year in (1994, 2000, 2010, 2021, 2023):
														_UpperCamelCase							=      'will be' if year > datetime.now().year else 'was'
														print(f'''Easter in {year} {tense} {gauss_easter(year)}''')




