from typing import List, Optional, Union

import numpy as np

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


lowerCAmelCase__  	=      logging.get_logger(__name__)
class 	_a  (							lowerCamelCase_					):



	"""simple docstring"""



	__SCREAMING_SNAKE_CASE              =					['input_values', 'attention_mask']


	def __init__(   self       ,  lowerCAmelCase_=1       ,  lowerCAmelCase_=16000       ,  lowerCAmelCase_=0.0       ,  lowerCAmelCase_=False       ,  lowerCAmelCase_=True       ,  **lowerCAmelCase_       ,  ):
		super().__init__(feature_size=lowerCAmelCase_       ,  sampling_rate=lowerCAmelCase_       ,  padding_value=lowerCAmelCase_       ,  **lowerCAmelCase_       )
		_lowercase   =return_attention_mask
		_lowercase   =do_normalize


	@staticmethod
	def __lowerCAmelCase      (   lowerCAmelCase_       ,  lowerCAmelCase_       ,  lowerCAmelCase_ = 0.0       ):
		if attention_mask is not None:
			_lowercase   =np.array(lowerCAmelCase_       ,  np.intaa       )
			_lowercase   =[]

			for vector, length in zip(lowerCAmelCase_       ,  attention_mask.sum(-1       )       ):
				_lowercase   =(vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1e-7       )
				if length < normed_slice.shape[0]:
					_lowercase   =padding_value

				normed_input_values.append(lowerCAmelCase_       )
		else:
			_lowercase   =[(x - x.mean()) / np.sqrt(x.var() + 1e-7       ) for x in input_values]

		return normed_input_values


	def __call__(   self       ,  lowerCAmelCase_       ,  lowerCAmelCase_ = False       ,  lowerCAmelCase_ = None       ,  lowerCAmelCase_ = False       ,  lowerCAmelCase_ = None       ,  lowerCAmelCase_ = None       ,  lowerCAmelCase_ = None       ,  lowerCAmelCase_ = None       ,  **lowerCAmelCase_       ,  ):

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

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

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

		# convert into correct format for padding
		_lowercase   =BatchFeature({"input_values": raw_speech}       )

		_lowercase   =self.pad(
		    lowerCAmelCase_       ,  padding=lowerCAmelCase_       ,  max_length=lowerCAmelCase_       ,  truncation=lowerCAmelCase_       ,  pad_to_multiple_of=lowerCAmelCase_       ,  return_attention_mask=lowerCAmelCase_       ,  )

		# convert input values to correct format
		_lowercase   =padded_inputs["input_values"]
		if not isinstance(input_values[0]       ,  np.ndarray       ):
			_lowercase   =[np.asarray(lowerCAmelCase_       ,  dtype=np.floataa       ) for array in input_values]
		elif (
		    not isinstance(lowerCAmelCase_       ,  np.ndarray       )
		    and isinstance(input_values[0]       ,  np.ndarray       )
		    and input_values[0].dtype is np.dtype(np.floataa       )
		):
			_lowercase   =[array.astype(np.floataa       ) for array in input_values]
		elif isinstance(lowerCAmelCase_       ,  np.ndarray       ) and input_values.dtype is np.dtype(np.floataa       ):
			_lowercase   =input_values.astype(np.floataa       )

		# convert attention_mask to correct format
		_lowercase   =padded_inputs.get("attention_mask"       )
		if attention_mask is not None:
			_lowercase   =[np.asarray(lowerCAmelCase_       ,  dtype=np.intaa       ) for array in attention_mask]

		# zero-mean and unit-variance normalization
		if self.do_normalize:
			_lowercase   =(
			    attention_mask
			    if self._get_padding_strategies(lowerCAmelCase_       ,  max_length=lowerCAmelCase_       ) is not PaddingStrategy.DO_NOT_PAD
			    else None
			)
			_lowercase   =self.zero_mean_unit_var_norm(
			    padded_inputs["input_values"]       ,  attention_mask=lowerCAmelCase_       ,  padding_value=self.padding_value       )

		if return_tensors is not None:
			_lowercase   =padded_inputs.convert_to_tensors(lowerCAmelCase_       )

		return padded_inputs





def 	__lowerCamelCase							(				)      ->       Dict:
	_lowercase   =1

	while True:
		if (
		    sorted(str(__a		)		)
		    == sorted(str(2 * i		)		)
		    == sorted(str(3 * i		)		)
		    == sorted(str(4 * i		)		)
		    == sorted(str(5 * i		)		)
		    == sorted(str(6 * i		)		)
		):
			return i

		i += 1


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




