

import unittest

from transformers import BigBirdTokenizer, BigBirdTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


_UpperCamelCase 			=		"▁"

_UpperCamelCase 			=		get_tests_dir("fixtures/test_sentencepiece.model")







@require_sentencepiece
@require_tokenizers
class   __lowercase      (_UpperCAmelCase		,   unittest.TestCase ):
 _UpperCamelCase			  =  BigBirdTokenizer
 _UpperCamelCase			  =  BigBirdTokenizerFast
 _UpperCamelCase			  =  True
 _UpperCamelCase			  =  True
 def 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





       super().setUp()

       __lowerCAmelCase					:						Union[str, Any]					=					self.tokenizer_class(A_      ,							keep_accents=A_					)
       tokenizer.save_pretrained(self.tmpdirname					)
 def 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





       __lowerCAmelCase					:						Union[str, Any]					=					'''<s>'''
       __lowerCAmelCase					:						Tuple					=					1

       self.assertEqual(self.get_tokenizer()._convert_token_to_id(A_					)      ,							A_					)
       self.assertEqual(self.get_tokenizer()._convert_id_to_token(A_					)      ,							A_					)
 def 	UpperCamelCase__  (							self					)					->str:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					list(self.get_tokenizer().get_vocab().keys()					)

       self.assertEqual(vocab_keys[0]      ,							'''<unk>'''					)
       self.assertEqual(vocab_keys[1]      ,							'''<s>'''					)
       self.assertEqual(vocab_keys[-1]      ,							'''[MASK]'''					)
       self.assertEqual(len(A_					)      ,							1004					)
 def 	UpperCamelCase__  (							self					)					->Optional[Any]:



       '''simple docstring'''





       self.assertEqual(self.get_tokenizer().vocab_size      ,							1000					)
 def 	UpperCamelCase__  (							self					)					->Union[str, Any]:



       '''simple docstring'''





       if not self.test_rust_tokenizer:
             return

       __lowerCAmelCase					:						List[Any]					=					self.get_tokenizer()
       __lowerCAmelCase					:						Tuple					=					self.get_rust_tokenizer()

       __lowerCAmelCase					:						str					=					'''I was born in 92000, and this is falsé.'''

       __lowerCAmelCase					:						Union[str, Any]					=					tokenizer.tokenize(A_					)
       __lowerCAmelCase					:						List[str]					=					rust_tokenizer.tokenize(A_					)
       self.assertListEqual(A_      ,							A_					)

       __lowerCAmelCase					:						Tuple					=					tokenizer.encode(A_      ,							add_special_tokens=A_					)
       __lowerCAmelCase					:						Dict					=					rust_tokenizer.encode(A_      ,							add_special_tokens=A_					)
       self.assertListEqual(A_      ,							A_					)

       __lowerCAmelCase					:						Union[str, Any]					=					self.get_rust_tokenizer()
       __lowerCAmelCase					:						Tuple					=					tokenizer.encode(A_					)
       __lowerCAmelCase					:						Dict					=					rust_tokenizer.encode(A_					)
       self.assertListEqual(A_      ,							A_					)
 def 	UpperCamelCase__  (							self					)					->int:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					BigBirdTokenizer(A_      ,							keep_accents=A_					)

       __lowerCAmelCase					:						int					=					tokenizer.tokenize('''This is a test'''					)
       self.assertListEqual(A_      ,							['''▁This''', '''▁is''', '''▁a''', '''▁t''', '''est''']					)

       self.assertListEqual(
           tokenizer.convert_tokens_to_ids(A_					)      ,							[285, 46, 10, 170, 382]      ,							)

       __lowerCAmelCase					:						List[str]					=					tokenizer.tokenize('''I was born in 92000, and this is falsé.'''					)
       self.assertListEqual(
           A_      ,							[
               SPIECE_UNDERLINE + '''I''',
               SPIECE_UNDERLINE + '''was''',
               SPIECE_UNDERLINE + '''b''',
               '''or''',
               '''n''',
               SPIECE_UNDERLINE + '''in''',
               SPIECE_UNDERLINE + '''''',
               '''9''',
               '''2''',
               '''0''',
               '''0''',
               '''0''',
               ''',''',
               SPIECE_UNDERLINE + '''and''',
               SPIECE_UNDERLINE + '''this''',
               SPIECE_UNDERLINE + '''is''',
               SPIECE_UNDERLINE + '''f''',
               '''al''',
               '''s''',
               '''é''',
               '''.''',
           ]      ,							)
       __lowerCAmelCase					:						int					=					tokenizer.convert_tokens_to_ids(A_					)
       self.assertListEqual(
           A_      ,							[8, 21, 84, 55, 24, 19, 7, 0, 602, 347, 347, 347, 3, 12, 66, 46, 72, 80, 6, 0, 4]      ,							)

       __lowerCAmelCase					:						Optional[Any]					=					tokenizer.convert_ids_to_tokens(A_					)
       self.assertListEqual(
           A_      ,							[
               SPIECE_UNDERLINE + '''I''',
               SPIECE_UNDERLINE + '''was''',
               SPIECE_UNDERLINE + '''b''',
               '''or''',
               '''n''',
               SPIECE_UNDERLINE + '''in''',
               SPIECE_UNDERLINE + '''''',
               '''<unk>''',
               '''2''',
               '''0''',
               '''0''',
               '''0''',
               ''',''',
               SPIECE_UNDERLINE + '''and''',
               SPIECE_UNDERLINE + '''this''',
               SPIECE_UNDERLINE + '''is''',
               SPIECE_UNDERLINE + '''f''',
               '''al''',
               '''s''',
               '''<unk>''',
               '''.''',
           ]      ,							)
 @cached_property
 def 	UpperCamelCase__  (							self					)					->Union[str, Any]:



       '''simple docstring'''





       return BigBirdTokenizer.from_pretrained('''google/bigbird-roberta-base'''					)
 @slow
 def 	UpperCamelCase__  (							self					)					->List[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						List[str]					=					'''Hello World!'''
       __lowerCAmelCase					:						Optional[Any]					=					[65, 1_8536, 2260, 101, 66]

       self.assertListEqual(A_      ,							self.big_tokenizer.encode(A_					)					)
 @slow
 def 	UpperCamelCase__  (							self					)					->str:



       '''simple docstring'''





       __lowerCAmelCase					:						Optional[Any]					=					(
           '''This is a very long text with a lot of weird characters, such as: . , ~ ? ( ) " [ ] ! : - . Also we will'''
           ''' add words that should not exsist and be tokenized to <unk>, such as saoneuhaoesuth'''
       )
       # fmt: off
       __lowerCAmelCase					:						List[str]					=					[65, 871, 419, 358, 946, 991, 2521, 452, 358, 1357, 387, 7751, 3536, 112, 985, 456, 126, 865, 938, 5400, 5734, 458, 1368, 467, 786, 2462, 5246, 1159, 633, 865, 4519, 457, 582, 852, 2557, 427, 916, 508, 405, 3_4324, 497, 391, 408, 1_1342, 1244, 385, 100, 938, 985, 456, 574, 362, 1_2597, 3200, 3129, 1172, 66]  # noqa: E231
       # fmt: on
       self.assertListEqual(A_      ,							self.big_tokenizer.encode(A_					)					)
 @require_torch
 @slow
 def 	UpperCamelCase__  (							self					)					->List[str]:



       '''simple docstring'''





       import torch

       from transformers import BigBirdConfig, BigBirdModel

       # Build sequence
       __lowerCAmelCase					:						Optional[int]					=					list(self.big_tokenizer.get_vocab().keys()					)[:10]
       __lowerCAmelCase					:						Tuple					=					''' '''.join(A_					)
       __lowerCAmelCase					:						str					=					self.big_tokenizer.encode_plus(A_      ,							return_tensors='''pt'''      ,							return_token_type_ids=A_					)
       __lowerCAmelCase					:						Optional[int]					=					self.big_tokenizer.batch_encode_plus(
           [sequence + ''' ''' + sequence]      ,							return_tensors='''pt'''      ,							return_token_type_ids=A_					)

       __lowerCAmelCase					:						Tuple					=					BigBirdConfig(attention_type='''original_full'''					)
       __lowerCAmelCase					:						List[Any]					=					BigBirdModel(A_					)

       assert model.get_input_embeddings().weight.shape[0] >= self.big_tokenizer.vocab_size

       with torch.no_grad():
             model(**A_					)
             model(**A_					)
 @slow
 def 	UpperCamelCase__  (							self					)					->Any:



       '''simple docstring'''





       __lowerCAmelCase					:						str					=					BigBirdTokenizer.from_pretrained('''google/bigbird-roberta-base'''					)
       __lowerCAmelCase					:						Optional[Any]					=					tokenizer.decode(tokenizer('''Paris is the [MASK].'''					).input_ids					)

       self.assertTrue(decoded_text == '''[CLS] Paris is the[MASK].[SEP]'''					)





 @slow
 def 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					{'''input_ids''': [[65, 3_9286, 458, 3_6335, 2001, 456, 1_3073, 1_3266, 455, 113, 7746, 1741, 1_1157, 391, 1_3073, 1_3266, 455, 113, 3967, 3_5412, 113, 4936, 109, 3870, 2377, 113, 3_0084, 4_5720, 458, 134, 1_7496, 112, 503, 1_1672, 113, 118, 112, 5665, 1_3347, 3_8687, 112, 1496, 3_1389, 112, 3268, 4_7264, 134, 962, 112, 1_6377, 8035, 2_3130, 430, 1_2169, 1_5518, 2_8592, 458, 146, 4_1697, 109, 391, 1_2169, 1_5518, 1_6689, 458, 146, 4_1358, 109, 452, 726, 4034, 111, 763, 3_5412, 5082, 388, 1903, 111, 9051, 391, 2870, 4_8918, 1900, 1123, 550, 998, 112, 9586, 1_5985, 455, 391, 410, 2_2955, 3_7636, 114, 66], [65, 448, 1_7496, 419, 3663, 385, 763, 113, 2_7533, 2870, 3283, 1_3043, 1639, 2_4713, 523, 656, 2_4013, 1_8550, 2521, 517, 2_7014, 2_1244, 420, 1212, 1465, 391, 927, 4833, 388, 578, 1_1786, 114, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [65, 484, 2169, 7687, 2_1932, 1_8146, 726, 363, 1_7032, 3391, 114, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], '''attention_mask''': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
       # fmt: on

       self.tokenizer_integration_test_util(
           expected_encoding=A_      ,							model_name='''google/bigbird-roberta-base'''      ,							revision='''215c99f1600e06f83acce68422f2035b2b5c3510'''      ,							)





import itertools
import random
import unittest

import numpy as np

from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor
from transformers.testing_utils import require_torch, slow

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


_UpperCamelCase 			=		random.Random()







def 		_lowercase (     lowercase__   ,	lowercase__=1.0   ,	lowercase__=None   ,	lowercase__=None						):
      if rng is None:
            __lowerCAmelCase					:						Optional[Any]					=					global_rng

      __lowerCAmelCase					:						Tuple					=					[]
      for batch_idx in range(shape[0]						):
            values.append([]						)
            for _ in range(shape[1]						):
                  values[-1].append(rng.random() * scale						)

      return values







class   __lowercase      (unittest.TestCase ):
 def __init__(							self      ,							A_      ,							A_=7      ,							A_=400      ,							A_=2000      ,							A_=1      ,							A_=0.0      ,							A_=1_6000      ,							A_=True      ,							A_=True      ,							)					->List[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						List[Any]					=					parent
       __lowerCAmelCase					:						Optional[int]					=					batch_size
       __lowerCAmelCase					:						Any					=					min_seq_length
       __lowerCAmelCase					:						Tuple					=					max_seq_length
       __lowerCAmelCase					:						Tuple					=					(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
       __lowerCAmelCase					:						Dict					=					feature_size
       __lowerCAmelCase					:						Optional[int]					=					padding_value
       __lowerCAmelCase					:						Tuple					=					sampling_rate
       __lowerCAmelCase					:						Union[str, Any]					=					return_attention_mask
       __lowerCAmelCase					:						Dict					=					do_normalize
 def 	UpperCamelCase__  (							self					)					->Optional[Any]:



       '''simple docstring'''





       return {
           "feature_size": self.feature_size,
           "padding_value": self.padding_value,
           "sampling_rate": self.sampling_rate,
           "return_attention_mask": self.return_attention_mask,
           "do_normalize": self.do_normalize,
       }





 def 	UpperCamelCase__  (							self      ,							A_=False      ,							A_=False					)					->Union[str, Any]:



       '''simple docstring'''





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

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

       return speech_inputs







class   __lowercase      (_UpperCAmelCase		,   unittest.TestCase ):
 _UpperCamelCase			  =  WavaVecaFeatureExtractor
 def 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





       __lowerCAmelCase					:						List[Any]					=					WavaVecaFeatureExtractionTester(self					)
 def 	UpperCamelCase__  (							self      ,							A_					)					->Optional[Any]:



       '''simple docstring'''





       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 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





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

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

       # Test batched
       __lowerCAmelCase					:						Dict					=					feat_extract(A_      ,							return_tensors='''np'''					).input_values
       __lowerCAmelCase					:						Dict					=					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					)					)

       # Test 2-D numpy arrays are batched.
       __lowerCAmelCase					:						int					=					[floats_list((1, x)					)[0] for x in (800, 800, 800)]
       __lowerCAmelCase					:						List[Any]					=					np.asarray(A_					)
       __lowerCAmelCase					:						Any					=					feat_extract(A_      ,							return_tensors='''np'''					).input_values
       __lowerCAmelCase					:						Union[str, Any]					=					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 	UpperCamelCase__  (							self					)					->Union[str, Any]:



       '''simple docstring'''





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

       __lowerCAmelCase					:						str					=					['''longest''', '''max_length''', '''do_not_pad''']
       __lowerCAmelCase					:						str					=					[None, 1600, None]
       for max_length, padding in zip(A_      ,							A_					):
             __lowerCAmelCase					:						Optional[int]					=					feat_extract(A_      ,							padding=A_      ,							max_length=A_      ,							return_tensors='''np'''					)
             __lowerCAmelCase					:						Optional[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 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





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

       __lowerCAmelCase					:						int					=					['''longest''', '''max_length''', '''do_not_pad''']
       __lowerCAmelCase					:						List[str]					=					[None, 1600, None]

       for max_length, padding in zip(A_      ,							A_					):
             __lowerCAmelCase					:						Union[str, Any]					=					feat_extract(A_      ,							max_length=A_      ,							padding=A_					)
             __lowerCAmelCase					:						Union[str, 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 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
       __lowerCAmelCase					:						Optional[Any]					=					[floats_list((1, x)					)[0] for x in range(800      ,							1400      ,							200					)]
       __lowerCAmelCase					:						List[str]					=					feat_extract(
           A_      ,							truncation=A_      ,							max_length=1000      ,							padding='''max_length'''      ,							return_tensors='''np'''					)
       __lowerCAmelCase					:						int					=					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 	UpperCamelCase__  (							self					)					->List[str]:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
       __lowerCAmelCase					:						int					=					[floats_list((1, x)					)[0] for x in range(800      ,							1400      ,							200					)]
       __lowerCAmelCase					:						int					=					feat_extract(
           A_      ,							truncation=A_      ,							max_length=1000      ,							padding='''longest'''      ,							return_tensors='''np'''					)
       __lowerCAmelCase					:						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 max_length
       self.assertTrue(input_values.shape == (3, 1000)					)

       __lowerCAmelCase					:						Any					=					[floats_list((1, x)					)[0] for x in range(800      ,							1400      ,							200					)]
       __lowerCAmelCase					:						Optional[int]					=					feat_extract(
           A_      ,							truncation=A_      ,							max_length=2000      ,							padding='''longest'''      ,							return_tensors='''np'''					)
       __lowerCAmelCase					:						List[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 longest
       self.assertTrue(input_values.shape == (3, 1200)					)
 @require_torch
 def 	UpperCamelCase__  (							self					)					->Any:



       '''simple docstring'''





       import torch

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

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





 @slow
 @require_torch
 def 	UpperCamelCase__  (							self					)					->int:



       '''simple docstring'''





       for model_id in WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST:
             __lowerCAmelCase					:						Any					=					WavaVecaConfig.from_pretrained(A_					)
             __lowerCAmelCase					:						Tuple					=					WavaVecaFeatureExtractor.from_pretrained(A_					)

             # only "layer" feature extraction norm should make use of
             # attention_mask
             self.assertEqual(feat_extract.return_attention_mask      ,							config.feat_extract_norm == '''layer'''					)


