






'''simple docstring'''







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      RemBertConfig,
      RemBertForCausalLM,
      RemBertForMaskedLM,
      RemBertForMultipleChoice,
      RemBertForQuestionAnswering,
      RemBertForSequenceClassification,
      RemBertForTokenClassification,
      RemBertModel,
  )
  from transformers.models.rembert.modeling_rembert import REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST




class      __SCREAMING_SNAKE_CASE					:


  """simple docstring"""


  def __init__( self      ,  UpperCamelCase__      ,  UpperCamelCase__=13      ,  UpperCamelCase__=7      ,  UpperCamelCase__=True      ,  UpperCamelCase__=True      ,  UpperCamelCase__=True      ,  UpperCamelCase__=True      ,  UpperCamelCase__=99      ,  UpperCamelCase__=32      ,  UpperCamelCase__=18      ,  UpperCamelCase__=43      ,  UpperCamelCase__=5      ,  UpperCamelCase__=4      ,  UpperCamelCase__=37      ,  UpperCamelCase__="gelu"      ,  UpperCamelCase__=0.1      ,  UpperCamelCase__=0.1      ,  UpperCamelCase__=512      ,  UpperCamelCase__=16      ,  UpperCamelCase__=2      ,  UpperCamelCase__=0.02      ,  UpperCamelCase__=3      ,  UpperCamelCase__=4      ,  UpperCamelCase__=None      ,  ):






         """simple docstring"""


         a_	    = parent
         a_	    = batch_size
         a_	    = seq_length
         a_	    = is_training
         a_	    = use_input_mask
         a_	    = use_token_type_ids
         a_	    = use_labels
         a_	    = vocab_size
         a_	    = hidden_size
         a_	    = input_embedding_size
         a_	    = output_embedding_size
         a_	    = num_hidden_layers
         a_	    = num_attention_heads
         a_	    = intermediate_size
         a_	    = hidden_act
         a_	    = hidden_dropout_prob
         a_	    = attention_probs_dropout_prob
         a_	    = max_position_embeddings
         a_	    = type_vocab_size
         a_	    = type_sequence_label_size
         a_	    = initializer_range
         a_	    = num_labels
         a_	    = num_choices
         a_	    = scope







  def       _a					( self  ):






         """simple docstring"""


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

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

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

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

         a_	    = RemBertConfig(
             vocab_size=self.vocab_size      ,  hidden_size=self.hidden_size      ,  input_embedding_size=self.input_embedding_size      ,  output_embedding_size=self.output_embedding_size      ,  num_hidden_layers=self.num_hidden_layers      ,  num_attention_heads=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      ,  max_position_embeddings=self.max_position_embeddings      ,  type_vocab_size=self.type_vocab_size      ,  is_decoder=UpperCamelCase__      ,  initializer_range=self.initializer_range      ,  )

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







  def       _a					( self  ):






         """simple docstring"""


         (
             (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  
         )	    = self.prepare_config_and_inputs()

         a_	    = True
         a_	    = floats_tensor([self.batch_size, self.seq_length, self.hidden_size]  )
         a_	    = ids_tensor([self.batch_size, self.seq_length]      ,  vocab_size=2  )

         return (
             config,
             input_ids,
             token_type_ids,
             input_mask,
             sequence_labels,
             token_labels,
             choice_labels,
             encoder_hidden_states,
             encoder_attention_mask,
         )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = RemBertModel(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__  )
         a_	    = model(UpperCamelCase__      ,  token_type_ids=UpperCamelCase__  )
         a_	    = model(UpperCamelCase__  )
         self.parent.assertEqual(result.last_hidden_state.shape      ,  (self.batch_size, self.seq_length, self.hidden_size)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  ):






         """simple docstring"""


         a_	    = True
         a_	    = RemBertModel(UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  encoder_hidden_states=UpperCamelCase__      ,  encoder_attention_mask=UpperCamelCase__      ,  )
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  encoder_hidden_states=UpperCamelCase__      ,  )
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__  )
         self.parent.assertEqual(result.last_hidden_state.shape      ,  (self.batch_size, self.seq_length, self.hidden_size)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  ):






         """simple docstring"""


         a_	    = RemBertForCausalLM(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  labels=UpperCamelCase__  )
         self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.vocab_size)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = RemBertForMaskedLM(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  labels=UpperCamelCase__  )
         self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.vocab_size)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  ):






         """simple docstring"""


         a_	    = True
         a_	    = True
         a_	    = RemBertForCausalLM(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()

         # first forward pass
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  encoder_hidden_states=UpperCamelCase__      ,  encoder_attention_mask=UpperCamelCase__      ,  use_cache=UpperCamelCase__      ,  )
         a_	    = outputs.past_key_values

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

         # append to next input_ids and
         a_	    = torch.cat([input_ids, next_tokens]      ,  dim=-1  )
         a_	    = torch.cat([input_mask, next_mask]      ,  dim=-1  )

         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  encoder_hidden_states=UpperCamelCase__      ,  encoder_attention_mask=UpperCamelCase__      ,  output_hidden_states=UpperCamelCase__      ,  )['hidden_states'][0]
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  encoder_hidden_states=UpperCamelCase__      ,  encoder_attention_mask=UpperCamelCase__      ,  past_key_values=UpperCamelCase__      ,  output_hidden_states=UpperCamelCase__      ,  )['hidden_states'][0]

         # select random slice
         a_	    = ids_tensor((1,)      ,  output_from_past.shape[-1]  ).item()
         a_	    = output_from_no_past[:, -3:, random_slice_idx].detach()
         a_	    = output_from_past[:, :, random_slice_idx].detach()

         self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]  )

         # test that outputs are equal for slice
         self.parent.assertTrue(torch.allclose(UpperCamelCase__      ,  UpperCamelCase__      ,  atol=1e-3  )  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = RemBertForQuestionAnswering(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  start_positions=UpperCamelCase__      ,  end_positions=UpperCamelCase__      ,  )
         self.parent.assertEqual(result.start_logits.shape      ,  (self.batch_size, self.seq_length)  )
         self.parent.assertEqual(result.end_logits.shape      ,  (self.batch_size, self.seq_length)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = self.num_labels
         a_	    = RemBertForSequenceClassification(UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  labels=UpperCamelCase__  )
         self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.num_labels)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = self.num_labels
         a_	    = RemBertForTokenClassification(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = model(UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  labels=UpperCamelCase__  )
         self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.num_labels)  )







  def       _a					( self      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__  ):






         """simple docstring"""


         a_	    = self.num_choices
         a_	    = RemBertForMultipleChoice(config=UpperCamelCase__  )
         model.to(UpperCamelCase__  )
         model.eval()
         a_	    = input_ids.unsqueeze(1  ).expand(-1      ,  self.num_choices      ,  -1  ).contiguous()
         a_	    = token_type_ids.unsqueeze(1  ).expand(-1      ,  self.num_choices      ,  -1  ).contiguous()
         a_	    = input_mask.unsqueeze(1  ).expand(-1      ,  self.num_choices      ,  -1  ).contiguous()
         a_	    = model(
             UpperCamelCase__      ,  attention_mask=UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  labels=UpperCamelCase__      ,  )
         self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.num_choices)  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.prepare_config_and_inputs()
         (
             (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  
         )	    = config_and_inputs
         a_	    = {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
         return config, inputs_dict





@require_torch
class      __SCREAMING_SNAKE_CASE					(__A       ,					__A       ,					unittest.TestCase					):


  """simple docstring"""


  _a     :   Dict			 =    (
      (
          RemBertModel,
          RemBertForMaskedLM,
          RemBertForCausalLM,
          RemBertForMultipleChoice,
          RemBertForQuestionAnswering,
          RemBertForSequenceClassification,
          RemBertForTokenClassification,
      )
      if is_torch_available()
      else ()
  )
  _a     :   Union[str, Any]			 =    (RemBertForCausalLM,) if is_torch_available() else ()
  _a     :   List[str]			 =    (
      {
          '''feature-extraction''': RemBertModel,
          '''fill-mask''': RemBertForMaskedLM,
          '''question-answering''': RemBertForQuestionAnswering,
          '''text-classification''': RemBertForSequenceClassification,
          '''text-generation''': RemBertForCausalLM,
          '''token-classification''': RemBertForTokenClassification,
          '''zero-shot''': RemBertForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = RemBertModelTester(self  )
         a_	    = ConfigTester(self      ,  config_class=UpperCamelCase__      ,  hidden_size=37  )







  def       _a					( self  ):






         """simple docstring"""


         self.config_tester.run_common_tests()







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
                a_	    = type
                self.model_tester.create_and_check_model(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_decoder_model_past_large_inputs(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_model_as_decoder(*UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         (
             (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  (
             a_
         )    ,  
         )	    = self.model_tester.prepare_config_and_inputs_for_decoder()

         a_	    = None

         self.model_tester.create_and_check_model_as_decoder(
             UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  UpperCamelCase__      ,  )







  @slow
  def       _a					( self  ):






         """simple docstring"""


         for model_name in REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                a_	    = RemBertModel.from_pretrained(UpperCamelCase__  )
                self.assertIsNotNone(UpperCamelCase__  )





@require_torch
class      __SCREAMING_SNAKE_CASE					(unittest.TestCase					):


  """simple docstring"""


  @slow
  def       _a					( self  ):






         """simple docstring"""


         a_	    = RemBertModel.from_pretrained('google/rembert'  )
         a_	    = torch.tensor([[312, 56_498, 313, 2_125, 313]]  )
         a_	    = torch.tensor([[0, 0, 0, 1, 1]]  )
         with torch.no_grad():
                a_	    = model(UpperCamelCase__      ,  token_type_ids=UpperCamelCase__      ,  output_hidden_states=UpperCamelCase__  )

         a_	    = 1_152

         a_	    = torch.Size((1, 5, hidden_size)  )
         self.assertEqual(output['last_hidden_state'].shape      ,  UpperCamelCase__  )

         a_	    = torch.tensor(
             [
                 [
                     [0.0_754, -0.2_022, 0.1_904],
                     [-0.3_354, -0.3_692, -0.4_791],
                     [-0.2_314, -0.6_729, -0.0_749],
                     [-0.0_396, -0.3_105, -0.4_234],
                     [-0.1_571, -0.0_525, 0.5_353],
                 ]
             ]  )

         # Running on the original tf implementation gives slightly different results here.
         # Not clear why this variations is present
         # TODO: Find reason for discrepancy
         # expected_original_implementation = [[
         #     [0.07630594074726105, -0.20146065950393677, 0.19107051193714142],
         #     [-0.3405614495277405, -0.36971670389175415, -0.4808273911476135],
         #     [-0.22587086260318756, -0.6656315922737122, -0.07844287157058716],
         #     [-0.04145475849509239, -0.3077218234539032, -0.42316967248916626],
         #     [-0.15887849032878876, -0.054529931396245956, 0.5356100797653198]
         # ]]

         self.assertTrue(torch.allclose(output['last_hidden_state'][:, :, :3]      ,  UpperCamelCase__      ,  atol=1e-4  )  )












'''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      __SCREAMING_SNAKE_CASE					(unittest.TestCase					):


  """simple docstring"""


  def       _a					( self  ):






         """simple docstring"""


         a_	    = '<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(' '  )
         a_	    = dict(zip(UpperCamelCase__      ,  range(len(UpperCamelCase__  )  )  )  )

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

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

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







  def       _a					( self      ,  **UpperCamelCase__  ):






         """simple docstring"""


         a_	    = self.add_kwargs_tokens_map.copy()
         kwargs.update(UpperCamelCase__  )
         return WavaVecaCTCTokenizer.from_pretrained(self.tmpdirname      ,  **UpperCamelCase__  )







  def       _a					( self      ,  **UpperCamelCase__  ):






         """simple docstring"""


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







  def       _a					( self  ):






         """simple docstring"""


         shutil.rmtree(self.tmpdirname  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.get_tokenizer()
         a_	    = self.get_feature_extractor()

         a_	    = WavaVecaProcessor(tokenizer=UpperCamelCase__      ,  feature_extractor=UpperCamelCase__  )

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

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

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







  def       _a					( self  ):






         """simple docstring"""


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

         a_	    = self.get_tokenizer(bos_token='(BOS)'      ,  eos_token='(EOS)'  )
         a_	    = self.get_feature_extractor(do_normalize=UpperCamelCase__      ,  padding_value=1.0  )

         a_	    = WavaVecaProcessor.from_pretrained(
             self.tmpdirname      ,  bos_token='(BOS)'      ,  eos_token='(EOS)'      ,  do_normalize=UpperCamelCase__      ,  padding_value=1.0  )

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

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







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.get_feature_extractor()
         a_	    = self.get_tokenizer()

         a_	    = WavaVecaProcessor(tokenizer=UpperCamelCase__      ,  feature_extractor=UpperCamelCase__  )

         a_	    = floats_list((3, 1_000)  )

         a_	    = feature_extractor(UpperCamelCase__      ,  return_tensors='np'  )
         a_	    = processor(UpperCamelCase__      ,  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  ):






         """simple docstring"""


         a_	    = self.get_feature_extractor()
         a_	    = self.get_tokenizer()

         a_	    = WavaVecaProcessor(tokenizer=UpperCamelCase__      ,  feature_extractor=UpperCamelCase__  )

         a_	    = 'This is a test string'

         a_	    = processor(text=UpperCamelCase__  )

         a_	    = tokenizer(UpperCamelCase__  )

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







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.get_feature_extractor()
         a_	    = self.get_tokenizer()

         a_	    = WavaVecaProcessor(tokenizer=UpperCamelCase__      ,  feature_extractor=UpperCamelCase__  )

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

         a_	    = processor.batch_decode(UpperCamelCase__  )
         a_	    = tokenizer.batch_decode(UpperCamelCase__  )

         self.assertListEqual(UpperCamelCase__      ,  UpperCamelCase__  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.get_feature_extractor()
         a_	    = self.get_tokenizer()

         a_	    = WavaVecaProcessor(tokenizer=UpperCamelCase__      ,  feature_extractor=UpperCamelCase__  )

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




