
'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import AutoTokenizer, GPTJConfig, is_tf_available
from transformers.testing_utils import require_tf, slow, tooslow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin
from ...utils.test_modeling_tf_core import TFCoreModelTesterMixin


if is_tf_available():
				import tensorflow as tf

				from transformers.models.gptj.modeling_tf_gptj import (
				    TFGPTJForCausalLM,
				    TFGPTJForQuestionAnswering,
				    TFGPTJForSequenceClassification,
				    TFGPTJModel,
				    shape_list,
				)





class      A							:



			def __init__(   self    ,       lowerCamelCase__    )     ->						Tuple:




									'''simple docstring'''



									lowercase__								=    parent
									lowercase__								=    13
									lowercase__								=    7
									lowercase__								=    True
									lowercase__								=    True
									lowercase__								=    True
									lowercase__								=    True
									lowercase__								=    True
									lowercase__								=    99
									lowercase__								=    32
									lowercase__								=    4
									lowercase__								=    2
									lowercase__								=    4
									lowercase__								=    37
									lowercase__								=    """gelu"""
									lowercase__								=    0.1
									lowercase__								=    0.1
									lowercase__								=    512
									lowercase__								=    16
									lowercase__								=    2
									lowercase__								=    0.02
									lowercase__								=    3
									lowercase__								=    4
									lowercase__								=    None
									lowercase__								=    self.vocab_size - 1
									lowercase__								=    self.vocab_size - 1
									lowercase__								=    self.vocab_size - 1



			def A__	(   self    )     ->						Dict:




									'''simple docstring'''



									lowercase__								=    ids_tensor([self.batch_size, self.seq_length]    ,       self.vocab_size    )

									lowercase__								=    None
									if self.use_input_mask:
															lowercase__								=    random_attention_mask([self.batch_size, self.seq_length]    )

									lowercase__								=    None
									if self.use_token_type_ids:
															lowercase__								=    ids_tensor([self.batch_size, self.seq_length]    ,       self.type_vocab_size    )

									lowercase__								=    None
									if self.use_mc_token_ids:
															lowercase__								=    ids_tensor([self.batch_size, self.num_choices]    ,       self.seq_length    )

									lowercase__								=    None
									lowercase__								=    None
									lowercase__								=    None
									if self.use_labels:
															lowercase__								=    ids_tensor([self.batch_size]    ,       self.type_sequence_label_size    )
															lowercase__								=    ids_tensor([self.batch_size, self.seq_length]    ,       self.num_labels    )
															lowercase__								=    ids_tensor([self.batch_size]    ,       self.num_choices    )

									lowercase__								=    GPTJConfig(
									    vocab_size=self.vocab_size    ,       n_embd=self.hidden_size    ,       n_layer=self.num_hidden_layers    ,       n_head=self.num_attention_heads    ,       intermediate_size=self.intermediate_size    ,       hidden_act=self.hidden_act    ,       hidden_dropout_prob=self.hidden_dropout_prob    ,       attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,       n_positions=self.max_position_embeddings    ,       type_vocab_size=self.type_vocab_size    ,       initializer_range=self.initializer_range    ,       bos_token_id=self.bos_token_id    ,       eos_token_id=self.eos_token_id    ,       pad_token_id=self.pad_token_id    ,       rotary_dim=self.rotary_dim    ,       return_dict=lowerCamelCase__    ,       )

									lowercase__								=    ids_tensor([self.num_hidden_layers, self.num_attention_heads]    ,       2    )

									return (
									    config,
									    input_ids,
									    input_mask,
									    head_mask,
									    token_type_ids,
									    mc_token_ids,
									    sequence_labels,
									    token_labels,
									    choice_labels,
									)



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       *lowerCamelCase__    )     ->						Optional[int]:




									'''simple docstring'''



									lowercase__								=    TFGPTJModel(config=lowerCamelCase__    )
									lowercase__								=    {
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}
									lowercase__								=    model(lowerCamelCase__    )

									lowercase__								=    [input_ids, None, input_mask]  # None is the input for 'past'
									lowercase__								=    model(lowerCamelCase__    )

									lowercase__								=    model(lowerCamelCase__    )

									self.parent.assertEqual(result.last_hidden_state.shape    ,       (self.batch_size, self.seq_length, self.hidden_size)    )



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       *lowerCamelCase__    )     ->						int:




									'''simple docstring'''



									lowercase__								=    TFGPTJModel(config=lowerCamelCase__    )

									# first forward pass
									lowercase__								=    model(lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       use_cache=lowerCamelCase__    )
									lowercase__								=    model(lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    )
									lowercase__								=    model(lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       use_cache=lowerCamelCase__    )

									self.parent.assertTrue(len(lowerCamelCase__    ) == len(lowerCamelCase__    )    )
									self.parent.assertTrue(len(lowerCamelCase__    ) == len(lowerCamelCase__    ) + 1    )

									lowercase__	,  lowercase__								=    outputs.to_tuple()

									# create hypothetical next token and extent to next_input_ids
									lowercase__								=    ids_tensor((self.batch_size, 1)    ,       config.vocab_size    )
									lowercase__								=    ids_tensor([self.batch_size, 1]    ,       self.type_vocab_size    )

									# append to next input_ids and token_type_ids
									lowercase__								=    tf.concat([input_ids, next_tokens]    ,       axis=-1    )
									lowercase__								=    tf.concat([token_type_ids, next_token_types]    ,       axis=-1    )

									lowercase__								=    model(lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    )["""last_hidden_state"""]
									lowercase__								=    model(lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       past_key_values=lowerCamelCase__    )[
									    """last_hidden_state"""
									]

									# select random slice
									lowercase__								=    int(ids_tensor((1,)    ,       shape_list(lowerCamelCase__    )[-1]    )    )
									lowercase__								=    output_from_no_past[:, -1, random_slice_idx]
									lowercase__								=    output_from_past[:, 0, random_slice_idx]

									# test that outputs are equal for slice
									tf.debugging.assert_near(lowerCamelCase__    ,       lowerCamelCase__    ,       rtol=1e-6    )



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       *lowerCamelCase__    )     ->						Any:




									'''simple docstring'''



									lowercase__								=    TFGPTJModel(config=lowerCamelCase__    )

									# create attention mask
									lowercase__								=    self.seq_length // 2
									lowercase__								=    tf.ones((self.batch_size, half_seq_length)    ,       dtype=tf.intaa    )
									lowercase__								=    tf.zeros((self.batch_size, self.seq_length - half_seq_length)    ,       dtype=tf.intaa    )
									lowercase__								=    tf.concat([attn_mask_begin, attn_mask_end]    ,       axis=1    )

									# first forward pass
									lowercase__	,  lowercase__								=    model(lowerCamelCase__    ,       attention_mask=lowerCamelCase__    ).to_tuple()

									# create hypothetical next token and extent to next_input_ids
									lowercase__								=    ids_tensor((self.batch_size, 1)    ,       config.vocab_size    )

									# change a random masked slice from input_ids
									lowercase__								=    ids_tensor((1,)    ,       lowerCamelCase__    ).numpy() + 1
									lowercase__								=    ids_tensor((self.batch_size, self.seq_length)    ,       config.vocab_size    )
									lowercase__								=    tf.range(self.seq_length    ) == (self.seq_length - random_seq_idx_to_change)
									lowercase__								=    tf.transpose(
									    tf.broadcast_to(tf.expand_dims(lowerCamelCase__    ,       -1    )    ,       (self.seq_length, self.batch_size)    )    )
									lowercase__								=    tf.where(lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    )

									# append to next input_ids and attn_mask
									lowercase__								=    tf.concat([input_ids, next_tokens]    ,       axis=-1    )
									lowercase__								=    tf.concat([attn_mask, tf.ones((shape_list(lowerCamelCase__    )[0], 1)    ,       dtype=tf.intaa    )]    ,       axis=1    )

									# get two different outputs
									lowercase__								=    model(lowerCamelCase__    ,       attention_mask=lowerCamelCase__    )["""last_hidden_state"""]
									lowercase__								=    model(lowerCamelCase__    ,       past_key_values=lowerCamelCase__    ,       attention_mask=lowerCamelCase__    )[
									    """last_hidden_state"""
									]

									# select random slice
									lowercase__								=    int(ids_tensor((1,)    ,       shape_list(lowerCamelCase__    )[-1]    )    )
									lowercase__								=    output_from_no_past[:, -1, random_slice_idx]
									lowercase__								=    output_from_past[:, 0, random_slice_idx]

									# test that outputs are equal for slice
									tf.debugging.assert_near(lowerCamelCase__    ,       lowerCamelCase__    ,       rtol=1e-12    )



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       *lowerCamelCase__    )     ->						Union[str, Any]:




									'''simple docstring'''



									lowercase__								=    TFGPTJModel(config=lowerCamelCase__    )

									lowercase__								=    input_ids[:1, :]
									lowercase__								=    input_mask[:1, :]
									lowercase__								=    token_type_ids[:1, :]
									lowercase__								=    1

									# first forward pass
									lowercase__								=    model(lowerCamelCase__    ,       attention_mask=lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       use_cache=lowerCamelCase__    )

									lowercase__	,  lowercase__								=    outputs.to_tuple()

									# create hypothetical next token and extent to next_input_ids
									lowercase__								=    ids_tensor((self.batch_size, 3)    ,       config.vocab_size    )
									lowercase__								=    ids_tensor((self.batch_size, 3)    ,       2    )
									lowercase__								=    ids_tensor((self.batch_size, 3)    ,       self.type_vocab_size    )

									# append to next input_ids and token_type_ids
									lowercase__								=    tf.concat([input_ids, next_tokens]    ,       axis=-1    )
									lowercase__								=    tf.concat([input_mask, next_attn_mask]    ,       axis=-1    )
									lowercase__								=    tf.concat([token_type_ids, next_token_types]    ,       axis=-1    )

									lowercase__								=    model(
									    lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       attention_mask=lowerCamelCase__    )["""last_hidden_state"""]
									lowercase__								=    model(
									    lowerCamelCase__    ,       token_type_ids=lowerCamelCase__    ,       attention_mask=lowerCamelCase__    ,       past_key_values=lowerCamelCase__    ,       )["""last_hidden_state"""]
									self.parent.assertTrue(output_from_past.shape[1] == next_tokens.shape[1]    )

									# select random slice
									lowercase__								=    int(ids_tensor((1,)    ,       shape_list(lowerCamelCase__    )[-1]    )    )
									lowercase__								=    output_from_no_past[:, -3:, random_slice_idx]
									lowercase__								=    output_from_past[:, :, random_slice_idx]

									# test that outputs are equal for slice
									tf.debugging.assert_near(lowerCamelCase__    ,       lowerCamelCase__    ,       rtol=1e-3    )



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       *lowerCamelCase__    )     ->						Dict:




									'''simple docstring'''



									lowercase__								=    TFGPTJForCausalLM(config=lowerCamelCase__    )
									lowercase__								=    {
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}
									lowercase__								=    model(lowerCamelCase__    )
									self.parent.assertEqual(result.logits.shape    ,       (self.batch_size, self.seq_length, self.vocab_size)    )



			def A__	(   self    )     ->						Any:




									'''simple docstring'''



									lowercase__								=    self.prepare_config_and_inputs()

									(
									    (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  (
									    lowercase__
									)	,  
									)								=    config_and_inputs

									lowercase__								=    {
									    """input_ids""": input_ids,
									    """token_type_ids""": token_type_ids,
									    """attention_mask""": input_mask,
									}
									return config, inputs_dict





@require_tf
class      A							(    __UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase						,  unittest.TestCase			):
			lowerCamelCase							:							List[Any]    						=					(
			    (TFGPTJForCausalLM, TFGPTJForSequenceClassification, TFGPTJForQuestionAnswering, TFGPTJModel)
			    if is_tf_available()
			    else ()
			)

			lowerCamelCase							:							Union[str, Any]    						=					(TFGPTJForCausalLM,) if is_tf_available() else ()
			lowerCamelCase							:							str    						=					(
			    {
			        """feature-extraction""": TFGPTJModel,
			        """question-answering""": TFGPTJForQuestionAnswering,
			        """text-classification""": TFGPTJForSequenceClassification,
			        """text-generation""": TFGPTJForCausalLM,
			        """zero-shot""": TFGPTJForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			lowerCamelCase							:							str    						=					False
			lowerCamelCase							:							int    						=					False
			lowerCamelCase							:							Optional[int]    						=					False
			lowerCamelCase							:							int    						=					False



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    ,       lowerCamelCase__    )     ->						str:




									'''simple docstring'''



									if (
									    pipeline_test_casse_name == "QAPipelineTests"
									    and tokenizer_name is not None
									    and not tokenizer_name.endswith("""Fast"""    )
									):
															# `QAPipelineTests` fails for a few models when the slower tokenizer are used.
															# (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
															# TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
															return True

									return False



			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									lowercase__								=    TFGPTJModelTester(self    )
									lowercase__								=    ConfigTester(self    ,       config_class=lowerCamelCase__    ,       n_embd=37    )



			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									self.config_tester.run_common_tests()



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




									'''simple docstring'''



									lowercase__								=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_gptj_model(*lowerCamelCase__    )



			def A__	(   self    )     ->						Tuple:




									'''simple docstring'''



									lowercase__								=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_gptj_model_past(*lowerCamelCase__    )



			def A__	(   self    )     ->						List[str]:




									'''simple docstring'''



									lowercase__								=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_gptj_model_attention_mask_past(*lowerCamelCase__    )



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




									'''simple docstring'''



									lowercase__								=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_gptj_model_past_large_inputs(*lowerCamelCase__    )



			def A__	(   self    )     ->						str:




									'''simple docstring'''



									lowercase__								=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_gptj_lm_head_model(*lowerCamelCase__    )



			@slow
			@unittest.skipIf(
			    not is_tf_available() or len(tf.config.list_physical_devices("""GPU"""    )    ) > 0    ,       """skip testing on GPU for now to avoid GPU OOM."""    ,       )
			def A__	(   self    )     ->						Optional[int]:




									'''simple docstring'''



									lowercase__								=    TFGPTJModel.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       from_pt=lowerCamelCase__    )
									self.assertIsNotNone(lowerCamelCase__    )



			@unittest.skip(reason="""Currently, model embeddings are going to undergo a major refactor."""    )
			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									super().test_resize_token_embeddings()





@require_tf
@tooslow
# Marked as @tooslow due to GPU OOM -- but still useful to run locally. Requires ~39GB of RAM.
class      A							(    unittest.TestCase			):



			def A__	(   self    )     ->						Any:




									'''simple docstring'''



									lowercase__								=    TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       from_pt=lowerCamelCase__    )
									lowercase__								=    tf.convert_to_tensor([[464, 3_290]]    ,       dtype=tf.intaa    )  # The dog
									# fmt: off
									# The dog is a man's best friend. It is a loyal companion, and it is a friend
									lowercase__								=    [464, 3_290, 318, 257, 582, 338, 1_266, 1_545, 13, 632, 318, 257, 9_112, 15_185, 11, 290, 340, 318, 257, 1_545]
									# fmt: on
									lowercase__								=    model.generate(lowerCamelCase__    ,       do_sample=lowerCamelCase__    )
									self.assertListEqual(output_ids[0].numpy().tolist()    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						int:




									'''simple docstring'''



									lowercase__								=    AutoTokenizer.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       revision="""float16"""    )
									lowercase__								=    TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       revision="""float16"""    ,       from_pt=lowerCamelCase__    )

									lowercase__								=    tokenizer("""Today is a nice day and"""    ,       return_tensors="""tf"""    )
									# forces the generation to happen on CPU, to avoid GPU-related quirks
									with tf.device(""":/CPU:0"""    ):
															lowercase__								=    model.generate(**lowerCamelCase__    ,       do_sample=lowerCamelCase__    ,       seed=[42, 0]    )
									lowercase__								=    tokenizer.decode(output_ids[0]    ,       skip_special_tokens=lowerCamelCase__    )

									lowercase__								=    """Today is a nice day and I’m going to go for a walk. I’"""
									self.assertEqual(lowerCamelCase__    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						Any:




									'''simple docstring'''



									lowercase__								=    TFGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       revision="""float16"""    ,       from_pt=lowerCamelCase__    )
									lowercase__								=    AutoTokenizer.from_pretrained("""EleutherAI/gpt-j-6B"""    ,       revision="""float16"""    )

									lowercase__								=    """left"""

									# Define PAD Token = EOS Token = 50256
									lowercase__								=    tokenizer.eos_token
									lowercase__								=    model.config.eos_token_id

									# use different length sentences to test batching
									lowercase__								=    [
									    """Hello, my dog is a little""",
									    """Today, I""",
									]
									lowercase__								=    [
									    """Hello, my dog is a little over a year old and has been diagnosed with hip dysplasia""",
									    """Today, I’m going to be talking about a topic that’""",
									]
									return model, tokenizer, sentences, expected_output_sentences



			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									lowercase__	,  lowercase__	,  lowercase__	,  lowercase__								=    self._get_beam_search_test_objects()

									lowercase__								=    tokenizer(lowerCamelCase__    ,       return_tensors="""tf"""    ,       padding=lowerCamelCase__    )
									lowercase__								=    model.generate(**lowerCamelCase__    ,       do_sample=lowerCamelCase__    ,       num_beams=2    )
									lowercase__								=    tokenizer.batch_decode(lowerCamelCase__    ,       skip_special_tokens=lowerCamelCase__    )
									self.assertListEqual(lowerCamelCase__    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									lowercase__	,  lowercase__	,  lowercase__	,  lowercase__								=    self._get_beam_search_test_objects()

									lowercase__								=    tokenizer(lowerCamelCase__    ,       return_tensors="""tf"""    ,       padding=lowerCamelCase__    )
									lowercase__								=    tokenizer(sentences[0]    ,       return_tensors="""tf"""    )
									lowercase__								=    model.generate(**lowerCamelCase__    ,       do_sample=lowerCamelCase__    ,       num_beams=2    )
									lowercase__								=    (
									    shape_list(inputs_non_padded["""input_ids"""]    )[-1]
									    - tf.reduce_sum(tf.cast(inputs["""attention_mask"""][-1]    ,       tf.intaa    )    ).numpy()
									)
									lowercase__								=    tokenizer(sentences[1]    ,       return_tensors="""tf"""    )
									lowercase__								=    model.generate(
									    **lowerCamelCase__    ,       do_sample=lowerCamelCase__    ,       num_beams=2    ,       max_length=model.config.max_length - num_paddings    )
									lowercase__								=    tokenizer.decode(output_non_padded[0]    ,       skip_special_tokens=lowerCamelCase__    )
									lowercase__								=    tokenizer.decode(output_padded[0]    ,       skip_special_tokens=lowerCamelCase__    )
									self.assertListEqual(lowerCamelCase__    ,       [non_padded_sentence, padded_sentence]    )



			def A__	(   self    )     ->						int:




									'''simple docstring'''



									lowercase__	,  lowercase__	,  lowercase__	,  lowercase__								=    self._get_beam_search_test_objects()

									lowercase__								=    tokenizer(lowerCamelCase__    ,       return_tensors="""tf"""    ,       padding=lowerCamelCase__    )
									lowercase__								=    tf.function(model.generate    ,       jit_compile=lowerCamelCase__    )
									lowercase__								=    xla_generate(**lowerCamelCase__    ,       do_sample=lowerCamelCase__    ,       num_beams=2    )
									lowercase__								=    tokenizer.batch_decode(lowerCamelCase__    ,       skip_special_tokens=lowerCamelCase__    )
									self.assertListEqual(lowerCamelCase__    ,       lowerCamelCase__    )








'''simple docstring'''



import json
import os
import shutil
import tempfile
import unittest

from transformers.models.wavaveca import WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor
from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES
from transformers.utils import FEATURE_EXTRACTOR_NAME

from .test_feature_extraction_wavaveca import floats_list





class      A							(    unittest.TestCase			):



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




									'''simple docstring'''



									lowercase__								=    """<pad> <s> </s> <unk> | E T A O N I H S R D L U M W C F G Y P B V K ' X J Q Z""".split(""" """    )
									lowercase__								=    dict(zip(lowerCamelCase__    ,       range(len(lowerCamelCase__    )    )    )    )

									lowercase__								=    {
									    """pad_token""": """<pad>""",
									    """unk_token""": """<unk>""",
									    """bos_token""": """<s>""",
									    """eos_token""": """</s>""",
									}
									lowercase__								=    {
									    """feature_size""": 1,
									    """padding_value""": 0.0,
									    """sampling_rate""": 16_000,
									    """return_attention_mask""": False,
									    """do_normalize""": True,
									}

									lowercase__								=    tempfile.mkdtemp()
									lowercase__								=    os.path.join(self.tmpdirname    ,       VOCAB_FILES_NAMES["""vocab_file"""]    )
									lowercase__								=    os.path.join(self.tmpdirname    ,       lowerCamelCase__    )
									with open(self.vocab_file    ,       """w"""    ,       encoding="""utf-8"""    ) as fp:
															fp.write(json.dumps(lowerCamelCase__    ) + """\n"""    )

									with open(self.feature_extraction_file    ,       """w"""    ,       encoding="""utf-8"""    ) as fp:
															fp.write(json.dumps(lowerCamelCase__    ) + """\n"""    )



			def A__	(   self    ,       **lowerCamelCase__    )     ->						int:




									'''simple docstring'''



									lowercase__								=    self.add_kwargs_tokens_map.copy()
									kwargs.update(lowerCamelCase__    )
									return WavaVecaCTCTokenizer.from_pretrained(self.tmpdirname    ,       **lowerCamelCase__    )



			def A__	(   self    ,       **lowerCamelCase__    )     ->						Dict:




									'''simple docstring'''



									return WavaVecaFeatureExtractor.from_pretrained(self.tmpdirname    ,       **lowerCamelCase__    )



			def A__	(   self    )     ->						Dict:




									'''simple docstring'''



									shutil.rmtree(self.tmpdirname    )



			def A__	(   self    )     ->						str:




									'''simple docstring'''



									lowercase__								=    self.get_tokenizer()
									lowercase__								=    self.get_feature_extractor()

									lowercase__								=    WavaVecaProcessor(tokenizer=lowerCamelCase__    ,       feature_extractor=lowerCamelCase__    )

									processor.save_pretrained(self.tmpdirname    )
									lowercase__								=    WavaVecaProcessor.from_pretrained(self.tmpdirname    )

									self.assertEqual(processor.tokenizer.get_vocab()    ,       tokenizer.get_vocab()    )
									self.assertIsInstance(processor.tokenizer    ,       lowerCamelCase__    )

									self.assertEqual(processor.feature_extractor.to_json_string()    ,       feature_extractor.to_json_string()    )
									self.assertIsInstance(processor.feature_extractor    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						Tuple:




									'''simple docstring'''



									lowercase__								=    WavaVecaProcessor(tokenizer=self.get_tokenizer()    ,       feature_extractor=self.get_feature_extractor()    )
									processor.save_pretrained(self.tmpdirname    )

									lowercase__								=    self.get_tokenizer(bos_token="""(BOS)"""    ,       eos_token="""(EOS)"""    )
									lowercase__								=    self.get_feature_extractor(do_normalize=lowerCamelCase__    ,       padding_value=1.0    )

									lowercase__								=    WavaVecaProcessor.from_pretrained(
									    self.tmpdirname    ,       bos_token="""(BOS)"""    ,       eos_token="""(EOS)"""    ,       do_normalize=lowerCamelCase__    ,       padding_value=1.0    )

									self.assertEqual(processor.tokenizer.get_vocab()    ,       tokenizer_add_kwargs.get_vocab()    )
									self.assertIsInstance(processor.tokenizer    ,       lowerCamelCase__    )

									self.assertEqual(processor.feature_extractor.to_json_string()    ,       feature_extractor_add_kwargs.to_json_string()    )
									self.assertIsInstance(processor.feature_extractor    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						List[str]:




									'''simple docstring'''



									lowercase__								=    self.get_feature_extractor()
									lowercase__								=    self.get_tokenizer()

									lowercase__								=    WavaVecaProcessor(tokenizer=lowerCamelCase__    ,       feature_extractor=lowerCamelCase__    )

									lowercase__								=    floats_list((3, 1_000)    )

									lowercase__								=    feature_extractor(lowerCamelCase__    ,       return_tensors="""np"""    )
									lowercase__								=    processor(lowerCamelCase__    ,       return_tensors="""np"""    )

									for key in input_feat_extract.keys():
															self.assertAlmostEqual(input_feat_extract[key].sum()    ,       input_processor[key].sum()    ,       delta=1e-2    )



			def A__	(   self    )     ->						Optional[Any]:




									'''simple docstring'''



									lowercase__								=    self.get_feature_extractor()
									lowercase__								=    self.get_tokenizer()

									lowercase__								=    WavaVecaProcessor(tokenizer=lowerCamelCase__    ,       feature_extractor=lowerCamelCase__    )

									lowercase__								=    """This is a test string"""

									lowercase__								=    processor(text=lowerCamelCase__    )

									lowercase__								=    tokenizer(lowerCamelCase__    )

									for key in encoded_tok.keys():
															self.assertListEqual(encoded_tok[key]    ,       encoded_processor[key]    )



			def A__	(   self    )     ->						List[Any]:




									'''simple docstring'''



									lowercase__								=    self.get_feature_extractor()
									lowercase__								=    self.get_tokenizer()

									lowercase__								=    WavaVecaProcessor(tokenizer=lowerCamelCase__    ,       feature_extractor=lowerCamelCase__    )

									lowercase__								=    [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

									lowercase__								=    processor.batch_decode(lowerCamelCase__    )
									lowercase__								=    tokenizer.batch_decode(lowerCamelCase__    )

									self.assertListEqual(lowerCamelCase__    ,       lowerCamelCase__    )



			def A__	(   self    )     ->						List[str]:




									'''simple docstring'''



									lowercase__								=    self.get_feature_extractor()
									lowercase__								=    self.get_tokenizer()

									lowercase__								=    WavaVecaProcessor(tokenizer=lowerCamelCase__    ,       feature_extractor=lowerCamelCase__    )

									self.assertListEqual(
									    processor.model_input_names    ,       feature_extractor.model_input_names    ,       msg="""`processor` and `feature_extractor` model input names do not match"""    ,       )






