





import copy
from typing import Any, Dict, List, Optional, Union

import numpy as np
import torch

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


SCREAMING_SNAKE_CASE__							:      int         =    logging.get_logger(__name__)







class 	__lowerCAmelCase      (       _UpperCamelCase	):
   _UpperCamelCase			:    Optional[int]  		=					["""input_features""", """is_longer"""]





   def __init__(			self       ,      snake_case=64       ,      snake_case=48_000       ,      snake_case=480       ,      snake_case=10       ,      snake_case=1_024       ,      snake_case=0.0       ,      snake_case=False       ,      snake_case = 0       ,      snake_case = 14_000       ,      snake_case = None       ,      snake_case = "fusion"       ,      snake_case = "repeatpad"       ,      **snake_case       ,      )					->	Tuple:
      """simple docstring"""





      super().__init__(
          feature_size=snake_case       ,      sampling_rate=snake_case       ,      padding_value=snake_case       ,      return_attention_mask=snake_case       ,      **snake_case       ,      )
      a__						:    Any   		=	top_db
      a__						:    List[Any]   		=	truncation
      a__						:    Tuple   		=	padding
      a__						:    str   		=	fft_window_size
      a__						:    int   		=	(fft_window_size >> 1) + 1
      a__						:    Dict   		=	hop_length
      a__						:    Optional[int]   		=	max_length_s
      a__						:    str   		=	max_length_s * sampling_rate
      a__						:    Union[str, Any]   		=	sampling_rate
      a__						:    str   		=	frequency_min
      a__						:    Optional[int]   		=	frequency_max
      a__						:    Tuple   		=	mel_filter_bank(
          num_frequency_bins=self.nb_frequency_bins       ,      num_mel_filters=snake_case       ,      min_frequency=snake_case       ,      max_frequency=snake_case       ,      sampling_rate=snake_case       ,      norm=snake_case       ,      mel_scale="htk"       ,      )
      a__						:    Optional[Any]   		=	mel_filter_bank(
          num_frequency_bins=self.nb_frequency_bins       ,      num_mel_filters=snake_case       ,      min_frequency=snake_case       ,      max_frequency=snake_case       ,      sampling_rate=snake_case       ,      norm="slaney"       ,      mel_scale="slaney"       ,      )





   def 						_snake_case			(			self   )					->	Dict[str, Any]:
      """simple docstring"""





      a__						:    str   		=	copy.deepcopy(self.__dict__   )
      a__						:    List[str]   		=	self.__class__.__name__
      if "mel_filters" in output:
         del output["mel_filters"]
      if "mel_filters_slaney" in output:
         del output["mel_filters_slaney"]
      return output





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case = None   )					->	np.ndarray:
      """simple docstring"""





      a__						:    Tuple   		=	spectrogram(
          snake_case       ,      window_function(self.fft_window_size       ,      "hann"   )       ,      frame_length=self.fft_window_size       ,      hop_length=self.hop_length       ,      power=2.0       ,      mel_filters=snake_case       ,      log_mel="dB"       ,      )
      return log_mel_spectrogram.T





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case   )					->	List[Any]:
      """simple docstring"""





      a__						:    Union[str, Any]   		=	np.array_split(list(range(0       ,      total_frames - chunk_frames + 1   )   )       ,      3   )
      if len(ranges[1]   ) == 0:
         # if the audio is too short, we just use the first chunk
         a__						:    int   		=	[0]
      if len(ranges[2]   ) == 0:
         # if the audio is too short, we just use the first chunk
         a__						:    Optional[int]   		=	[0]
      # randomly choose index for each part
      a__						:    Any   		=	np.random.choice(ranges[0]   )
      a__						:    Any   		=	np.random.choice(ranges[1]   )
      a__						:    Optional[int]   		=	np.random.choice(ranges[2]   )

      a__						:    Optional[Any]   		=	mel[idx_front : idx_front + chunk_frames, :]
      a__						:    Tuple   		=	mel[idx_middle : idx_middle + chunk_frames, :]
      a__						:    Optional[Any]   		=	mel[idx_back : idx_back + chunk_frames, :]

      a__						:    str   		=	torch.tensor(mel[None, None, :]   )
      a__						:    List[Any]   		=	torch.nn.functional.interpolate(
          snake_case       ,      size=[chunk_frames, 64]       ,      mode="bilinear"       ,      align_corners=snake_case   )
      a__						:    int   		=	mel_shrink[0][0].numpy()
      a__						:    Union[str, Any]   		=	np.stack([mel_shrink, mel_chunk_front, mel_chunk_middle, mel_chunk_back]       ,      axis=0   )
      return mel_fusion





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case   )					->	np.array:
      """simple docstring"""





      if waveform.shape[0] > max_length:
         if truncation == "rand_trunc":
            a__						:    List[str]   		=	True
            # random crop to max_length (for compatibility) -> this should be handled by self.pad
            a__						:    Optional[int]   		=	len(snake_case   ) - max_length
            a__						:    Tuple   		=	np.random.randint(0       ,      overflow + 1   )
            a__						:    Dict   		=	waveform[idx : idx + max_length]
            a__						:    Union[str, Any]   		=	self._np_extract_fbank_features(snake_case       ,      self.mel_filters_slaney   )[None, :]
         elif truncation == "fusion":
            a__						:    str   		=	self._np_extract_fbank_features(snake_case       ,      self.mel_filters   )
            a__						:    List[str]   		=	max_length // self.hop_length + 1  # the +1 related to how the spectrogram is computed
            a__						:    int   		=	mel.shape[0]
            if chunk_frames == total_frames:
               # there is a corner case where the audio length is larger than max_length but smaller than max_length+hop_length.
               # In this case, we just use the whole audio.
               a__						:    List[str]   		=	np.stack([mel, mel, mel, mel]       ,      axis=0   )
               a__						:    List[Any]   		=	False
            else:
               a__						:    int   		=	self._random_mel_fusion(snake_case       ,      snake_case       ,      snake_case   )
               a__						:    List[Any]   		=	True
         else:
            raise NotImplementedError(F"""data_truncating {truncation} not implemented"""   )

      else:
         a__						:    List[Any]   		=	False
         # only use repeat as a new possible value for padding. you repeat the audio before applying the usual max_length padding
         if waveform.shape[0] < max_length:
            if padding == "repeat":
               a__						:    Tuple   		=	int(max_length / len(snake_case   )   )
               a__						:    Optional[int]   		=	np.stack(np.tile(snake_case       ,      n_repeat + 1   )   )[:max_length]
            if padding == "repeatpad":
               a__						:    int   		=	int(max_length / len(snake_case   )   )
               a__						:    int   		=	np.stack(np.tile(snake_case       ,      snake_case   )   )
            a__						:    int   		=	np.pad(snake_case       ,      (0, max_length - waveform.shape[0])       ,      mode="constant"       ,      constant_values=0   )

         if truncation == "fusion":
            a__						:    Union[str, Any]   		=	self._np_extract_fbank_features(snake_case       ,      self.mel_filters   )
            a__						:    Optional[Any]   		=	np.stack([input_mel, input_mel, input_mel, input_mel]       ,      axis=0   )
         else:
            a__						:    Tuple   		=	self._np_extract_fbank_features(snake_case       ,      self.mel_filters_slaney   )[None, :]

      return input_mel, longer





   def __call__(			self       ,      snake_case       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      **snake_case       ,      )					->	BatchFeature:
      """simple docstring"""





      a__						:    str   		=	truncation if truncation is not None else self.truncation
      a__						:    List[Any]   		=	padding if padding else self.padding

      if sampling_rate is not None:
         if sampling_rate != self.sampling_rate:
            raise ValueError(
                F"""The model corresponding to this feature extractor: {self.__class__.__name__} was trained using a"""
                F""" sampling rate of {self.sampling_rate}. Please make sure that the provided `raw_speech` input"""
                F""" was sampled 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."   )

      a__						:    int   		=	isinstance(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}"""   )
      a__						:    Union[str, Any]   		=	is_batched_numpy or (
          isinstance(snake_case       ,      (list, tuple)   ) and (isinstance(raw_speech[0]       ,      (np.ndarray, tuple, list)   ))
      )

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

      # always return batch
      if not is_batched:
         a__						:    Dict   		=	[np.asarray(snake_case   )]

      # convert to mel spectrogram, truncate and pad if needed.
      a__						:    Union[str, Any]   		=	[
          self._get_input_mel(snake_case       ,      max_length if max_length else self.nb_max_samples       ,      snake_case       ,      snake_case   )
          for waveform in raw_speech
      ]

      a__						:    Optional[int]   		=	[]
      a__						:    Optional[int]   		=	[]
      for mel, longer in padded_inputs:
         input_mel.append(snake_case   )
         is_longer.append(snake_case   )

      if truncation == "fusion" and sum(snake_case   ) == 0:
         # if no audio is longer than 10s, then randomly select one audio to be longer
         a__						:    str   		=	np.random.randint(0       ,      len(snake_case   )   )
         a__						:    Optional[Any]   		=	True

      if isinstance(input_mel[0]       ,      snake_case   ):
         a__						:    Dict   		=	[np.asarray(snake_case       ,      dtype=np.floataa   ) for feature in input_mel]

      # is_longer is a list of bool
      a__						:    int   		=	[[longer] for longer in is_longer]

      a__						:    Union[str, Any]   		=	{"input_features": input_mel, "is_longer": is_longer}
      a__						:    Union[str, Any]   		=	BatchFeature(snake_case   )

      if return_tensors is not None:
         a__						:    Any   		=	input_features.convert_to_tensors(snake_case   )

      return input_features








def    _A	(   lowerCamelCase ):
   a__						:    Optional[Any]   		=	1
   for i in range(1				,			num + 1 ):
      fact *= i
   return fact






def    _A	(   lowerCamelCase ):
   a__						:    List[Any]   		=	0
   while number > 0:
      a__						:    str   		=	number % 10
      sum_of_digits += last_digit
      a__						:    Dict   		=	number // 10  # Removing the last_digit from the given number
   return sum_of_digits






def    _A	(   lowerCamelCase = 100 ):
   a__						:    Any   		=	factorial(lowerCamelCase )
   a__						:    Optional[Any]   		=	split_and_add(lowerCamelCase )
   return result


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

