

import itertools
import random
import unittest

import numpy as np

from transformers import BatchFeature, SpeechTaFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
			import torch


a__												=						random.Random()



def   __UpperCAmelCase					(      __a :     Optional[Any]						,__a :     int=1.0						,__a :     int=None						,__a :     Optional[int]=None      )     ->	Any:

					"""simple docstring"""

					if rng is None:
										_a      :       str   =						global_rng

					_a      :       Union[str, Any]   =						[]
					for batch_idx in range(shape[0]      ):
										values.append([]      )
										for _ in range(shape[1]      ):
															values[-1].append(rng.random() * scale      )

					return values

@require_torch
class 							UpperCAmelCase_						(     unittest.TestCase  ):
							"""simple docstring"""







							def __init__(     self			,				_a			,				_a=7			,				_a=4_0_0			,				_a=2_0_0_0			,				_a=1			,				_a=0.0			,				_a=1_6_0_0_0			,				_a=True			,				_a=8_0			,				_a=1_6			,				_a=6_4			,				_a="hann_window"			,				_a=8_0			,				_a=7_6_0_0			,				_a=1e-1_0			,				_a=True			,				)       ->       str:
												_a      :       Optional[Any]   =						parent
												_a      :       str   =						batch_size
												_a      :       Optional[int]   =						min_seq_length
												_a      :       Dict   =						max_seq_length
												_a      :       List[str]   =						(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
												_a      :       Union[str, Any]   =						feature_size
												_a      :       List[str]   =						padding_value
												_a      :       Dict   =						sampling_rate
												_a      :       str   =						do_normalize
												_a      :       List[Any]   =						num_mel_bins
												_a      :       List[Any]   =						hop_length
												_a      :       Any   =						win_length
												_a      :       str   =						win_function
												_a      :       int   =						fmin
												_a      :       Tuple   =						fmax
												_a      :       str   =						mel_floor
												_a      :       Tuple   =						return_attention_mask


							def 							__lowercase							(     self			)       ->       List[Any]:
												return {
												    "feature_size": self.feature_size,
												    "padding_value": self.padding_value,
												    "sampling_rate": self.sampling_rate,
												    "do_normalize": self.do_normalize,
												    "num_mel_bins": self.num_mel_bins,
												    "hop_length": self.hop_length,
												    "win_length": self.win_length,
												    "win_function": self.win_function,
												    "fmin": self.fmin,
												    "fmax": self.fmax,
												    "mel_floor": self.mel_floor,
												    "return_attention_mask": self.return_attention_mask,
												}


							def 							__lowercase							(     self			,				_a=False			,				_a=False			)       ->       Optional[Any]:





												def _flatten(_a			):
																	return list(itertools.chain(*_a			)			)

												if equal_length:
																	_a      :       int   =						floats_list((self.batch_size, self.max_seq_length)			)
												else:
																	# make sure that inputs increase in size
																	_a      :       Optional[Any]   =						[
																	    _flatten(floats_list((x, self.feature_size)			)			)
																	    for x in range(self.min_seq_length			,				self.max_seq_length			,				self.seq_length_diff			)
																	]

												if numpify:
																	_a      :       Optional[Any]   =						[np.asarray(_a			) for x in speech_inputs]

												return speech_inputs




							def 							__lowercase							(     self			,				_a=False			,				_a=False			)       ->       str:





												if equal_length:
																	_a      :       Tuple   =						[floats_list((self.max_seq_length, self.num_mel_bins)			) for _ in range(self.batch_size			)]
												else:
																	# make sure that inputs increase in size
																	_a      :       Dict   =						[
																	    floats_list((x, self.num_mel_bins)			)
																	    for x in range(self.min_seq_length			,				self.max_seq_length			,				self.seq_length_diff			)
																	]

												if numpify:
																	_a      :       int   =						[np.asarray(_a			) for x in speech_inputs]

												return speech_inputs



@require_torch
class 							UpperCAmelCase_						(     _UpperCamelCase							,			unittest.TestCase  ):
							"""simple docstring"""







							UpperCAmelCase__			:		Any             =       SpeechTaFeatureExtractor


							def 							__lowercase							(     self			)       ->       str:
												_a      :       Any   =						SpeechTaFeatureExtractionTester(self			)


							def 							__lowercase							(     self			,				_a			)       ->       Dict:
												self.assertTrue(np.all(np.mean(_a			,				axis=0			) < 1e-3			)			)
												self.assertTrue(np.all(np.abs(np.var(_a			,				axis=0			) - 1			) < 1e-3			)			)


							def 							__lowercase							(     self			)       ->       Dict:
												_a      :       Any   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												# create three inputs of length 800, 1000, and 1200
												_a      :       Any   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]
												_a      :       int   =						[np.asarray(_a			) for speech_input in speech_inputs]

												# Test not batched input
												_a      :       str   =						feat_extract(speech_inputs[0]			,				return_tensors='''np'''			).input_values
												_a      :       str   =						feat_extract(np_speech_inputs[0]			,				return_tensors='''np'''			).input_values
												self.assertTrue(np.allclose(_a			,				_a			,				atol=1e-3			)			)

												# Test batched
												_a      :       Optional[int]   =						feat_extract(_a			,				return_tensors='''np'''			).input_values
												_a      :       Optional[int]   =						feat_extract(_a			,				return_tensors='''np'''			).input_values
												for enc_seq_a, enc_seq_a in zip(_a			,				_a			):
																	self.assertTrue(np.allclose(_a			,				_a			,				atol=1e-3			)			)


							def 							__lowercase							(     self			)       ->       str:
												_a      :       Dict   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												_a      :       List[Any]   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]

												_a      :       Optional[int]   =						["longest", "max_length", "do_not_pad"]
												_a      :       int   =						[None, 1_6_0_0, None]
												for max_length, padding in zip(_a			,				_a			):
																	_a      :       Tuple   =						feat_extract(_a			,				padding=_a			,				max_length=_a			,				return_tensors='''np'''			)
																	_a      :       Tuple   =						processed.input_values

																	self._check_zero_mean_unit_variance(input_values[0][:8_0_0]			)
																	self.assertTrue(input_values[0][8_0_0:].sum() < 1e-6			)
																	self._check_zero_mean_unit_variance(input_values[1][:1_0_0_0]			)
																	self.assertTrue(input_values[0][1_0_0_0:].sum() < 1e-6			)
																	self._check_zero_mean_unit_variance(input_values[2][:1_2_0_0]			)


							def 							__lowercase							(     self			)       ->       Optional[Any]:
												_a      :       Optional[int]   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												_a      :       Tuple   =						range(8_0_0			,				1_4_0_0			,				2_0_0			)
												_a      :       int   =						[floats_list((1, x)			)[0] for x in lengths]

												_a      :       Optional[Any]   =						["longest", "max_length", "do_not_pad"]
												_a      :       Tuple   =						[None, 1_6_0_0, None]

												for max_length, padding in zip(_a			,				_a			):
																	_a      :       Union[str, Any]   =						feat_extract(_a			,				max_length=_a			,				padding=_a			)
																	_a      :       Any   =						processed.input_values

																	self._check_zero_mean_unit_variance(input_values[0][:8_0_0]			)
																	self._check_zero_mean_unit_variance(input_values[1][:1_0_0_0]			)
																	self._check_zero_mean_unit_variance(input_values[2][:1_2_0_0]			)


							def 							__lowercase							(     self			)       ->       Optional[int]:
												_a      :       List[Any]   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												_a      :       Dict   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]
												_a      :       int   =						feat_extract(
												    _a			,				truncation=_a			,				max_length=1_0_0_0			,				padding='''max_length'''			,				return_tensors='''np'''			)
												_a      :       Optional[int]   =						processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]			)
												self._check_zero_mean_unit_variance(input_values[1]			)
												self._check_zero_mean_unit_variance(input_values[2]			)


							def 							__lowercase							(     self			)       ->       Optional[int]:
												_a      :       Optional[Any]   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												_a      :       int   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]
												_a      :       str   =						feat_extract(
												    _a			,				truncation=_a			,				max_length=1_0_0_0			,				padding='''longest'''			,				return_tensors='''np'''			)
												_a      :       Dict   =						processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]			)
												self._check_zero_mean_unit_variance(input_values[1, :1_0_0_0]			)
												self._check_zero_mean_unit_variance(input_values[2]			)

												# make sure that if max_length < longest -> then pad to max_length
												self.assertTrue(input_values.shape == (3, 1_0_0_0)			)

												_a      :       List[str]   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]
												_a      :       Any   =						feat_extract(
												    _a			,				truncation=_a			,				max_length=2_0_0_0			,				padding='''longest'''			,				return_tensors='''np'''			)
												_a      :       int   =						processed.input_values

												self._check_zero_mean_unit_variance(input_values[0, :8_0_0]			)
												self._check_zero_mean_unit_variance(input_values[1, :1_0_0_0]			)
												self._check_zero_mean_unit_variance(input_values[2]			)

												# make sure that if max_length > longest -> then pad to longest
												self.assertTrue(input_values.shape == (3, 1_2_0_0)			)


							def 							__lowercase							(     self			)       ->       int:
												_a      :       Tuple   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												_a      :       Any   =						np.random.rand(1_0_0			).astype(np.floataa			)
												_a      :       Optional[Any]   =						np_speech_inputs.tolist()

												for inputs in [py_speech_inputs, np_speech_inputs]:
																	_a      :       Any   =						feature_extractor.pad([{'''input_values''': inputs}]			,				return_tensors='''np'''			)
																	self.assertTrue(np_processed.input_values.dtype == np.floataa			)
																	_a      :       Dict   =						feature_extractor.pad([{'''input_values''': inputs}]			,				return_tensors='''pt'''			)
																	self.assertTrue(pt_processed.input_values.dtype == torch.floataa			)


							def 							__lowercase							(     self			)       ->       int:
												_a      :       str   =						self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
												# create three inputs of length 800, 1000, and 1200
												_a      :       Dict   =						[floats_list((1, x)			)[0] for x in range(8_0_0			,				1_4_0_0			,				2_0_0			)]
												_a      :       Dict   =						[np.asarray(_a			) for speech_input in speech_inputs]

												# Test feature size
												_a      :       int   =						feature_extractor(audio_target=_a			,				padding=_a			,				return_tensors='''np'''			).input_values
												self.assertTrue(input_values.ndim == 3			)
												self.assertTrue(input_values.shape[-1] == feature_extractor.num_mel_bins			)

												# Test not batched input
												_a      :       List[Any]   =						feature_extractor(speech_inputs[0]			,				return_tensors='''np'''			).input_values
												_a      :       Optional[Any]   =						feature_extractor(np_speech_inputs[0]			,				return_tensors='''np'''			).input_values
												self.assertTrue(np.allclose(_a			,				_a			,				atol=1e-3			)			)

												# Test batched
												_a      :       Dict   =						feature_extractor(_a			,				return_tensors='''np'''			).input_values
												_a      :       str   =						feature_extractor(_a			,				return_tensors='''np'''			).input_values
												for enc_seq_a, enc_seq_a in zip(_a			,				_a			):
																	self.assertTrue(np.allclose(_a			,				_a			,				atol=1e-3			)			)

												# Test 2-D numpy arrays are batched.
												_a      :       Optional[Any]   =						[floats_list((1, x)			)[0] for x in (8_0_0, 8_0_0, 8_0_0)]
												_a      :       int   =						np.asarray(_a			)
												_a      :       Any   =						feature_extractor(_a			,				return_tensors='''np'''			).input_values
												_a      :       Dict   =						feature_extractor(_a			,				return_tensors='''np'''			).input_values
												for enc_seq_a, enc_seq_a in zip(_a			,				_a			):
																	self.assertTrue(np.allclose(_a			,				_a			,				atol=1e-3			)			)


							def 							__lowercase							(     self			)       ->       Dict:
												_a      :       Optional[Any]   =						self.feat_extract_tester.prepare_inputs_for_target()
												_a      :       Optional[Any]   =						self.feature_extraction_class(**self.feat_extract_dict			)
												_a      :       Optional[Any]   =						feat_extract.model_input_names[0]

												_a      :       str   =						BatchFeature({input_name: speech_inputs}			)

												self.assertTrue(all(len(_a			) == len(_a			) for x, y in zip(_a			,				processed_features[input_name]			)			)			)

												_a      :       Optional[int]   =						self.feat_extract_tester.prepare_inputs_for_target(equal_length=_a			)
												_a      :       Tuple   =						BatchFeature({input_name: speech_inputs}			,				tensor_type='''np'''			)

												_a      :       Tuple   =						processed_features[input_name]

												if len(batch_features_input.shape			) < 3:
																	_a      :       str   =						batch_features_input[:, :, None]

												self.assertTrue(
												    batch_features_input.shape
												    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]			), self.feat_extract_tester.num_mel_bins)			)


							@require_torch
							def 							__lowercase							(     self			)       ->       Any:
												_a      :       Optional[int]   =						self.feat_extract_tester.prepare_inputs_for_target(equal_length=_a			)
												_a      :       Optional[Any]   =						self.feature_extraction_class(**self.feat_extract_dict			)
												_a      :       Dict   =						feat_extract.model_input_names[0]

												_a      :       str   =						BatchFeature({input_name: speech_inputs}			,				tensor_type='''pt'''			)

												_a      :       int   =						processed_features[input_name]

												if len(batch_features_input.shape			) < 3:
																	_a      :       Any   =						batch_features_input[:, :, None]

												self.assertTrue(
												    batch_features_input.shape
												    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]			), self.feat_extract_tester.num_mel_bins)			)


							@require_torch
							def 							__lowercase							(     self			)       ->       Dict:
												_a      :       List[Any]   =						self.feature_extraction_class(**self.feat_extract_dict			)
												_a      :       Optional[int]   =						self.feat_extract_tester.prepare_inputs_for_target()
												_a      :       Dict   =						feat_extract.model_input_names[0]

												_a      :       Any   =						BatchFeature({input_name: speech_inputs}			)

												_a      :       str   =						feat_extract.num_mel_bins  # hack!

												_a      :       Dict   =						feat_extract.pad(_a			,				padding='''longest'''			,				return_tensors='''np'''			)[input_name]
												_a      :       Optional[Any]   =						feat_extract.pad(_a			,				padding='''longest'''			,				return_tensors='''pt'''			)[input_name]

												self.assertTrue(abs(input_np.astype(np.floataa			).sum() - input_pt.numpy().astype(np.floataa			).sum()			) < 1e-2			)


							def 							__lowercase							(     self			)       ->       Dict:
												_a      :       int   =						self.feat_extract_dict
												_a      :       List[str]   =						True
												_a      :       Union[str, Any]   =						self.feature_extraction_class(**_a			)
												_a      :       Any   =						self.feat_extract_tester.prepare_inputs_for_target()
												_a      :       List[str]   =						[len(_a			) for x in speech_inputs]
												_a      :       int   =						feat_extract.model_input_names[0]

												_a      :       List[str]   =						BatchFeature({input_name: speech_inputs}			)

												_a      :       Union[str, Any]   =						feat_extract.num_mel_bins  # hack!

												_a      :       List[Any]   =						feat_extract.pad(_a			,				padding='''longest'''			,				return_tensors='''np'''			)
												self.assertIn('''attention_mask'''			,				_a			)
												self.assertListEqual(list(processed.attention_mask.shape			)			,				list(processed[input_name].shape[:2]			)			)
												self.assertListEqual(processed.attention_mask.sum(-1			).tolist()			,				_a			)


							def 							__lowercase							(     self			)       ->       Any:
												_a      :       Tuple   =						self.feat_extract_dict
												_a      :       str   =						True
												_a      :       int   =						self.feature_extraction_class(**_a			)
												_a      :       Any   =						self.feat_extract_tester.prepare_inputs_for_target()
												_a      :       Dict   =						[len(_a			) for x in speech_inputs]
												_a      :       List[Any]   =						feat_extract.model_input_names[0]

												_a      :       Optional[Any]   =						BatchFeature({input_name: speech_inputs}			)
												_a      :       Union[str, Any]   =						min(_a			)

												_a      :       Union[str, Any]   =						feat_extract.num_mel_bins  # hack!

												_a      :       Any   =						feat_extract.pad(
												    _a			,				padding='''max_length'''			,				max_length=_a			,				truncation=_a			,				return_tensors='''np'''			)
												self.assertIn('''attention_mask'''			,				_a			)
												self.assertListEqual(
												    list(processed_pad.attention_mask.shape			)			,				[processed_pad[input_name].shape[0], max_length]			)
												self.assertListEqual(
												    processed_pad.attention_mask[:, :max_length].sum(-1			).tolist()			,				[max_length for x in speech_inputs]			)


							def 							__lowercase							(     self			,				_a			)       ->       List[str]:
												from datasets import load_dataset

												_a      :       List[Any]   =						load_dataset('''hf-internal-testing/librispeech_asr_dummy'''			,				'''clean'''			,				split='''validation'''			)
												# automatic decoding with librispeech
												_a      :       int   =						ds.sort('''id'''			).select(range(_a			)			)[:num_samples]["audio"]

												return [x["array"] for x in speech_samples]


							def 							__lowercase							(     self			)       ->       List[Any]:
												_a      :       Dict   =						torch.tensor(
												    [2.3_8_0_4e-0_3, 2.0_7_5_2e-0_3, 1.9_8_3_6e-0_3, 2.1_0_5_7e-0_3, 1.6_1_7_4e-0_3,
												     3.0_5_1_8e-0_4, 9.1_5_5_3e-0_5, 3.3_5_6_9e-0_4, 9.7_6_5_6e-0_4, 1.8_3_1_1e-0_3,
												     2.0_1_4_2e-0_3, 2.1_0_5_7e-0_3, 1.7_3_9_5e-0_3, 4.5_7_7_6e-0_4, -3.9_6_7_3e-0_4,
												     4.5_7_7_6e-0_4, 1.0_0_7_1e-0_3, 9.1_5_5_3e-0_5, 4.8_8_2_8e-0_4, 1.1_5_9_7e-0_3,
												     7.3_2_4_2e-0_4, 9.4_6_0_4e-0_4, 1.8_0_0_5e-0_3, 1.8_3_1_1e-0_3, 8.8_5_0_1e-0_4,
												     4.2_7_2_5e-0_4, 4.8_8_2_8e-0_4, 7.3_2_4_2e-0_4, 1.0_9_8_6e-0_3, 2.1_0_5_7e-0_3]			)
												# fmt: on

												_a      :       Dict   =						self._load_datasamples(1			)
												_a      :       Union[str, Any]   =						SpeechTaFeatureExtractor()
												_a      :       Any   =						feature_extractor(_a			,				return_tensors='''pt'''			).input_values
												self.assertEquals(input_values.shape			,				(1, 9_3_6_8_0)			)
												self.assertTrue(torch.allclose(input_values[0, :3_0]			,				_a			,				atol=1e-6			)			)




							def 							__lowercase							(     self			)       ->       Optional[int]:
												_a      :       Tuple   =						torch.tensor(
												    [-2.6870, -3.0104, -3.1356, -3.5352, -3.0044, -3.0353, -3.4719, -3.6777,
												     -3.1520, -2.9435, -2.6553, -2.8795, -2.9944, -2.5921, -3.0279, -3.0386,
												     -3.0864, -3.1291, -3.2353, -2.7444, -2.6831, -2.7287, -3.1761, -3.1571,
												     -3.2726, -3.0582, -3.1007, -3.4533, -3.4695, -3.0998]			)
												# fmt: on

												_a      :       Optional[Any]   =						self._load_datasamples(1			)
												_a      :       Optional[int]   =						SpeechTaFeatureExtractor()
												_a      :       int   =						feature_extractor(audio_target=_a			,				return_tensors='''pt'''			).input_values
												self.assertEquals(input_values.shape			,				(1, 3_6_6, 8_0)			)
												self.assertTrue(torch.allclose(input_values[0, 0, :3_0]			,				_a			,				atol=1e-4			)			)










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())))

