






from math import ceil
from typing import List, Optional, Union

import numpy as np

from ...audio_utils import mel_filter_bank, spectrogram, window_function
from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor
from ...utils import TensorType, logging


lowerCamelCase     :							List[Any]    =logging.get_logger(__name__)





class       __a  (   A__	):
 _lowerCAmelCase	:	int				=			['''audio_values''', '''audio_mask''']







 def __init__(		self :       Union[str, Any]							,       SCREAMING_SNAKE_CASE :       Optional[Any]=20_48							,       SCREAMING_SNAKE_CASE :       str=1							,       SCREAMING_SNAKE_CASE :       List[str]=[16, 16]							,       SCREAMING_SNAKE_CASE :       List[str]=1_28							,       SCREAMING_SNAKE_CASE :       Dict=4_41_00							,       SCREAMING_SNAKE_CASE :       List[str]=86							,       SCREAMING_SNAKE_CASE :       int=20_48							,       SCREAMING_SNAKE_CASE :       List[Any]=0.0							,       **SCREAMING_SNAKE_CASE :       List[Any]							,       ):


      '''simple docstring'''






      super().__init__(
          feature_size=SCREAMING_SNAKE_CASE							,       sampling_rate=SCREAMING_SNAKE_CASE							,       padding_value=SCREAMING_SNAKE_CASE							,       **SCREAMING_SNAKE_CASE							,       )

      UpperCamelCase__      :       Tuple	    =  spectrogram_length
      UpperCamelCase__      :       List[str]	    =  num_channels
      UpperCamelCase__      :       Optional[int]	    =  patch_size
      UpperCamelCase__      :       str	    =  feature_size // self.patch_size[1]
      UpperCamelCase__      :       str	    =  n_fft
      UpperCamelCase__      :       Tuple	    =  sampling_rate // hop_length_to_sampling_rate
      UpperCamelCase__      :       Optional[Any]	    =  sampling_rate
      UpperCamelCase__      :       List[Any]	    =  padding_value
      UpperCamelCase__      :       Any	    =  mel_filter_bank(
          num_frequency_bins=1 + n_fft // 2							,       num_mel_filters=SCREAMING_SNAKE_CASE							,       min_frequency=0.0							,       max_frequency=2_2_0_5_0.0							,       sampling_rate=SCREAMING_SNAKE_CASE							,       norm="slaney"							,       mel_scale="slaney"							,       ).T







 def  __lowercase (		self :       Tuple							,       SCREAMING_SNAKE_CASE :       np.array						):


      '''simple docstring'''






      UpperCamelCase__      :       int	    =  spectrogram(
          SCREAMING_SNAKE_CASE							,       window_function(self.n_fft							,       "hann"						)							,       frame_length=self.n_fft							,       hop_length=self.hop_length							,       power=2.0							,       mel_filters=self.mel_filters.T							,       log_mel="dB"							,       db_range=8_0.0							,       )
      UpperCamelCase__      :       Optional[int]	    =  log_spec[:, :-1]
      UpperCamelCase__      :       Optional[int]	    =  log_spec - 2_0.0
      UpperCamelCase__      :       str	    =  np.clip(log_spec / 4_0.0							,       -2.0							,       0.0						) + 1.0
      return log_spec







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


      '''simple docstring'''






      if sampling_rate is not None:
           if sampling_rate != self.sampling_rate:
                raise ValueError(
                    "This feature extractor is set to support sampling rate"
                    F' of {self.sampling_rate}. Please make sure that the provided `raw_speech` input was sampled'
                    F' with {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__      :       Any	    =  isinstance(SCREAMING_SNAKE_CASE							,       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__      :       Optional[int]	    =  is_batched_numpy or (
          isinstance(SCREAMING_SNAKE_CASE							,       (list, tuple)						) and (isinstance(raw_speech[0]							,       (np.ndarray, tuple, list)						))
      )
      if is_batched:
           UpperCamelCase__      :       List[str]	    =  [np.asarray([speech]							,       dtype=np.floataa						).T for speech in raw_speech]
      elif not is_batched and not isinstance(SCREAMING_SNAKE_CASE							,       np.ndarray						):
           UpperCamelCase__      :       int	    =  np.asarray(SCREAMING_SNAKE_CASE							,       dtype=np.floataa						)
      elif isinstance(SCREAMING_SNAKE_CASE							,       np.ndarray						) and raw_speech.dtype is np.dtype(np.floataa						):
           UpperCamelCase__      :       List[str]	    =  raw_speech.astype(np.floataa						)
      # always return batch
      if not is_batched:
           UpperCamelCase__      :       Union[str, Any]	    =  [np.asarray([raw_speech]						).T]

      # Convert audio signals to log mel spectrograms, truncate by time axis
      UpperCamelCase__      :       Tuple	    =  [
          self._np_extract_fbank_features(waveform.squeeze()						).T[: self.spectrogram_length] for waveform in raw_speech
      ]
      if isinstance(audio_features[0]							,       SCREAMING_SNAKE_CASE						):
           UpperCamelCase__      :       List[str]	    =  [np.asarray(SCREAMING_SNAKE_CASE							,       dtype=np.floataa						) for feature in audio_features]

      # Create audio attention mask
      UpperCamelCase__      :       Optional[int]	    =  max(
          [ceil(feature.shape[0] / self.patch_size[0]						) * self.freq_len for feature in audio_features]						)  # The maximum number of audio patches in a batch
      if return_attention_mask:
           UpperCamelCase__      :       Dict	    =  [
               (ceil(feature.shape[0] / self.patch_size[0]						) * self.freq_len) * [1]
               + (max_patch_len - ceil(feature.shape[0] / self.patch_size[0]						) * self.freq_len) * [0]
               for feature in audio_features
           ]
           UpperCamelCase__      :       Any	    =  np.array(SCREAMING_SNAKE_CASE						).astype(np.floataa						)

      # convert into correct format for padding
      UpperCamelCase__      :       str	    =  max_patch_len // self.freq_len * self.patch_size[0]  # The maximum audio size in a batch
      UpperCamelCase__      :       str	    =  np.ones([len(SCREAMING_SNAKE_CASE						), 1, max_time_len, self.feature_size]						).astype(np.floataa						)
      UpperCamelCase__      :       str	    =  padded_audio_features * self.padding_value
      for i in range(len(SCREAMING_SNAKE_CASE						)						):
           UpperCamelCase__      :       Dict	    =  audio_features[i]
           UpperCamelCase__      :       int	    =  feature

      # return as BatchFeature
      if return_attention_mask:
           UpperCamelCase__      :       Optional[int]	    =  {"audio_values": padded_audio_features, "audio_mask": audio_mask}
      else:
           UpperCamelCase__      :       Optional[int]	    =  {"audio_values": padded_audio_features}

      UpperCamelCase__      :       List[str]	    =  BatchFeature(data=SCREAMING_SNAKE_CASE							,       tensor_type=SCREAMING_SNAKE_CASE						)
      return encoded_inputs







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase      )			->     int:
     UpperCamelCase__      :       int	    =  1
     for i in range(1 ,   num + 1      ):
          fact *= i
     return fact







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase      )			->     int:
     UpperCamelCase__      :       List[Any]	    =  0
     while number > 0:
          UpperCamelCase__      :       List[Any]	    =  number % 10
          sum_of_digits += last_digit
          UpperCamelCase__      :       int	    =  number // 10  # Removing the last_digit from the given number
     return sum_of_digits







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase = 100      )			->     int:
     UpperCamelCase__      :       Optional[Any]	    =  factorial(__lowerCAmelCase      )
     UpperCamelCase__      :       Optional[int]	    =  split_and_add(__lowerCAmelCase      )
     return result


if __name__ == "__main__":
 print(solution(int(input('''Enter the Number: ''').strip())))