






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


UpperCAmelCase_     :				Any         =				random.Random()



def       _A    (__a					,       __a=1.0					,       __a=None					,       __a=None							)				-> Any:
    """simple docstring"""






    if rng is None:
        SCREAMING_SNAKE_CASE_   :						List[Any]							=	global_rng

    SCREAMING_SNAKE_CASE_   :						int							=	[]
    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 							lowerCAmelCase__       (    unittest.TestCase				):






      '''simple docstring'''

      def __init__(		self  :						Tuple		,			lowercase_  :						Optional[Any]		,			lowercase_  :						List[Any]=7		,			lowercase_  :						List[str]=400		,			lowercase_  :						Any=2000		,			lowercase_  :						Union[str, Any]=1		,			lowercase_  :						str=0.0		,			lowercase_  :						Union[str, Any]=16000		,			lowercase_  :						Union[str, Any]=True		,			lowercase_  :						List[str]=80		,			lowercase_  :						Dict=16		,			lowercase_  :						Optional[Any]=64		,			lowercase_  :						Optional[Any]="hann_window"		,			lowercase_  :						Any=80		,			lowercase_  :						Optional[int]=7600		,			lowercase_  :						List[str]=1e-10		,			lowercase_  :						List[Any]=True		,			):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[Any]							=	parent
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	batch_size
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	min_seq_length
          SCREAMING_SNAKE_CASE_   :						List[str]							=	max_seq_length
          SCREAMING_SNAKE_CASE_   :						Any							=	(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
          SCREAMING_SNAKE_CASE_   :						Any							=	feature_size
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	padding_value
          SCREAMING_SNAKE_CASE_   :						str							=	sampling_rate
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	do_normalize
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	num_mel_bins
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	hop_length
          SCREAMING_SNAKE_CASE_   :						str							=	win_length
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	win_function
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	fmin
          SCREAMING_SNAKE_CASE_   :						Any							=	fmax
          SCREAMING_SNAKE_CASE_   :						List[str]							=	mel_floor
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	return_attention_mask
      def _SCREAMING_SNAKE_CASE				(		self  :						List[Any]):




          '''simple docstring'''


          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 _SCREAMING_SNAKE_CASE				(		self  :						List[Any]		,			lowercase_  :						str=False		,			lowercase_  :						List[str]=False):




          '''simple docstring'''


          def _flatten(lowercase_  :						Union[str, Any]):
              return list(itertools.chain(*lowercase_))

          if equal_length:
              SCREAMING_SNAKE_CASE_   :						Any							=	floats_list((self.batch_size, self.max_seq_length))
          else:
              # make sure that inputs increase in size
              SCREAMING_SNAKE_CASE_   :						List[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:
              SCREAMING_SNAKE_CASE_   :						Optional[int]							=	[np.asarray(lowercase_) for x in speech_inputs]

          return speech_inputs



      def _SCREAMING_SNAKE_CASE				(		self  :						Any		,			lowercase_  :						Optional[int]=False		,			lowercase_  :						Any=False):




          '''simple docstring'''


          if equal_length:
              SCREAMING_SNAKE_CASE_   :						Any							=	[floats_list((self.max_seq_length, self.num_mel_bins)) for _ in range(self.batch_size)]
          else:
              # make sure that inputs increase in size
              SCREAMING_SNAKE_CASE_   :						Tuple							=	[
                  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:
              SCREAMING_SNAKE_CASE_   :						int							=	[np.asarray(lowercase_) for x in speech_inputs]

          return speech_inputs




@require_torch
class 							lowerCAmelCase__       (    UpperCAmelCase__       ,	unittest.TestCase				):






      '''simple docstring'''

      __UpperCamelCase							=						SpeechTaFeatureExtractor
      def _SCREAMING_SNAKE_CASE				(		self  :						Optional[int]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[Any]							=	SpeechTaFeatureExtractionTester(self)
      def _SCREAMING_SNAKE_CASE				(		self  :						Optional[Any]		,			lowercase_  :						int):




          '''simple docstring'''


          self.assertTrue(np.all(np.mean(lowercase_		,			axis=0) < 1e-3))
          self.assertTrue(np.all(np.abs(np.var(lowercase_		,			axis=0) - 1) < 1e-3))
      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[str]							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          # create three inputs of length 800, 1000, and 1200
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]
          SCREAMING_SNAKE_CASE_   :						List[str]							=	[np.asarray(lowercase_) for speech_input in speech_inputs]

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

          # Test batched
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	feat_extract(lowercase_		,			return_tensors='''np''').input_values
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	feat_extract(lowercase_		,			return_tensors='''np''').input_values
          for enc_seq_a, enc_seq_a in zip(lowercase_		,			lowercase_):
              self.assertTrue(np.allclose(lowercase_		,			lowercase_		,			atol=1e-3))
      def _SCREAMING_SNAKE_CASE				(		self  :						Dict):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Dict							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          SCREAMING_SNAKE_CASE_   :						Dict							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]

          SCREAMING_SNAKE_CASE_   :						Tuple							=	['''longest''', '''max_length''', '''do_not_pad''']
          SCREAMING_SNAKE_CASE_   :						List[str]							=	[None, 1600, None]
          for max_length, padding in zip(lowercase_		,			lowercase_):
              SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	feat_extract(lowercase_		,			padding=lowercase_		,			max_length=lowercase_		,			return_tensors='''np''')
              SCREAMING_SNAKE_CASE_   :						List[Any]							=	processed.input_values

              self._check_zero_mean_unit_variance(input_values[0][:800])
              self.assertTrue(input_values[0][800:].sum() < 1e-6)
              self._check_zero_mean_unit_variance(input_values[1][:1000])
              self.assertTrue(input_values[0][1000:].sum() < 1e-6)
              self._check_zero_mean_unit_variance(input_values[2][:1200])
      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Dict							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          SCREAMING_SNAKE_CASE_   :						str							=	range(800		,			1400		,			200)
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	[floats_list((1, x))[0] for x in lengths]

          SCREAMING_SNAKE_CASE_   :						Tuple							=	['''longest''', '''max_length''', '''do_not_pad''']
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	[None, 1600, None]

          for max_length, padding in zip(lowercase_		,			lowercase_):
              SCREAMING_SNAKE_CASE_   :						str							=	feat_extract(lowercase_		,			max_length=lowercase_		,			padding=lowercase_)
              SCREAMING_SNAKE_CASE_   :						List[Any]							=	processed.input_values

              self._check_zero_mean_unit_variance(input_values[0][:800])
              self._check_zero_mean_unit_variance(input_values[1][:1000])
              self._check_zero_mean_unit_variance(input_values[2][:1200])
      def _SCREAMING_SNAKE_CASE				(		self  :						str):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Dict							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          SCREAMING_SNAKE_CASE_   :						List[str]							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]
          SCREAMING_SNAKE_CASE_   :						List[str]							=	feat_extract(
              lowercase_		,			truncation=lowercase_		,			max_length=1000		,			padding='''max_length'''		,			return_tensors='''np''')
          SCREAMING_SNAKE_CASE_   :						Any							=	processed.input_values

          self._check_zero_mean_unit_variance(input_values[0, :800])
          self._check_zero_mean_unit_variance(input_values[1])
          self._check_zero_mean_unit_variance(input_values[2])
      def _SCREAMING_SNAKE_CASE				(		self  :						List[Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]
          SCREAMING_SNAKE_CASE_   :						Any							=	feat_extract(
              lowercase_		,			truncation=lowercase_		,			max_length=1000		,			padding='''longest'''		,			return_tensors='''np''')
          SCREAMING_SNAKE_CASE_   :						str							=	processed.input_values

          self._check_zero_mean_unit_variance(input_values[0, :800])
          self._check_zero_mean_unit_variance(input_values[1, :1000])
          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, 1000))

          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]
          SCREAMING_SNAKE_CASE_   :						int							=	feat_extract(
              lowercase_		,			truncation=lowercase_		,			max_length=2000		,			padding='''longest'''		,			return_tensors='''np''')
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	processed.input_values

          self._check_zero_mean_unit_variance(input_values[0, :800])
          self._check_zero_mean_unit_variance(input_values[1, :1000])
          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, 1200))
      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[str]							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	np.random.rand(100).astype(np.floataa)
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	np_speech_inputs.tolist()

          for inputs in [py_speech_inputs, np_speech_inputs]:
              SCREAMING_SNAKE_CASE_   :						Optional[int]							=	feature_extractor.pad([{'''input_values''': inputs}]		,			return_tensors='''np''')
              self.assertTrue(np_processed.input_values.dtype == np.floataa)
              SCREAMING_SNAKE_CASE_   :						Optional[int]							=	feature_extractor.pad([{'''input_values''': inputs}]		,			return_tensors='''pt''')
              self.assertTrue(pt_processed.input_values.dtype == torch.floataa)
      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						int							=	self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
          # create three inputs of length 800, 1000, and 1200
          SCREAMING_SNAKE_CASE_   :						str							=	[floats_list((1, x))[0] for x in range(800		,			1400		,			200)]
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	[np.asarray(lowercase_) for speech_input in speech_inputs]

          # Test feature size
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	feature_extractor(audio_target=lowercase_		,			padding=lowercase_		,			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
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	feature_extractor(speech_inputs[0]		,			return_tensors='''np''').input_values
          SCREAMING_SNAKE_CASE_   :						List[str]							=	feature_extractor(np_speech_inputs[0]		,			return_tensors='''np''').input_values
          self.assertTrue(np.allclose(lowercase_		,			lowercase_		,			atol=1e-3))

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

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




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	self.feat_extract_tester.prepare_inputs_for_target()
          SCREAMING_SNAKE_CASE_   :						Any							=	self.feature_extraction_class(**self.feat_extract_dict)
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	feat_extract.model_input_names[0]

          SCREAMING_SNAKE_CASE_   :						List[Any]							=	BatchFeature({input_name: speech_inputs})

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

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

          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	processed_features[input_name]

          if len(batch_features_input.shape) < 3:
              SCREAMING_SNAKE_CASE_   :						Tuple							=	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 _SCREAMING_SNAKE_CASE				(		self  :						List[str]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	self.feat_extract_tester.prepare_inputs_for_target(equal_length=lowercase_)
          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	self.feature_extraction_class(**self.feat_extract_dict)
          SCREAMING_SNAKE_CASE_   :						Dict							=	feat_extract.model_input_names[0]

          SCREAMING_SNAKE_CASE_   :						Dict							=	BatchFeature({input_name: speech_inputs}		,			tensor_type='''pt''')

          SCREAMING_SNAKE_CASE_   :						str							=	processed_features[input_name]

          if len(batch_features_input.shape) < 3:
              SCREAMING_SNAKE_CASE_   :						List[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 _SCREAMING_SNAKE_CASE				(		self  :						int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[Any]							=	self.feature_extraction_class(**self.feat_extract_dict)
          SCREAMING_SNAKE_CASE_   :						str							=	self.feat_extract_tester.prepare_inputs_for_target()
          SCREAMING_SNAKE_CASE_   :						Any							=	feat_extract.model_input_names[0]

          SCREAMING_SNAKE_CASE_   :						int							=	BatchFeature({input_name: speech_inputs})

          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	feat_extract.num_mel_bins  # hack!

          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	feat_extract.pad(lowercase_		,			padding='''longest'''		,			return_tensors='''np''')[input_name]
          SCREAMING_SNAKE_CASE_   :						int							=	feat_extract.pad(lowercase_		,			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 _SCREAMING_SNAKE_CASE				(		self  :						Optional[Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						str							=	self.feat_extract_dict
          SCREAMING_SNAKE_CASE_   :						int							=	True
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	self.feature_extraction_class(**lowercase_)
          SCREAMING_SNAKE_CASE_   :						Any							=	self.feat_extract_tester.prepare_inputs_for_target()
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	[len(lowercase_) for x in speech_inputs]
          SCREAMING_SNAKE_CASE_   :						str							=	feat_extract.model_input_names[0]

          SCREAMING_SNAKE_CASE_   :						Dict							=	BatchFeature({input_name: speech_inputs})

          SCREAMING_SNAKE_CASE_   :						Dict							=	feat_extract.num_mel_bins  # hack!

          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	feat_extract.pad(lowercase_		,			padding='''longest'''		,			return_tensors='''np''')
          self.assertIn('''attention_mask'''		,			lowercase_)
          self.assertListEqual(list(processed.attention_mask.shape)		,			list(processed[input_name].shape[:2]))
          self.assertListEqual(processed.attention_mask.sum(-1).tolist()		,			lowercase_)
      def _SCREAMING_SNAKE_CASE				(		self  :						int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						List[Any]							=	self.feat_extract_dict
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	True
          SCREAMING_SNAKE_CASE_   :						int							=	self.feature_extraction_class(**lowercase_)
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	self.feat_extract_tester.prepare_inputs_for_target()
          SCREAMING_SNAKE_CASE_   :						List[str]							=	[len(lowercase_) for x in speech_inputs]
          SCREAMING_SNAKE_CASE_   :						List[str]							=	feat_extract.model_input_names[0]

          SCREAMING_SNAKE_CASE_   :						int							=	BatchFeature({input_name: speech_inputs})
          SCREAMING_SNAKE_CASE_   :						Optional[Any]							=	min(lowercase_)

          SCREAMING_SNAKE_CASE_   :						Tuple							=	feat_extract.num_mel_bins  # hack!

          SCREAMING_SNAKE_CASE_   :						str							=	feat_extract.pad(
              lowercase_		,			padding='''max_length'''		,			max_length=lowercase_		,			truncation=lowercase_		,			return_tensors='''np''')
          self.assertIn('''attention_mask'''		,			lowercase_)
          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 _SCREAMING_SNAKE_CASE				(		self  :						Dict		,			lowercase_  :						Optional[Any]):




          '''simple docstring'''


          from datasets import load_dataset

          SCREAMING_SNAKE_CASE_   :						str							=	load_dataset('''hf-internal-testing/librispeech_asr_dummy'''		,			'''clean'''		,			split='''validation''')
          # automatic decoding with librispeech
          SCREAMING_SNAKE_CASE_   :						str							=	ds.sort('''id''').select(range(lowercase_))[:num_samples]['''audio''']

          return [x["array"] for x in speech_samples]
      def _SCREAMING_SNAKE_CASE				(		self  :						Tuple):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Optional[int]							=	torch.tensor(
              [2.3_804e-03, 2.0_752e-03, 1.9_836e-03, 2.1_057e-03, 1.6_174e-03,
               3.0_518e-04, 9.1_553e-05, 3.3_569e-04, 9.7_656e-04, 1.8_311e-03,
               2.0_142e-03, 2.1_057e-03, 1.7_395e-03, 4.5_776e-04, -3.9_673e-04,
               4.5_776e-04, 1.0_071e-03, 9.1_553e-05, 4.8_828e-04, 1.1_597e-03,
               7.3_242e-04, 9.4_604e-04, 1.8_005e-03, 1.8_311e-03, 8.8_501e-04,
               4.2_725e-04, 4.8_828e-04, 7.3_242e-04, 1.0_986e-03, 2.1_057e-03])
          # fmt: on

          SCREAMING_SNAKE_CASE_   :						str							=	self._load_datasamples(1)
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	SpeechTaFeatureExtractor()
          SCREAMING_SNAKE_CASE_   :						List[Any]							=	feature_extractor(lowercase_		,			return_tensors='''pt''').input_values
          self.assertEquals(input_values.shape		,			(1, 93680))
          self.assertTrue(torch.allclose(input_values[0, :30]		,			lowercase_		,			atol=1e-6))



      def _SCREAMING_SNAKE_CASE				(		self  :						Union[str, Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_   :						Dict							=	torch.tensor(
              [-2.68_70, -3.01_04, -3.13_56, -3.53_52, -3.00_44, -3.03_53, -3.47_19, -3.67_77,
               -3.15_20, -2.94_35, -2.65_53, -2.87_95, -2.99_44, -2.59_21, -3.02_79, -3.03_86,
               -3.08_64, -3.12_91, -3.23_53, -2.74_44, -2.68_31, -2.72_87, -3.17_61, -3.15_71,
               -3.27_26, -3.05_82, -3.10_07, -3.45_33, -3.46_95, -3.09_98])
          # fmt: on

          SCREAMING_SNAKE_CASE_   :						List[str]							=	self._load_datasamples(1)
          SCREAMING_SNAKE_CASE_   :						Union[str, Any]							=	SpeechTaFeatureExtractor()
          SCREAMING_SNAKE_CASE_   :						Tuple							=	feature_extractor(audio_target=lowercase_		,			return_tensors='''pt''').input_values
          self.assertEquals(input_values.shape		,			(1, 366, 80))
          self.assertTrue(torch.allclose(input_values[0, 0, :30]		,			lowercase_		,			atol=1e-4))










"""simple docstring"""






# Algorithm for the pigeonhole sorting





def       _A    (__a							)				-> Dict:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_   :						Dict							=	min(__a							)  # min() finds the minimum value
    SCREAMING_SNAKE_CASE_   :						int							=	max(__a							)  # max() finds the maximum value

    SCREAMING_SNAKE_CASE_   :						Dict							=	max_val - min_val + 1  # size is difference of max and min values plus one

    # list of pigeonholes of size equal to the variable size
    SCREAMING_SNAKE_CASE_   :						Any							=	[0] * size

    # Populate the pigeonholes.
    for x in a:
        assert isinstance(__a					,       __a							), "integers only please"
        holes[x - min_val] += 1

    # Putting the elements back into the array in an order.
    SCREAMING_SNAKE_CASE_   :						Any							=	0
    for count in range(__a							):
        while holes[count] > 0:
            holes[count] -= 1
            SCREAMING_SNAKE_CASE_   :						Dict							=	count + min_val
            i += 1



def       _A    ()				-> Optional[int]:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_   :						List[str]							=	[8, 3, 2, 7, 4, 6, 8]
    pigeonhole_sort(__a							)
    print('''Sorted order is:'''					,       ''' '''.join(__a							)							)


if __name__ == "__main__":
  main()


