






_UpperCamelCase    :   List[Any]   			=						range(2, 20 + 1)
_UpperCamelCase    :   Optional[Any]   			=						[10**k for k in range(ks[-1] + 1)]
_UpperCamelCase    :   Dict   			=						{}




def       snake_case  (A_				:int     ,      A_				:Union[str, Any]     ,      A_				:Optional[int]     ,      A_				:List[Any]				):







  '''simple docstring'''

  a					:      str    =       sum(a_i[j] for j in range(_lowerCamelCase     ,      len(_lowerCamelCase				)				)				)
  a					:      Dict    =       sum(a_i[j] * base[j] for j in range(min(len(_lowerCamelCase				)     ,      _lowerCamelCase				)				)				)

  a					:      int    =       0, 0
  a					:      List[str]    =       n - i

  a					:      Optional[Any]    =       memo.get(_lowerCamelCase				)

  if sub_memo is not None:
    a					:      int    =       sub_memo.get(_lowerCamelCase				)

    if jumps is not None and len(_lowerCamelCase				) > 0:
      # find and make the largest jump without going over
      a					:      Optional[int]    =       -1
      for _k in range(len(_lowerCamelCase				) - 1     ,      -1     ,      -1				):
        if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
          a					:      Dict    =       _k
          break

      if max_jump >= 0:
        a					:      Any    =       jumps[max_jump]
        # since the difference between jumps is cached, add c
        a					:      int    =       diff + c
        for j in range(min(_lowerCamelCase     ,      len(_lowerCamelCase				)				)				):
          a					:      int    =       divmod(_lowerCamelCase     ,      1_0				)
        if new_c > 0:
          add(_lowerCamelCase     ,      _lowerCamelCase     ,      _lowerCamelCase				)

    else:
      a					:      List[str]    =       []
  else:
    a					:      int    =       {c: []}
    a					:      Optional[int]    =       sub_memo

  if dn >= max_dn or c + diff >= base[k]:
    return diff, dn

  if k > ks[0]:
    while True:
      # keep doing smaller jumps
      a					:      str    =       next_term(_lowerCamelCase     ,      k - 1     ,      i + dn     ,      _lowerCamelCase				)
      diff += _diff
      dn += terms_jumped

      if dn >= max_dn or c + diff >= base[k]:
        break
  else:
    # would be too small a jump, just compute sequential terms instead
    a					:      List[str]    =       compute(_lowerCamelCase     ,      _lowerCamelCase     ,      i + dn     ,      _lowerCamelCase				)
    diff += _diff
    dn += terms_jumped

  a					:      Union[str, Any]    =       sub_memo[c]

  # keep jumps sorted by # of terms skipped
  a					:      Union[str, Any]    =       0
  while j < len(_lowerCamelCase				):
    if jumps[j][1] > dn:
      break
    j += 1

  # cache the jump for this value digitsum(b) and c
  sub_memo[c].insert(_lowerCamelCase     ,      (diff, dn, k)				)
  return (diff, dn)




def       snake_case  (A_				:Optional[int]     ,      A_				:Union[str, Any]     ,      A_				:Dict     ,      A_				:Dict				):







  '''simple docstring'''

  if i >= n:
    return 0, i
  if k > len(_lowerCamelCase				):
    a_i.extend([0 for _ in range(k - len(_lowerCamelCase				)				)]				)

  # note: a_i -> b * 10^k + c
  # ds_b -> digitsum(b)
  # ds_c -> digitsum(c)
  a					:      List[Any]    =       i
  a					:      str    =       0, 0, 0
  for j in range(len(_lowerCamelCase				)				):
    if j >= k:
      ds_b += a_i[j]
    else:
      ds_c += a_i[j]

  while i < n:
    i += 1
    a					:      Dict    =       ds_c + ds_b
    diff += addend
    a					:      List[Any]    =       0
    for j in range(_lowerCamelCase				):
      a					:      str    =       a_i[j] + addend
      a					:      Any    =       divmod(_lowerCamelCase     ,      1_0				)

      ds_c += a_i[j]

    if addend > 0:
      break

  if addend > 0:
    add(_lowerCamelCase     ,      _lowerCamelCase     ,      _lowerCamelCase				)
  return diff, i - start_i




def       snake_case  (A_				:List[str]     ,      A_				:List[str]     ,      A_				:Union[str, Any]				):







  '''simple docstring'''

  for j in range(_lowerCamelCase     ,      len(_lowerCamelCase				)				):
    a					:      Optional[Any]    =       digits[j] + addend
    if s >= 1_0:
      a					:      List[str]    =       divmod(_lowerCamelCase     ,      1_0				)
      a					:      List[Any]    =       addend // 1_0 + quotient
    else:
      a					:      int    =       s
      a					:      Optional[int]    =       addend // 1_0

    if addend == 0:
      break

  while addend > 0:
    a					:      Union[str, Any]    =       divmod(_lowerCamelCase     ,      1_0				)
    digits.append(_lowerCamelCase				)




def       snake_case  (A_				:Optional[int] = 1_0**1_5				):







  '''simple docstring'''

  a					:      Dict    =       [1]
  a					:      Dict    =       1
  a					:      List[Any]    =       0
  while True:
    a					:      Any    =       next_term(_lowerCamelCase     ,      2_0     ,      i + dn     ,      _lowerCamelCase				)
    dn += terms_jumped
    if dn == n - i:
      break

  a					:      Optional[Any]    =       0
  for j in range(len(_lowerCamelCase				)				):
    a_n += digits[j] * 1_0**j
  return a_n


if __name__ == "__main__":
   print(f'''{solution() = }''')












"""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    :   int   			=						logging.get_logger(__name__)






class 						snake_case  (  UpperCAmelCase	):
    __magic_name__   					=					['''input_features''', '''attention_mask''']





    def __init__(							self     : Optional[int]    ,		A     : Optional[Any]=8_0    ,		A     : str=1_6_0_0_0    ,		A     : List[str]=0.0    ,		A     : Any=1_0    ,		A     : Union[str, Any]=2_5    ,		A     : str="hamming_window"    ,		A     : str=3_27_68.0    ,		A     : Union[str, Any]=0.97    ,		A     : Dict=1.0    ,		A     : Any=True    ,		A     : Union[str, Any]=True    ,		A     : List[Any]=False    ,		**A     : Tuple    ,		):


      '''simple docstring'''




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

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

      a					:      List[Any]    =       win_length * sampling_rate // 1_0_0_0
      a					:      Tuple    =       hop_length * sampling_rate // 1_0_0_0

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





    def     lowerCamelCase__				(							self     : List[Any]    ,		A     : np.array      ):


      '''simple docstring'''




      if self.win_function == "hamming_window":
        a					:      List[str]    =       window_function(window_length=self.sample_size    ,		name=self.win_function    ,		periodic=A      )
      else:
        a					:      Dict    =       window_function(window_length=self.sample_size    ,		name=self.win_function      )

      a					:      str    =       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    ,		)

      a					:      List[Any]    =       spectrogram(
          one_waveform * self.frame_signal_scale    ,		window=A    ,		frame_length=self.sample_size    ,		hop_length=self.sample_stride    ,		fft_length=self.n_fft    ,		center=A    ,		preemphasis=self.preemphasis_coeff    ,		mel_filters=A    ,		mel_floor=self.mel_floor    ,		log_mel='log'    ,		)
      return msfc_features.T





    def     lowerCamelCase__				(							self     : int    ,		A     : Tuple    ,		A     : int    ,		A     : Optional[int]      ):


      '''simple docstring'''




      if self.normalize_means:
        a					:      Any    =       x[:input_length].mean(axis=0      )
        a					:      Dict    =       np.subtract(A    ,		A      )
      if self.normalize_vars:
        a					:      Dict    =       x[:input_length].std(axis=0      )
        a					:      Dict    =       np.divide(A    ,		A      )

      if input_length < x.shape[0]:
        a					:      Dict    =       padding_value

      # make sure array is in float32
      a					:      Optional[int]    =       x.astype(np.floataa      )

      return x





    def     lowerCamelCase__				(							self     : str    ,		A     : List[np.ndarray]    ,		A     : Optional[np.ndarray] = None      ):


      '''simple docstring'''




      a					:      str    =       attention_mask.sum(-1      ) if attention_mask is not None else [x.shape[0] for x in input_features]
      return [self._normalize_one(A    ,		A    ,		self.padding_value      ) for x, n in zip(A    ,		A      )]





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


      '''simple docstring'''




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

      a					:      Optional[int]    =       isinstance(A    ,		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					:      Dict    =       is_batched_numpy or (
          isinstance(A    ,		(list, tuple)      ) and (isinstance(raw_speech[0]    ,		(np.ndarray, tuple, list)      ))
      )

      if is_batched:
        a					:      str    =       [np.asarray(A    ,		dtype=np.floataa      ) for speech in raw_speech]
      elif not is_batched and not isinstance(A    ,		np.ndarray      ):
        a					:      List[str]    =       np.asarray(A    ,		dtype=np.floataa      )
      elif isinstance(A    ,		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					:      Any    =       [raw_speech]

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

      # convert into correct format for padding
      a					:      int    =       BatchFeature({'input_features': features}      )

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

      a					:      List[Any]    =       padded_inputs.get('attention_mask'      )
      if attention_mask is not None:
        a					:      int    =       [np.asarray(A    ,		dtype=np.intaa      ) for array in attention_mask]

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

      if return_tensors is not None:
        a					:      Optional[int]    =       padded_inputs.convert_to_tensors(A      )

      return padded_inputs




