






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


snake_case__   :						int													=   logging.get_logger(__name__)


class     _a							(	UpperCAmelCase__     ):






  """simple docstring"""





  A_						       = ["""audio_values""", """audio_mask"""]




  def __init__(  self		,		_UpperCAmelCase=2048		,		_UpperCAmelCase=1		,		_UpperCAmelCase=[16, 16]		,		_UpperCAmelCase=128		,		_UpperCAmelCase=44100		,		_UpperCAmelCase=86		,		_UpperCAmelCase=2048		,		_UpperCAmelCase=0.0		,		**_UpperCAmelCase		,		)      ->			Optional[Any]:
     super().__init__(
         feature_size=_UpperCAmelCase		,		sampling_rate=_UpperCAmelCase		,		padding_value=_UpperCAmelCase		,		**_UpperCAmelCase		,		)

     UpperCamelCase_						=  spectrogram_length
     UpperCamelCase_						=  num_channels
     UpperCamelCase_						=  patch_size
     UpperCamelCase_						=  feature_size // self.patch_size[1]
     UpperCamelCase_						=  n_fft
     UpperCamelCase_						=  sampling_rate // hop_length_to_sampling_rate
     UpperCamelCase_						=  sampling_rate
     UpperCamelCase_						=  padding_value
     UpperCamelCase_						=  mel_filter_bank(
         num_frequency_bins=1 + n_fft // 2		,		num_mel_filters=_UpperCAmelCase		,		min_frequency=0.0		,		max_frequency=2_2_0_5_0.0		,		sampling_rate=_UpperCAmelCase		,		norm='slaney'		,		mel_scale='slaney'		,		).T




  def  _UpperCAmelCase  (  self		,		_UpperCAmelCase			)      ->			np.ndarray:
     UpperCamelCase_						=  spectrogram(
         _UpperCAmelCase		,		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_						=  log_spec[:, :-1]
     UpperCamelCase_						=  log_spec - 2_0.0
     UpperCamelCase_						=  np.clip(log_spec / 4_0.0		,		-2.0		,		0.0			) + 1.0
     return log_spec




  def __call__(  self		,		_UpperCAmelCase		,		_UpperCAmelCase = None		,		_UpperCAmelCase = True		,		_UpperCAmelCase = None		,		_UpperCAmelCase = False		,		_UpperCAmelCase = False		,		**_UpperCAmelCase		,		)      ->			BatchFeature:

     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_						=  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)			))
     )
     if is_batched:
        UpperCamelCase_						=  [np.asarray([speech]		,		dtype=np.floataa			).T for speech in raw_speech]
     elif not is_batched and not isinstance(_UpperCAmelCase		,		np.ndarray			):
        UpperCamelCase_						=  np.asarray(_UpperCAmelCase		,		dtype=np.floataa			)
     elif isinstance(_UpperCAmelCase		,		np.ndarray			) and raw_speech.dtype is np.dtype(np.floataa			):
        UpperCamelCase_						=  raw_speech.astype(np.floataa			)
     # always return batch
     if not is_batched:
        UpperCamelCase_						=  [np.asarray([raw_speech]			).T]

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

     # Create audio attention mask
     UpperCamelCase_						=  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_						=  [
            (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_						=  np.array(_UpperCAmelCase			).astype(np.floataa			)

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

     # return as BatchFeature
     if return_attention_mask:
        UpperCamelCase_						=  {'audio_values': padded_audio_features, 'audio_mask': audio_mask}
     else:
        UpperCamelCase_						=  {'audio_values': padded_audio_features}

     UpperCamelCase_						=  BatchFeature(data=_UpperCAmelCase		,		tensor_type=_UpperCAmelCase			)
     return encoded_inputs













def      _snake_case     (__lowercase):
   UpperCamelCase_						=  1
   for i in range(1     ,   num + 1):
      fact *= i
   return fact






def      _snake_case     (__lowercase):
   UpperCamelCase_						=  0
   while number > 0:
      UpperCamelCase_						=  number % 10
      sum_of_digits += last_digit
      UpperCamelCase_						=  number // 10  # Removing the last_digit from the given number
   return sum_of_digits






def      _snake_case     (__lowercase = 100):
   UpperCamelCase_						=  factorial(__lowercase)
   UpperCamelCase_						=  split_and_add(__lowercase)
   return result


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





