



"""simple docstring"""
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer
from ...utils import logging


__SCREAMING_SNAKE_CASE  :						Dict    							=      logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE  :						str    							=      '''▁'''

__SCREAMING_SNAKE_CASE  :						str    							=      {'''vocab_file''': '''sentencepiece.bpe.model'''}

__SCREAMING_SNAKE_CASE  :						Optional[int]    							=      {
    '''vocab_file''': {
        '''facebook/mbart-large-50-one-to-many-mmt''': (
            '''https://huggingface.co/facebook/mbart-large-50-one-to-many-mmt/resolve/main/sentencepiece.bpe.model'''
        ),
    }
}

__SCREAMING_SNAKE_CASE  :						str    							=      {
    '''facebook/mbart-large-50-one-to-many-mmt''': 1_0_2_4,
}

# fmt: off
__SCREAMING_SNAKE_CASE  :						Dict    							=      ['''ar_AR''', '''cs_CZ''', '''de_DE''', '''en_XX''', '''es_XX''', '''et_EE''', '''fi_FI''', '''fr_XX''', '''gu_IN''', '''hi_IN''', '''it_IT''', '''ja_XX''', '''kk_KZ''', '''ko_KR''', '''lt_LT''', '''lv_LV''', '''my_MM''', '''ne_NP''', '''nl_XX''', '''ro_RO''', '''ru_RU''', '''si_LK''', '''tr_TR''', '''vi_VN''', '''zh_CN''', '''af_ZA''', '''az_AZ''', '''bn_IN''', '''fa_IR''', '''he_IL''', '''hr_HR''', '''id_ID''', '''ka_GE''', '''km_KH''', '''mk_MK''', '''ml_IN''', '''mn_MN''', '''mr_IN''', '''pl_PL''', '''ps_AF''', '''pt_XX''', '''sv_SE''', '''sw_KE''', '''ta_IN''', '''te_IN''', '''th_TH''', '''tl_XX''', '''uk_UA''', '''ur_PK''', '''xh_ZA''', '''gl_ES''', '''sl_SI''']


class 							lowerCamelCase_(   A__    ):





     '''simple docstring'''



     lowercase__   :       str										= VOCAB_FILES_NAMES
     lowercase__   :       str										= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     lowercase__   :       Optional[int]										= PRETRAINED_VOCAB_FILES_MAP
     lowercase__   :       int										= ['input_ids', 'attention_mask']

     lowercase__   :       List[int]										= []
     lowercase__   :       List[int]										= []

     def __init__(    self				,       lowerCamelCase__				,       lowerCamelCase__=None				,       lowerCamelCase__=None				,       lowerCamelCase__="</s>"				,       lowerCamelCase__="</s>"				,       lowerCamelCase__="<s>"				,       lowerCamelCase__="<unk>"				,       lowerCamelCase__="<pad>"				,       lowerCamelCase__="<mask>"				,       lowerCamelCase__ = None				,       **lowerCamelCase__				,       ):
         # Mask token behave like a normal word, i.e. include the space before it
         _lowerCamelCase        =				AddedToken(lowerCamelCase__				,       lstrip=lowerCamelCase__				,       rstrip=lowerCamelCase__   ) if isinstance(lowerCamelCase__				,       lowerCamelCase__   ) else mask_token

         _lowerCamelCase        =				{} if sp_model_kwargs is None else sp_model_kwargs

         _lowerCamelCase        =				kwargs.get('''additional_special_tokens'''				,       []   )
         kwargs["additional_special_tokens"] += [
             code for code in FAIRSEQ_LANGUAGE_CODES if code not in kwargs["additional_special_tokens"]
         ]

         super().__init__(
             src_lang=lowerCamelCase__				,       tgt_lang=lowerCamelCase__				,       eos_token=lowerCamelCase__				,       unk_token=lowerCamelCase__				,       sep_token=lowerCamelCase__				,       cls_token=lowerCamelCase__				,       pad_token=lowerCamelCase__				,       mask_token=lowerCamelCase__				,       sp_model_kwargs=self.sp_model_kwargs				,       **lowerCamelCase__				,       )

         _lowerCamelCase        =				spm.SentencePieceProcessor(**self.sp_model_kwargs   )
         self.sp_model.Load(str(lowerCamelCase__   )   )
         _lowerCamelCase        =				vocab_file

         # Original fairseq vocab and spm vocab must be "aligned":
         # Vocab    |    0    |    1    |   2    |    3    |  4  |  5  |  6  |   7   |   8   |  9
         # -------- | ------- | ------- | ------ | ------- | --- | --- | --- | ----- | ----- | ----
         # fairseq  | '<s>'   | '<pad>' | '</s>' | '<unk>' | ',' | '.' | '▁' | 's'   | '▁de' | '-'
         # spm      | '<unk>' | '<s>'   | '</s>' | ','     | '.' | '▁' | 's' | '▁de' | '-'   | '▁a'

         # Mimic fairseq token-to-id alignment for the first 4 token
         _lowerCamelCase        =				{'''<s>''': 0, '''<pad>''': 1, '''</s>''': 2, '''<unk>''': 3}

         # The first "real" token "," has position 4 in the original fairseq vocab and position 3 in the spm vocab
         _lowerCamelCase        =				1

         _lowerCamelCase        =				len(self.sp_model   )
         _lowerCamelCase        =				{
             code: self.sp_model_size + i + self.fairseq_offset for i, code in enumerate(lowerCamelCase__   )
         }
         _lowerCamelCase        =				{v: k for k, v in self.lang_code_to_id.items()}
         _lowerCamelCase        =				len(self.sp_model   ) + len(self.lang_code_to_id   ) + self.fairseq_offset

         self.fairseq_tokens_to_ids.update(self.lang_code_to_id   )
         _lowerCamelCase        =				{v: k for k, v in self.fairseq_tokens_to_ids.items()}

         _lowerCamelCase        =				src_lang if src_lang is not None else '''en_XX'''
         _lowerCamelCase        =				self.lang_code_to_id[self._src_lang]
         _lowerCamelCase        =				tgt_lang
         self.set_src_lang_special_tokens(self._src_lang   )

     @property
     def 			snake_case__      (    self   ):
         return len(self.sp_model   ) + len(self.lang_code_to_id   ) + self.fairseq_offset + 1  # Plus 1 for the mask token

     @property
     def 			snake_case__      (    self   ):
         return self._src_lang

     @src_lang.setter
     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         _lowerCamelCase        =				new_src_lang
         self.set_src_lang_special_tokens(self._src_lang   )

     def __getstate__(    self   ):
         _lowerCamelCase        =				self.__dict__.copy()
         _lowerCamelCase        =				None
         return state

     def __setstate__(    self				,       lowerCamelCase__   ):
         _lowerCamelCase        =				d

         # for backward compatibility
         if not hasattr(self				,       '''sp_model_kwargs'''   ):
             _lowerCamelCase        =				{}

         _lowerCamelCase        =				spm.SentencePieceProcessor(**self.sp_model_kwargs   )
         self.sp_model.Load(self.vocab_file   )

     def 			snake_case__      (    self   ):
         _lowerCamelCase        =				{self.convert_ids_to_tokens(lowerCamelCase__   ): i for i in range(self.vocab_size   )}
         vocab.update(self.added_tokens_encoder   )
         return vocab

     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         return self.sp_model.encode(lowerCamelCase__				,       out_type=lowerCamelCase__   )

     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         if token in self.fairseq_tokens_to_ids:
             return self.fairseq_tokens_to_ids[token]
         _lowerCamelCase        =				self.sp_model.PieceToId(lowerCamelCase__   )

         # Need to return unknown token if the SP model returned 0
         return spm_id + self.fairseq_offset if spm_id else self.unk_token_id

     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         if index in self.fairseq_ids_to_tokens:
             return self.fairseq_ids_to_tokens[index]
         return self.sp_model.IdToPiece(index - self.fairseq_offset   )

     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         _lowerCamelCase        =				[]
         _lowerCamelCase        =				''''''
         _lowerCamelCase        =				False
         for token in tokens:
             # make sure that special tokens are not decoded using sentencepiece model
             if token in self.all_special_tokens:
                 if not prev_is_special:
                     out_string += " "
                 out_string += self.sp_model.decode(lowerCamelCase__   ) + token
                 _lowerCamelCase        =				True
                 _lowerCamelCase        =				[]
             else:
                 current_sub_tokens.append(lowerCamelCase__   )
                 _lowerCamelCase        =				False
         out_string += self.sp_model.decode(lowerCamelCase__   )
         return out_string.strip()

     def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__ = None   ):
         if not os.path.isdir(lowerCamelCase__   ):
             logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""   )
             return
         _lowerCamelCase        =				os.path.join(
             lowerCamelCase__				,       (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']   )

         if os.path.abspath(self.vocab_file   ) != os.path.abspath(lowerCamelCase__   ) and os.path.isfile(self.vocab_file   ):
             copyfile(self.vocab_file				,       lowerCamelCase__   )
         elif not os.path.isfile(self.vocab_file   ):
             with open(lowerCamelCase__				,       '''wb'''   ) as fi:
                 _lowerCamelCase        =				self.sp_model.serialized_model_proto()
                 fi.write(lowerCamelCase__   )

         return (out_vocab_file,)

     def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__ = None				,       lowerCamelCase__ = False   ):

         if already_has_special_tokens:
             return super().get_special_tokens_mask(
                 token_ids_a=lowerCamelCase__				,       token_ids_a=lowerCamelCase__				,       already_has_special_tokens=lowerCamelCase__   )

         _lowerCamelCase        =				[1] * len(self.prefix_tokens   )
         _lowerCamelCase        =				[1] * len(self.suffix_tokens   )
         if token_ids_a is None:
             return prefix_ones + ([0] * len(lowerCamelCase__   )) + suffix_ones
         return prefix_ones + ([0] * len(lowerCamelCase__   )) + ([0] * len(lowerCamelCase__   )) + suffix_ones

     def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__ = None   ):
         if token_ids_a is None:
             return self.prefix_tokens + token_ids_a + self.suffix_tokens
         # We don't expect to process pairs, but leave the pair logic for API consistency
         return self.prefix_tokens + token_ids_a + token_ids_a + self.suffix_tokens

     def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__				,       **lowerCamelCase__   ):
         if src_lang is None or tgt_lang is None:
             raise ValueError('''Translation requires a `src_lang` and a `tgt_lang` for this model'''   )
         _lowerCamelCase        =				src_lang
         _lowerCamelCase        =				self(lowerCamelCase__				,       add_special_tokens=lowerCamelCase__				,       return_tensors=lowerCamelCase__				,       **lowerCamelCase__   )
         _lowerCamelCase        =				self.convert_tokens_to_ids(lowerCamelCase__   )
         _lowerCamelCase        =				tgt_lang_id
         return inputs

     def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__ = "en_XX"				,       lowerCamelCase__ = None				,       lowerCamelCase__ = "ro_RO"				,       **lowerCamelCase__				,       ):
         _lowerCamelCase        =				src_lang
         _lowerCamelCase        =				tgt_lang
         return super().prepare_seqaseq_batch(lowerCamelCase__				,       lowerCamelCase__				,       **lowerCamelCase__   )

     def 			snake_case__      (    self   ):
         return self.set_src_lang_special_tokens(self.src_lang   )

     def 			snake_case__      (    self   ):
         return self.set_tgt_lang_special_tokens(self.tgt_lang   )

     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         _lowerCamelCase        =				self.lang_code_to_id[src_lang]
         _lowerCamelCase        =				[self.cur_lang_code_id]
         _lowerCamelCase        =				[self.eos_token_id]





     def 			snake_case__      (    self				,       lowerCamelCase__   ):
         _lowerCamelCase        =				self.lang_code_to_id[tgt_lang]
         _lowerCamelCase        =				[self.cur_lang_code_id]
         _lowerCamelCase        =				[self.eos_token_id]





"""simple docstring"""
import itertools
import os
import random
import tempfile
import unittest

import numpy as np
from datasets import load_dataset

from transformers import is_speech_available
from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_speech_available():
			from transformers import WhisperFeatureExtractor

if is_torch_available():
			import torch

__SCREAMING_SNAKE_CASE  :						Dict    							=      random.Random()



def        lowerCAmelCase_(   lowercase_     :							Dict						,   lowercase_     :							int=1.0						,   lowercase_     :							str=None						,   lowercase_     :							Optional[int]=None							)	->       Any:
				if rng is None:
								_lowerCamelCase        =				global_rng

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

				return values


@require_torch
@require_torchaudio
class 							lowerCamelCase_(   unittest.TestCase    ):





					'''simple docstring'''



					def __init__(    self				,       lowerCamelCase__				,       lowerCamelCase__=7				,       lowerCamelCase__=4_0_0				,       lowerCamelCase__=2_0_0_0				,       lowerCamelCase__=1_0				,       lowerCamelCase__=1_6_0				,       lowerCamelCase__=8				,       lowerCamelCase__=0.0				,       lowerCamelCase__=4_0_0_0				,       lowerCamelCase__=False				,       lowerCamelCase__=True				,       ):
									_lowerCamelCase        =				parent
									_lowerCamelCase        =				batch_size
									_lowerCamelCase        =				min_seq_length
									_lowerCamelCase        =				max_seq_length
									_lowerCamelCase        =				(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
									_lowerCamelCase        =				padding_value
									_lowerCamelCase        =				sampling_rate
									_lowerCamelCase        =				return_attention_mask
									_lowerCamelCase        =				do_normalize
									_lowerCamelCase        =				feature_size
									_lowerCamelCase        =				chunk_length
									_lowerCamelCase        =				hop_length

					def 			snake_case__      (    self   ):
									return {
									    "feature_size": self.feature_size,
									    "hop_length": self.hop_length,
									    "chunk_length": self.chunk_length,
									    "padding_value": self.padding_value,
									    "sampling_rate": self.sampling_rate,
									    "return_attention_mask": self.return_attention_mask,
									    "do_normalize": self.do_normalize,
									}





					def 			snake_case__      (    self				,       lowerCamelCase__=False				,       lowerCamelCase__=False   ):
									def _flatten(lowerCamelCase__   ):
													return list(itertools.chain(*lowerCamelCase__   )   )

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


@require_torch
@require_torchaudio
class 							lowerCamelCase_(   A__,				unittest.TestCase    ):





					'''simple docstring'''



					lowercase__   :       Optional[int]										= WhisperFeatureExtractor if is_speech_available() else None

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				WhisperFeatureExtractionTester(self   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.feature_extraction_class(**self.feat_extract_dict   )

									with tempfile.TemporaryDirectory() as tmpdirname:
													_lowerCamelCase        =				feat_extract_first.save_pretrained(lowerCamelCase__   )[0]
													check_json_file_has_correct_format(lowerCamelCase__   )
													_lowerCamelCase        =				self.feature_extraction_class.from_pretrained(lowerCamelCase__   )

									_lowerCamelCase        =				feat_extract_first.to_dict()
									_lowerCamelCase        =				feat_extract_second.to_dict()
									_lowerCamelCase        =				feat_extract_first.mel_filters
									_lowerCamelCase        =				feat_extract_second.mel_filters
									self.assertTrue(np.allclose(lowerCamelCase__				,       lowerCamelCase__   )   )
									self.assertEqual(lowerCamelCase__				,       lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.feature_extraction_class(**self.feat_extract_dict   )

									with tempfile.TemporaryDirectory() as tmpdirname:
													_lowerCamelCase        =				os.path.join(lowerCamelCase__				,       '''feat_extract.json'''   )
													feat_extract_first.to_json_file(lowerCamelCase__   )
													_lowerCamelCase        =				self.feature_extraction_class.from_json_file(lowerCamelCase__   )

									_lowerCamelCase        =				feat_extract_first.to_dict()
									_lowerCamelCase        =				feat_extract_second.to_dict()
									_lowerCamelCase        =				feat_extract_first.mel_filters
									_lowerCamelCase        =				feat_extract_second.mel_filters
									self.assertTrue(np.allclose(lowerCamelCase__				,       lowerCamelCase__   )   )
									self.assertEqual(lowerCamelCase__				,       lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									# Tests that all call wrap to encode_plus and batch_encode_plus
									_lowerCamelCase        =				self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()   )
									# create three inputs of length 800, 1000, and 1200
									_lowerCamelCase        =				[floats_list((1, x)   )[0] for x in range(8_0_0				,       1_4_0_0				,       2_0_0   )]
									_lowerCamelCase        =				[np.asarray(lowerCamelCase__   ) for speech_input in speech_inputs]

									# Test feature size
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       padding='''max_length'''				,       return_tensors='''np'''   ).input_features
									self.assertTrue(input_features.ndim == 3   )
									self.assertTrue(input_features.shape[-1] == feature_extractor.nb_max_frames   )
									self.assertTrue(input_features.shape[-2] == feature_extractor.feature_size   )

									# Test not batched input
									_lowerCamelCase        =				feature_extractor(speech_inputs[0]				,       return_tensors='''np'''   ).input_features
									_lowerCamelCase        =				feature_extractor(np_speech_inputs[0]				,       return_tensors='''np'''   ).input_features
									self.assertTrue(np.allclose(lowerCamelCase__				,       lowerCamelCase__				,       atol=1e-3   )   )

									# Test batched
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									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.
									_lowerCamelCase        =				[floats_list((1, x)   )[0] for x in (8_0_0, 8_0_0, 8_0_0)]
									_lowerCamelCase        =				np.asarray(lowerCamelCase__   )
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									for enc_seq_a, enc_seq_a in zip(lowerCamelCase__				,       lowerCamelCase__   ):
													self.assertTrue(np.allclose(lowerCamelCase__				,       lowerCamelCase__				,       atol=1e-3   )   )

									# Test truncation required
									_lowerCamelCase        =				[floats_list((1, x)   )[0] for x in range(2_0_0				,       (feature_extractor.n_samples + 5_0_0)				,       2_0_0   )]
									_lowerCamelCase        =				[np.asarray(lowerCamelCase__   ) for speech_input in speech_inputs]

									_lowerCamelCase        =				[x[: feature_extractor.n_samples] for x in speech_inputs]
									_lowerCamelCase        =				[np.asarray(lowerCamelCase__   ) for speech_input in speech_inputs_truncated]

									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''np'''   ).input_features
									for enc_seq_a, enc_seq_a in zip(lowerCamelCase__				,       lowerCamelCase__   ):
													self.assertTrue(np.allclose(lowerCamelCase__				,       lowerCamelCase__				,       atol=1e-3   )   )

					def 			snake_case__      (    self   ):
									import torch

									_lowerCamelCase        =				self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()   )
									_lowerCamelCase        =				np.random.rand(1_0_0				,       3_2   ).astype(np.floataa   )
									_lowerCamelCase        =				np_speech_inputs.tolist()

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

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

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

					def 			snake_case__      (    self   ):
									# fmt: off
									_lowerCamelCase        =				torch.tensor(
									    [
									        0.1_1_9_3, -0.0_9_4_6, -0.1_0_9_8, -0.0_1_9_6, 0.0_2_2_5, -0.0_6_9_0, -0.1_7_3_6, 0.0_9_5_1,
									        0.0_9_7_1, -0.0_8_1_7, -0.0_7_0_2, 0.0_1_6_2, 0.0_2_6_0, 0.0_0_1_7, -0.0_1_9_2, -0.1_6_7_8,
									        0.0_7_0_9, -0.1_8_6_7, -0.0_6_5_5, -0.0_2_7_4, -0.0_2_3_4, -0.1_8_8_4, -0.0_5_1_6, -0.0_5_5_4,
									        -0.0_2_7_4, -0.1_4_2_5, -0.1_4_2_3, 0.0_8_3_7, 0.0_3_7_7, -0.0_8_5_4
									    ]   )
									# fmt: on

									_lowerCamelCase        =				self._load_datasamples(1   )
									_lowerCamelCase        =				WhisperFeatureExtractor()
									_lowerCamelCase        =				feature_extractor(lowerCamelCase__				,       return_tensors='''pt'''   ).input_features
									self.assertEqual(input_features.shape				,       (1, 8_0, 3_0_0_0)   )
									self.assertTrue(torch.allclose(input_features[0, 0, :3_0]				,       lowerCamelCase__				,       atol=1e-4   )   )





					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()   )
									_lowerCamelCase        =				self._load_datasamples(1   )[0]
									_lowerCamelCase        =				((audio - audio.min()) / (audio.max() - audio.min())) * 6_5_5_3_5  # Rescale to [0, 65535] to show issue
									_lowerCamelCase        =				feat_extract.zero_mean_unit_var_norm([audio]				,       attention_mask=lowerCamelCase__   )[0]

									self.assertTrue(np.all(np.mean(lowerCamelCase__   ) < 1e-3   )   )
									self.assertTrue(np.all(np.abs(np.var(lowerCamelCase__   ) - 1   ) < 1e-3   )   )
