





'''simple docstring'''

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


lowercase__		:     Optional[int]			=							random.Random()







def    a__							(							lowercase   :	Optional[int],   lowercase   :	List[Any]=1.0,   lowercase   :	Dict=None,   lowercase   :	Optional[Any]=None )						->						List[str]:





     """simple docstring"""

     if rng is None:
          _UpperCamelCase							       =			global_rng

     _UpperCamelCase							       =			[]
     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			,					lowerCAmelCase__  :						Optional[int]			,					lowerCAmelCase__  :						Tuple=7			,					lowerCAmelCase__  :						List[str]=400			,					lowerCAmelCase__  :						str=2000			,					lowerCAmelCase__  :						List[Any]=1			,					lowerCAmelCase__  :						Dict=0.0			,					lowerCAmelCase__  :						Optional[int]=16000			,					lowerCAmelCase__  :						Any=True			,					lowerCAmelCase__  :						int=80			,					lowerCAmelCase__  :						Union[str, Any]=16			,					lowerCAmelCase__  :						Optional[Any]=64			,					lowerCAmelCase__  :						Union[str, Any]="hann_window"			,					lowerCAmelCase__  :						List[str]=80			,					lowerCAmelCase__  :						Union[str, Any]=7600			,					lowerCAmelCase__  :						List[Any]=1e-1_0			,					lowerCAmelCase__  :						List[Any]=True			,					)       ->	Dict:

            '''simple docstring'''




            _UpperCamelCase							       =			parent
            _UpperCamelCase							       =			batch_size
            _UpperCamelCase							       =			min_seq_length
            _UpperCamelCase							       =			max_seq_length
            _UpperCamelCase							       =			(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
            _UpperCamelCase							       =			feature_size
            _UpperCamelCase							       =			padding_value
            _UpperCamelCase							       =			sampling_rate
            _UpperCamelCase							       =			do_normalize
            _UpperCamelCase							       =			num_mel_bins
            _UpperCamelCase							       =			hop_length
            _UpperCamelCase							       =			win_length
            _UpperCamelCase							       =			win_function
            _UpperCamelCase							       =			fmin
            _UpperCamelCase							       =			fmax
            _UpperCamelCase							       =			mel_floor
            _UpperCamelCase							       =			return_attention_mask





       def snake_case__		(				self  :						List[Any]	)       ->	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 snake_case__		(				self  :						Optional[int]			,					lowerCAmelCase__  :						Optional[int]=False			,					lowerCAmelCase__  :						Optional[int]=False	)       ->	List[str]:

            '''simple docstring'''




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

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

            return speech_inputs







       def snake_case__		(				self  :						str			,					lowerCAmelCase__  :						str=False			,					lowerCAmelCase__  :						Union[str, Any]=False	)       ->	Any:

            '''simple docstring'''




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

            return speech_inputs

@require_torch
class 							__lowerCAmelCase	(       __magic_name__		,		unittest.TestCase					):






       """simple docstring"""
       _snake_case      :	str									=       SpeechTaFeatureExtractor





       def snake_case__		(				self  :						str	)       ->	str:

            '''simple docstring'''




            _UpperCamelCase							       =			SpeechTaFeatureExtractionTester(self	)





       def snake_case__		(				self  :						List[Any]			,					lowerCAmelCase__  :						Optional[Any]	)       ->	str:

            '''simple docstring'''




            self.assertTrue(np.all(np.mean(lowerCAmelCase__			,					axis=0	) < 1e-3	)	)
            self.assertTrue(np.all(np.abs(np.var(lowerCAmelCase__			,					axis=0	) - 1	) < 1e-3	)	)





       def snake_case__		(				self  :						int	)       ->	Optional[int]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()	)
            # create three inputs of length 800, 1000, and 1200
            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in range(800			,					1400			,					200	)]
            _UpperCamelCase							       =			[np.asarray(lowerCAmelCase__	) for speech_input in speech_inputs]

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

            # Test batched
            _UpperCamelCase							       =			feat_extract(lowerCAmelCase__			,					return_tensors='''np'''	).input_values
            _UpperCamelCase							       =			feat_extract(lowerCAmelCase__			,					return_tensors='''np'''	).input_values
            for enc_seq_a, enc_seq_a in zip(lowerCAmelCase__			,					lowerCAmelCase__	):
                 self.assertTrue(np.allclose(lowerCAmelCase__			,					lowerCAmelCase__			,					atol=1e-3	)	)





       def snake_case__		(				self  :						Tuple	)       ->	Optional[Any]:

            '''simple docstring'''




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

            _UpperCamelCase							       =			['''longest''', '''max_length''', '''do_not_pad''']
            _UpperCamelCase							       =			[None, 1600, None]
            for max_length, padding in zip(lowerCAmelCase__			,					lowerCAmelCase__	):
                 _UpperCamelCase							       =			feat_extract(lowerCAmelCase__			,					padding=lowerCAmelCase__			,					max_length=lowerCAmelCase__			,					return_tensors='''np'''	)
                 _UpperCamelCase							       =			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 snake_case__		(				self  :						Dict	)       ->	Optional[Any]:

            '''simple docstring'''




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

            _UpperCamelCase							       =			['''longest''', '''max_length''', '''do_not_pad''']
            _UpperCamelCase							       =			[None, 1600, None]

            for max_length, padding in zip(lowerCAmelCase__			,					lowerCAmelCase__	):
                 _UpperCamelCase							       =			feat_extract(lowerCAmelCase__			,					max_length=lowerCAmelCase__			,					padding=lowerCAmelCase__	)
                 _UpperCamelCase							       =			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 snake_case__		(				self  :						str	)       ->	Optional[int]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()	)
            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in range(800			,					1400			,					200	)]
            _UpperCamelCase							       =			feat_extract(
                lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=1000			,					padding='''max_length'''			,					return_tensors='''np'''	)
            _UpperCamelCase							       =			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 snake_case__		(				self  :						Any	)       ->	Tuple:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()	)
            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in range(800			,					1400			,					200	)]
            _UpperCamelCase							       =			feat_extract(
                lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=1000			,					padding='''longest'''			,					return_tensors='''np'''	)
            _UpperCamelCase							       =			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)	)

            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in range(800			,					1400			,					200	)]
            _UpperCamelCase							       =			feat_extract(
                lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=2000			,					padding='''longest'''			,					return_tensors='''np'''	)
            _UpperCamelCase							       =			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 snake_case__		(				self  :						Optional[int]	)       ->	List[str]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()	)
            _UpperCamelCase							       =			np.random.rand(100	).astype(np.floataa	)
            _UpperCamelCase							       =			np_speech_inputs.tolist()

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





       def snake_case__		(				self  :						str	)       ->	str:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()	)
            # create three inputs of length 800, 1000, and 1200
            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in range(800			,					1400			,					200	)]
            _UpperCamelCase							       =			[np.asarray(lowerCAmelCase__	) for speech_input in speech_inputs]

            # Test feature size
            _UpperCamelCase							       =			feature_extractor(audio_target=lowerCAmelCase__			,					padding=lowerCAmelCase__			,					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
            _UpperCamelCase							       =			feature_extractor(speech_inputs[0]			,					return_tensors='''np'''	).input_values
            _UpperCamelCase							       =			feature_extractor(np_speech_inputs[0]			,					return_tensors='''np'''	).input_values
            self.assertTrue(np.allclose(lowerCAmelCase__			,					lowerCAmelCase__			,					atol=1e-3	)	)

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

            # Test 2-D numpy arrays are batched.
            _UpperCamelCase							       =			[floats_list((1, x)	)[0] for x in (800, 800, 800)]
            _UpperCamelCase							       =			np.asarray(lowerCAmelCase__	)
            _UpperCamelCase							       =			feature_extractor(lowerCAmelCase__			,					return_tensors='''np'''	).input_values
            _UpperCamelCase							       =			feature_extractor(lowerCAmelCase__			,					return_tensors='''np'''	).input_values
            for enc_seq_a, enc_seq_a in zip(lowerCAmelCase__			,					lowerCAmelCase__	):
                 self.assertTrue(np.allclose(lowerCAmelCase__			,					lowerCAmelCase__			,					atol=1e-3	)	)





       def snake_case__		(				self  :						str	)       ->	Optional[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target()
            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_dict	)
            _UpperCamelCase							       =			feat_extract.model_input_names[0]

            _UpperCamelCase							       =			BatchFeature({input_name: speech_inputs}	)

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

            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target(equal_length=lowerCAmelCase__	)
            _UpperCamelCase							       =			BatchFeature({input_name: speech_inputs}			,					tensor_type='''np'''	)

            _UpperCamelCase							       =			processed_features[input_name]

            if len(batch_features_input.shape	) < 3:
                 _UpperCamelCase							       =			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 snake_case__		(				self  :						List[Any]	)       ->	Any:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target(equal_length=lowerCAmelCase__	)
            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_dict	)
            _UpperCamelCase							       =			feat_extract.model_input_names[0]

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

            _UpperCamelCase							       =			processed_features[input_name]

            if len(batch_features_input.shape	) < 3:
                 _UpperCamelCase							       =			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 snake_case__		(				self  :						int	)       ->	Any:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feature_extraction_class(**self.feat_extract_dict	)
            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target()
            _UpperCamelCase							       =			feat_extract.model_input_names[0]

            _UpperCamelCase							       =			BatchFeature({input_name: speech_inputs}	)

            _UpperCamelCase							       =			feat_extract.num_mel_bins  # hack!

            _UpperCamelCase							       =			feat_extract.pad(lowerCAmelCase__			,					padding='''longest'''			,					return_tensors='''np'''	)[input_name]
            _UpperCamelCase							       =			feat_extract.pad(lowerCAmelCase__			,					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 snake_case__		(				self  :						Optional[int]	)       ->	List[str]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feat_extract_dict
            _UpperCamelCase							       =			True
            _UpperCamelCase							       =			self.feature_extraction_class(**lowerCAmelCase__	)
            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target()
            _UpperCamelCase							       =			[len(lowerCAmelCase__	) for x in speech_inputs]
            _UpperCamelCase							       =			feat_extract.model_input_names[0]

            _UpperCamelCase							       =			BatchFeature({input_name: speech_inputs}	)

            _UpperCamelCase							       =			feat_extract.num_mel_bins  # hack!

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





       def snake_case__		(				self  :						str	)       ->	List[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.feat_extract_dict
            _UpperCamelCase							       =			True
            _UpperCamelCase							       =			self.feature_extraction_class(**lowerCAmelCase__	)
            _UpperCamelCase							       =			self.feat_extract_tester.prepare_inputs_for_target()
            _UpperCamelCase							       =			[len(lowerCAmelCase__	) for x in speech_inputs]
            _UpperCamelCase							       =			feat_extract.model_input_names[0]

            _UpperCamelCase							       =			BatchFeature({input_name: speech_inputs}	)
            _UpperCamelCase							       =			min(lowerCAmelCase__	)

            _UpperCamelCase							       =			feat_extract.num_mel_bins  # hack!

            _UpperCamelCase							       =			feat_extract.pad(
                lowerCAmelCase__			,					padding='''max_length'''			,					max_length=lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					return_tensors='''np'''	)
            self.assertIn('''attention_mask'''			,					lowerCAmelCase__	)
            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 snake_case__		(				self  :						Dict			,					lowerCAmelCase__  :						Tuple	)       ->	List[str]:

            '''simple docstring'''




            from datasets import load_dataset

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

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





       def snake_case__		(				self  :						List[str]	)       ->	Dict:

            '''simple docstring'''




            _UpperCamelCase							       =			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

            _UpperCamelCase							       =			self._load_datasamples(1	)
            _UpperCamelCase							       =			SpeechTaFeatureExtractor()
            _UpperCamelCase							       =			feature_extractor(lowerCAmelCase__			,					return_tensors='''pt'''	).input_values
            self.assertEquals(input_values.shape			,					(1, 93680)	)
            self.assertTrue(torch.allclose(input_values[0, :30]			,					lowerCAmelCase__			,					atol=1e-6	)	)







       def snake_case__		(				self  :						Union[str, Any]	)       ->	Tuple:

            '''simple docstring'''




            _UpperCamelCase							       =			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

            _UpperCamelCase							       =			self._load_datasamples(1	)
            _UpperCamelCase							       =			SpeechTaFeatureExtractor()
            _UpperCamelCase							       =			feature_extractor(audio_target=lowerCAmelCase__			,					return_tensors='''pt'''	).input_values
            self.assertEquals(input_values.shape			,					(1, 366, 80)	)
            self.assertTrue(torch.allclose(input_values[0, 0, :30]			,					lowerCAmelCase__			,					atol=1e-4	)	)








'''simple docstring'''

from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


SCREAMING_SNAKE_CASE__     :						Union[str, Any]	=  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__     :						Union[str, Any]	=  {
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}

class 							a__( snake_case__     ):
			a_	: int									=      '''efficientnet'''






			def __init__(     self					,   _UpperCAmelCase = 3					,   _UpperCAmelCase = 600					,   _UpperCAmelCase = 2.0					,   _UpperCAmelCase = 3.1					,   _UpperCAmelCase = 8					,   _UpperCAmelCase = [3, 3, 5, 3, 5, 5, 3]					,   _UpperCAmelCase = [32, 16, 24, 40, 80, 112, 192]					,   _UpperCAmelCase = [16, 24, 40, 80, 112, 192, 320]					,   _UpperCAmelCase = []					,   _UpperCAmelCase = [1, 2, 2, 2, 1, 2, 1]					,   _UpperCAmelCase = [1, 2, 2, 3, 3, 4, 1]					,   _UpperCAmelCase = [1, 6, 6, 6, 6, 6, 6]					,   _UpperCAmelCase = 0.25					,   _UpperCAmelCase = "swish"					,   _UpperCAmelCase = 2560					,   _UpperCAmelCase = "mean"					,   _UpperCAmelCase = 0.02					,   _UpperCAmelCase = 0.001					,   _UpperCAmelCase = 0.99					,   _UpperCAmelCase = 0.5					,   _UpperCAmelCase = 0.2					,   **_UpperCAmelCase					,   )							->							Dict:
					super().__init__(**_UpperCAmelCase						)

					snake_case__	     =num_channels
					snake_case__	     =image_size
					snake_case__	     =width_coefficient
					snake_case__	     =depth_coefficient
					snake_case__	     =depth_divisor
					snake_case__	     =kernel_sizes
					snake_case__	     =in_channels
					snake_case__	     =out_channels
					snake_case__	     =depthwise_padding
					snake_case__	     =strides
					snake_case__	     =num_block_repeats
					snake_case__	     =expand_ratios
					snake_case__	     =squeeze_expansion_ratio
					snake_case__	     =hidden_act
					snake_case__	     =hidden_dim
					snake_case__	     =pooling_type
					snake_case__	     =initializer_range
					snake_case__	     =batch_norm_eps
					snake_case__	     =batch_norm_momentum
					snake_case__	     =dropout_rate
					snake_case__	     =drop_connect_rate
					snake_case__	     =sum(_UpperCAmelCase						) * 4





class 							a__( snake_case__     ):
			a_	: List[str]									=      version.parse('''1.11'''     )






			@property
			def 						_lowercase  (     self						)							->							Mapping[str, Mapping[int, str]]:
					return OrderedDict(
					    [
					        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
					    ]						)






			@property
			def 						_lowercase  (     self						)							->							float:
					return 1E-5




