




'''simple docstring'''

from typing import List, Optional, Union

import numpy as np
import torch
import torchaudio.compliance.kaldi as ta_kaldi

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


a       :						Dict								=		logging.get_logger(__name__)



class 		SCREAMING_SNAKE_CASE__  (			_UpperCamelCase	):
			__SCREAMING_SNAKE_CASE    =			["""input_features""", """attention_mask"""]





			def __init__(      self						:    Any      ,		a_						:    Optional[Any]=80      ,		a_						:    Optional[Any]=16_000      ,		a_						:    Tuple=80      ,		a_						:    int=0.0      ,		a_						:    List[Any]=True      ,		a_						:    Union[str, Any]=True      ,		a_						:    List[Any]=True      ,		**a_						:    List[Any]      ,		):



						"""simple docstring"""




						super().__init__(feature_size=a_      ,		sampling_rate=a_      ,		padding_value=a_      ,		**a_							)
						__snake_case			=		num_mel_bins
						__snake_case			=		do_ceptral_normalize
						__snake_case			=		normalize_means
						__snake_case			=		normalize_vars
						__snake_case			=		True





			def 							A (      self						:    Tuple      ,		a_						:    np.ndarray      ,		):



						"""simple docstring"""




						__snake_case			=		waveform * (2**15)  # Kaldi compliance: 16-bit signed integers
						__snake_case			=		torch.from_numpy(a_							).unsqueeze(0							)
						__snake_case			=		ta_kaldi.fbank(a_      ,		num_mel_bins=self.num_mel_bins      ,		sample_frequency=self.sampling_rate							)
						return features.numpy()





			@staticmethod
			def 							A (      a_						:    np.ndarray      ,		a_						:    int      ,		a_						:    Optional[bool] = True      ,		a_						:    Optional[bool] = True      ,		a_						:    float = 0.0      ,		):



						"""simple docstring"""




						if normalize_means:
									__snake_case			=		x[:input_length].mean(axis=0							)
									__snake_case			=		np.subtract(a_      ,		a_							)
						if normalize_vars:
									__snake_case			=		x[:input_length].std(axis=0							)
									__snake_case			=		np.divide(a_      ,		a_							)

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

						# make sure array is in float32
						__snake_case			=		x.astype(np.floataa							)

						return x





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



						"""simple docstring"""




						__snake_case			=		attention_mask.sum(-1							) if attention_mask is not None else [x.shape[0] for x in input_features]
						return [
						    self.utterance_cmvn(a_      ,		a_      ,		self.normalize_means      ,		self.normalize_vars      ,		self.padding_value							)
						    for x, n in zip(a_      ,		a_							)
						]






			def __call__(      self						:    List[Any]      ,		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[Union[str, TensorType]] = None      ,		a_						:    Optional[int] = None      ,		a_						:    Optional[bool] = 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."							)

						__snake_case			=		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}'''							)
						__snake_case			=		is_batched_numpy or (
						    isinstance(a_      ,		(list, tuple)							) and (isinstance(raw_speech[0]      ,		(np.ndarray, tuple, list)							))
						)

						if is_batched:
									__snake_case			=		[np.asarray(a_      ,		dtype=np.floataa							) for speech in raw_speech]
						elif not is_batched and not isinstance(a_      ,		np.ndarray							):
									__snake_case			=		np.asarray(a_      ,		dtype=np.floataa							)
						elif isinstance(a_      ,		np.ndarray							) and raw_speech.dtype is np.dtype(np.floataa							):
									__snake_case			=		raw_speech.astype(np.floataa							)

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

						# extract fbank features
						__snake_case			=		[self._extract_fbank_features(a_							) for waveform in raw_speech]

						# convert into correct format for padding
						__snake_case			=		BatchFeature({"input_features": features}							)

						__snake_case			=		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
						__snake_case			=		padded_inputs.get("input_features"							)
						if isinstance(input_features[0]      ,		a_							):
									__snake_case			=		[np.asarray(a_      ,		dtype=np.floataa							) for feature in input_features]

						__snake_case			=		padded_inputs.get("attention_mask"							)
						if attention_mask is not None:
									__snake_case			=		[np.asarray(a_      ,		dtype=np.intaa							) for array in attention_mask]

						# Utterance-level cepstral mean and variance normalization
						if self.do_ceptral_normalize:
									__snake_case			=		(
									    np.array(a_      ,		dtype=np.intaa							)
									    if self._get_padding_strategies(a_      ,		max_length=a_							) is not PaddingStrategy.DO_NOT_PAD
									    else None
									)
									__snake_case			=		self.normalize(
									    padded_inputs["input_features"]      ,		attention_mask=a_							)

						if return_tensors is not None:
									__snake_case			=		padded_inputs.convert_to_tensors(a_							)

						return padded_inputs











def      lowerCamelCase_						(			)	->			List[str]:





				"""simple docstring"""


				__lowerCamelCase									=       0
				for i in range(1					,	1001 ):
								total += i**i
				return str(UpperCamelCase__ )[-10:]


if __name__ == "__main__":
					print(solution())


