

"""simple docstring"""







import json
import os
import re
import shutil
import tempfile
import unittest
from typing import Tuple

from transformers import AddedToken, BatchEncoding, ByTaTokenizer
from transformers.utils import cached_property, is_tf_available, is_torch_available

from ...test_tokenization_common import TokenizerTesterMixin


if is_torch_available():
       __SCREAMING_SNAKE_CASE								="pt"
elif is_tf_available():
       __SCREAMING_SNAKE_CASE								="tf"
else:
       __SCREAMING_SNAKE_CASE								="jax"







class  UpperCamelCase	(    _snake_case		,   unittest.TestCase						):
   lowercase							=						ByTaTokenizer
   lowercase							=						False
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        super().setUp()
        lowercase_			:       Any									=			ByTaTokenizer()
        tokenizer.save_pretrained(self.tmpdirname    )
   @cached_property
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        return ByTaTokenizer.from_pretrained('google/byt5-small'    )
   def     _UpperCAmelCase     (    self  ,**__UpperCamelCase    )			->   ByTaTokenizer:


        '''simple docstring'''


        return self.tokenizer_class.from_pretrained(self.tmpdirname  ,**lowerCAmelCase__    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase=False  ,__UpperCamelCase=20  ,__UpperCamelCase=5    )			->   Tuple[str, list]:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			[]
        for i in range(len(lowerCAmelCase__    )    ):
             try:
                  lowercase_			:       int									=			tokenizer.decode([i]  ,clean_up_tokenization_spaces=lowerCAmelCase__    )
             except UnicodeDecodeError:
                  pass
             toks.append((i, tok)    )

        lowercase_			:       Optional[Any]									=			list(filter(lambda __UpperCamelCase    : re.match(r'^[ a-zA-Z]+$'  ,t[1]    )  ,lowerCAmelCase__    )    )
        lowercase_			:       Tuple									=			list(filter(lambda __UpperCamelCase    : [t[0]] == tokenizer.encode(t[1]  ,add_special_tokens=lowerCAmelCase__    )  ,lowerCAmelCase__    )    )
        if max_length is not None and len(lowerCAmelCase__    ) > max_length:
             lowercase_			:       List[Any]									=			toks[:max_length]
        if min_length is not None and len(lowerCAmelCase__    ) < min_length and len(lowerCAmelCase__    ) > 0:
             while len(lowerCAmelCase__    ) < min_length:
                  lowercase_			:       Optional[int]									=			toks + toks
                   # toks_str = [t[1] for t in toks]
        lowercase_			:       str									=			[t[0] for t in toks]

        # Ensure consistency
        lowercase_			:       Union[str, Any]									=			tokenizer.decode(lowerCAmelCase__  ,clean_up_tokenization_spaces=lowerCAmelCase__    )
        if " " not in output_txt and len(lowerCAmelCase__    ) > 1:
             lowercase_			:       Any									=			(
                 tokenizer.decode([toks_ids[0]]  ,clean_up_tokenization_spaces=lowerCAmelCase__    )
                 + ' '
                 + tokenizer.decode(toks_ids[1:]  ,clean_up_tokenization_spaces=lowerCAmelCase__    )
             )
        if with_prefix_space:
             lowercase_			:       List[str]									=			' ' + output_txt
        lowercase_			:       Any									=			tokenizer.encode(lowerCAmelCase__  ,add_special_tokens=lowerCAmelCase__    )
        return output_txt, output_ids
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        lowercase_			:       Dict									=			self.ta_base_tokenizer
        lowercase_			:       Tuple									=			tokenizer(['hi</s>', 'I went to the gym</s>', '</s>']    )
        lowercase_			:       Optional[Any]									=			tokenizer(['hi', 'I went to the gym', '']    )
        self.assertListEqual(batch_with_eos_added['input_ids']  ,batch_without_eos_added['input_ids']    )
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			self.ta_base_tokenizer
        lowercase_			:       Optional[int]									=			'Unicode €.'
        lowercase_			:       int									=			tokenizer(lowerCAmelCase__    )
        lowercase_			:       Optional[Any]									=			[88, 113, 108, 102, 114, 103, 104, 35, 229, 133, 175, 49, 1]
        self.assertEqual(encoded['input_ids']  ,lowerCAmelCase__    )

        # decoding
        lowercase_			:       Dict									=			tokenizer.decode(lowerCAmelCase__    )
        self.assertEqual(lowerCAmelCase__  ,'Unicode €.</s>'    )

        lowercase_			:       Tuple									=			tokenizer('e è é ê ë'    )
        lowercase_			:       Any									=			[104, 35, 198, 171, 35, 198, 172, 35, 198, 173, 35, 198, 174, 1]
        self.assertEqual(encoded['input_ids']  ,lowerCAmelCase__    )
        # decoding
        lowercase_			:       Any									=			tokenizer.decode(lowerCAmelCase__    )
        self.assertEqual(lowerCAmelCase__  ,'e è é ê ë</s>'    )

        # encode/decode, but with `encode` instead of `__call__`
        self.assertEqual(tokenizer.decode(tokenizer.encode('e è é ê ë'    )    )  ,'e è é ê ë</s>'    )
   def     _UpperCAmelCase     (    self    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       Any									=			self.ta_base_tokenizer
        lowercase_			:       Dict									=			['A long paragraph for summarization.', 'Another paragraph for summarization.']
        # fmt: off
        lowercase_			:       Tuple									=			[68, 35, 111, 114, 113, 106, 35, 115, 100, 117, 100, 106, 117, 100, 115, 107, 35, 105, 114, 117, 35, 118, 120, 112, 112, 100, 117, 108, 125, 100, 119, 108, 114, 113, 49, 1, 0]
        # fmt: on
        lowercase_			:       Any									=			tokenizer(lowerCAmelCase__  ,padding=lowerCAmelCase__  ,return_tensors=lowerCAmelCase__    )
        self.assertIsInstance(lowerCAmelCase__  ,lowerCAmelCase__    )

        if FRAMEWORK != "jax":
             lowercase_			:       List[str]									=			list(batch.input_ids.numpy()[0]    )
        else:
             lowercase_			:       Optional[int]									=			list(batch.input_ids.tolist()[0]    )

        self.assertListEqual(lowerCAmelCase__  ,lowerCAmelCase__    )

        self.assertEqual((2, 37)  ,batch.input_ids.shape    )
        self.assertEqual((2, 37)  ,batch.attention_mask.shape    )
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			self.ta_base_tokenizer
        lowercase_			:       List[str]									=			['A long paragraph for summarization.', 'Another paragraph for summarization.']
        lowercase_			:       Any									=			tokenizer(lowerCAmelCase__  ,padding=lowerCAmelCase__  ,return_tensors=lowerCAmelCase__    )
        # check if input_ids are returned and no decoder_input_ids
        self.assertIn('input_ids'  ,lowerCAmelCase__    )
        self.assertIn('attention_mask'  ,lowerCAmelCase__    )
        self.assertNotIn('decoder_input_ids'  ,lowerCAmelCase__    )
        self.assertNotIn('decoder_attention_mask'  ,lowerCAmelCase__    )
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       Tuple									=			self.ta_base_tokenizer
        lowercase_			:       str									=			[
            'Summary of the text.',
            'Another summary.',
        ]
        lowercase_			:       Optional[int]									=			tokenizer(
            text_target=lowerCAmelCase__  ,max_length=32  ,padding='max_length'  ,truncation=lowerCAmelCase__  ,return_tensors=lowerCAmelCase__    )
        self.assertEqual(32  ,targets['input_ids'].shape[1]    )
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       List[str]									=			self.ta_base_tokenizer
        lowercase_			:       Optional[int]									=			['A long paragraph for summarization. </s>']
        lowercase_			:       int									=			['Summary of the text. </s>']
        # fmt: off
        lowercase_			:       List[Any]									=			[68, 35, 111, 114, 113, 106, 35, 115, 100, 117, 100, 106, 117, 100, 115, 107, 35, 105, 114, 117, 35, 118, 120, 112, 112, 100, 117, 108, 125, 100, 119, 108, 114, 113, 49, 35, 1]
        lowercase_			:       int									=			[86, 120, 112, 112, 100, 117, 124, 35, 114, 105, 35, 119, 107, 104, 35, 119, 104, 123, 119, 49, 35, 1]
        # fmt: on

        lowercase_			:       Any									=			tokenizer(lowerCAmelCase__  ,text_target=lowerCAmelCase__    )

        self.assertEqual(lowerCAmelCase__  ,batch['input_ids'][0]    )
        self.assertEqual(lowerCAmelCase__  ,batch['labels'][0]    )
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			self.get_tokenizers()
        for tokenizer in tokenizers:
             with self.subTest(f'''{tokenizer.__class__.__name__}'''    ):
                  self.assertNotEqual(tokenizer.model_max_length  ,42    )

                   # Now let's start the test
        lowercase_			:       List[Any]									=			self.get_tokenizers()
        for tokenizer in tokenizers:
             with self.subTest(f'''{tokenizer.__class__.__name__}'''    ):
                  # Isolate this from the other tests because we save additional tokens/etc
                  lowercase_			:       Optional[Any]									=			tempfile.mkdtemp()

                  lowercase_			:       Union[str, Any]									=			' He is very happy, UNwant\u00E9d,running'
                  lowercase_			:       str									=			tokenizer.encode(lowerCAmelCase__  ,add_special_tokens=lowerCAmelCase__    )
                  tokenizer.save_pretrained(lowerCAmelCase__    )

                  lowercase_			:       Any									=			tokenizer.__class__.from_pretrained(lowerCAmelCase__    )
                  lowercase_			:       str									=			after_tokenizer.encode(lowerCAmelCase__  ,add_special_tokens=lowerCAmelCase__    )
                  self.assertListEqual(lowerCAmelCase__  ,lowerCAmelCase__    )

                  shutil.rmtree(lowerCAmelCase__    )

        lowercase_			:       List[Any]									=			self.get_tokenizers(model_max_length=42    )
        for tokenizer in tokenizers:
             with self.subTest(f'''{tokenizer.__class__.__name__}'''    ):
                  # Isolate this from the other tests because we save additional tokens/etc
                  lowercase_			:       Optional[Any]									=			tempfile.mkdtemp()

                  lowercase_			:       Union[str, Any]									=			' He is very happy, UNwant\u00E9d,running'
                  tokenizer.add_tokens(['bim', 'bambam']    )
                  lowercase_			:       Any									=			tokenizer.additional_special_tokens
                  additional_special_tokens.append('new_additional_special_token'    )
                  tokenizer.add_special_tokens({'additional_special_tokens': additional_special_tokens}    )
                  lowercase_			:       str									=			tokenizer.encode(lowerCAmelCase__  ,add_special_tokens=lowerCAmelCase__    )
                  tokenizer.save_pretrained(lowerCAmelCase__    )

                  lowercase_			:       Union[str, Any]									=			tokenizer.__class__.from_pretrained(lowerCAmelCase__    )
                  lowercase_			:       Tuple									=			after_tokenizer.encode(lowerCAmelCase__  ,add_special_tokens=lowerCAmelCase__    )
                  self.assertListEqual(lowerCAmelCase__  ,lowerCAmelCase__    )
                  self.assertIn('new_additional_special_token'  ,after_tokenizer.additional_special_tokens    )
                  self.assertEqual(after_tokenizer.model_max_length  ,42    )

                  lowercase_			:       Any									=			tokenizer.__class__.from_pretrained(lowerCAmelCase__  ,model_max_length=43    )
                  self.assertEqual(tokenizer.model_max_length  ,43    )

                  shutil.rmtree(lowerCAmelCase__    )
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			[]
        if self.test_slow_tokenizer:
             tokenizer_list.append((self.tokenizer_class, self.get_tokenizer())    )

        if self.test_rust_tokenizer:
             tokenizer_list.append((self.rust_tokenizer_class, self.get_rust_tokenizer())    )

        for tokenizer_class, tokenizer_utils in tokenizer_list:
             with tempfile.TemporaryDirectory() as tmp_dir:
                  tokenizer_utils.save_pretrained(lowerCAmelCase__    )

                  with open(os.path.join(lowerCAmelCase__  ,'special_tokens_map.json'    )  ,encoding='utf-8'    ) as json_file:
                       lowercase_			:       int									=			json.load(lowerCAmelCase__    )

                  with open(os.path.join(lowerCAmelCase__  ,'tokenizer_config.json'    )  ,encoding='utf-8'    ) as json_file:
                       lowercase_			:       Tuple									=			json.load(lowerCAmelCase__    )

                  lowercase_			:       Optional[int]									=			[f'''<extra_id_{i}>''' for i in range(125    )]

                  lowercase_			:       Tuple									=			added_tokens_extra_ids + [
                      'an_additional_special_token'
                  ]
                  lowercase_			:       Optional[Any]									=			added_tokens_extra_ids + [
                      'an_additional_special_token'
                  ]

                  with open(os.path.join(lowerCAmelCase__  ,'special_tokens_map.json'    )  ,'w'  ,encoding='utf-8'    ) as outfile:
                       json.dump(lowerCAmelCase__  ,lowerCAmelCase__    )
                  with open(os.path.join(lowerCAmelCase__  ,'tokenizer_config.json'    )  ,'w'  ,encoding='utf-8'    ) as outfile:
                       json.dump(lowerCAmelCase__  ,lowerCAmelCase__    )

                  # the following checks allow us to verify that our test works as expected, i.e. that the tokenizer takes
                  # into account the new value of additional_special_tokens given in the "tokenizer_config.json" and
                  # "special_tokens_map.json" files
                  lowercase_			:       Any									=			tokenizer_class.from_pretrained(
                      lowerCAmelCase__  ,)
                  self.assertIn(
                      'an_additional_special_token'  ,tokenizer_without_change_in_init.additional_special_tokens    )
                  # self.assertIn("an_additional_special_token",tokenizer_without_change_in_init.get_vocab()) # ByT5Tokenization no vocab
                  self.assertEqual(
                      ['an_additional_special_token']  ,tokenizer_without_change_in_init.convert_ids_to_tokens(
                          tokenizer_without_change_in_init.convert_tokens_to_ids(['an_additional_special_token']    )    )  ,)

                  # Now we test that we can change the value of additional_special_tokens in the from_pretrained
                  lowercase_			:       int									=			added_tokens_extra_ids + [AddedToken('a_new_additional_special_token'  ,lstrip=lowerCAmelCase__    )]
                  lowercase_			:       List[Any]									=			tokenizer_class.from_pretrained(
                      lowerCAmelCase__  ,additional_special_tokens=lowerCAmelCase__  ,)

                  self.assertIn('a_new_additional_special_token'  ,tokenizer.additional_special_tokens    )
                  self.assertEqual(
                      ['a_new_additional_special_token']  ,tokenizer.convert_ids_to_tokens(
                          tokenizer.convert_tokens_to_ids(['a_new_additional_special_token']    )    )  ,)
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			[]
        if self.test_slow_tokenizer:
             tokenizer_list.append((self.tokenizer_class, self.get_tokenizer())    )

        if self.test_rust_tokenizer:
             tokenizer_list.append((self.rust_tokenizer_class, self.get_rust_tokenizer())    )

        for tokenizer_class, tokenizer_utils in tokenizer_list:
             with tempfile.TemporaryDirectory() as tmp_dir:
                  tokenizer_utils.save_pretrained(lowerCAmelCase__    )

                  lowercase_			:       Tuple									=			tokenizer_class.from_pretrained(lowerCAmelCase__    )

                  self.assertTrue(tokenizer.decode([255]    ) == ''    )
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_			:       Dict									=			self.get_tokenizers(fast=lowerCAmelCase__  ,do_lower_case=lowerCAmelCase__    )
        for tokenizer in tokenizers:
             with self.subTest(f'''{tokenizer.__class__.__name__}'''    ):
                  lowercase_			:       Optional[int]									=			['t', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 'x', 't', '</s>']
                  lowercase_			:       List[str]									=			tokenizer.convert_tokens_to_string(lowerCAmelCase__    )

                  self.assertIsInstance(lowerCAmelCase__  ,lowerCAmelCase__    )







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


        '''simple docstring'''


        lowercase_			:       List[str]									=			self.get_tokenizers()
        for tokenizer in tokenizers:
             with self.subTest(f'''{tokenizer.__class__.__name__}'''    ):
                  lowercase_			:       List[str]									=			[
                      'bos_token',
                      'eos_token',
                      'unk_token',
                      'sep_token',
                      'pad_token',
                      'cls_token',
                      'mask_token',
                  ]

                  lowercase_			:       int									=			0
                  lowercase_			:       Union[str, Any]									=			tokenizer.convert_ids_to_tokens(
                      lowerCAmelCase__  ,skip_special_tokens=lowerCAmelCase__    )

                  for attr in attributes_list:
                       setattr(lowerCAmelCase__  ,attr + '_id'  ,lowerCAmelCase__    )
                       self.assertEqual(getattr(lowerCAmelCase__  ,lowerCAmelCase__    )  ,lowerCAmelCase__    )
                       self.assertEqual(getattr(lowerCAmelCase__  ,attr + '_id'    )  ,lowerCAmelCase__    )

                       setattr(lowerCAmelCase__  ,attr + '_id'  ,lowerCAmelCase__    )
                       self.assertEqual(getattr(lowerCAmelCase__  ,lowerCAmelCase__    )  ,lowerCAmelCase__    )
                       self.assertEqual(getattr(lowerCAmelCase__  ,attr + '_id'    )  ,lowerCAmelCase__    )

                  setattr(lowerCAmelCase__  ,'additional_special_tokens_ids'  ,[]    )
                  self.assertListEqual(getattr(lowerCAmelCase__  ,'additional_special_tokens'    )  ,[]    )
                  self.assertListEqual(getattr(lowerCAmelCase__  ,'additional_special_tokens_ids'    )  ,[]    )

                  setattr(lowerCAmelCase__  ,'additional_special_tokens_ids'  ,[token_id_to_test_setters]    )
                  self.assertListEqual(getattr(lowerCAmelCase__  ,'additional_special_tokens'    )  ,[token_to_test_setters]    )
                  self.assertListEqual(getattr(lowerCAmelCase__  ,'additional_special_tokens_ids'    )  ,[token_id_to_test_setters]    )


"""simple docstring"""







import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__SCREAMING_SNAKE_CASE								=logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE								={
    "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json",
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}







class  UpperCamelCase	(    lowercase_						):
   lowercase							=						'wav2vec2'
   def __init__(    self  ,__UpperCamelCase=32  ,__UpperCamelCase=768  ,__UpperCamelCase=12  ,__UpperCamelCase=12  ,__UpperCamelCase=3072  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.02  ,__UpperCamelCase=1e-5  ,__UpperCamelCase="group"  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=(512, 512, 512, 512, 512, 512, 512)  ,__UpperCamelCase=(5, 2, 2, 2, 2, 2, 2)  ,__UpperCamelCase=(10, 3, 3, 3, 3, 2, 2)  ,__UpperCamelCase=False  ,__UpperCamelCase=128  ,__UpperCamelCase=16  ,__UpperCamelCase=False  ,__UpperCamelCase=True  ,__UpperCamelCase=0.05  ,__UpperCamelCase=10  ,__UpperCamelCase=2  ,__UpperCamelCase=0.0  ,__UpperCamelCase=10  ,__UpperCamelCase=0  ,__UpperCamelCase=320  ,__UpperCamelCase=2  ,__UpperCamelCase=0.1  ,__UpperCamelCase=100  ,__UpperCamelCase=256  ,__UpperCamelCase=256  ,__UpperCamelCase=0.1  ,__UpperCamelCase="sum"  ,__UpperCamelCase=False  ,__UpperCamelCase=False  ,__UpperCamelCase=256  ,__UpperCamelCase=(512, 512, 512, 512, 1500)  ,__UpperCamelCase=(5, 3, 3, 1, 1)  ,__UpperCamelCase=(1, 2, 3, 1, 1)  ,__UpperCamelCase=512  ,__UpperCamelCase=0  ,__UpperCamelCase=1  ,__UpperCamelCase=2  ,__UpperCamelCase=False  ,__UpperCamelCase=3  ,__UpperCamelCase=2  ,__UpperCamelCase=3  ,__UpperCamelCase=None  ,__UpperCamelCase=None  ,**__UpperCamelCase  ,)			->   Optional[Any]:


        '''simple docstring'''


        super().__init__(**__UpperCamelCase  ,pad_token_id=__UpperCamelCase  ,bos_token_id=__UpperCamelCase  ,eos_token_id=__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			hidden_size
        lowercase_			:       Tuple									=			feat_extract_norm
        lowercase_			:       Dict									=			feat_extract_activation
        lowercase_			:       List[str]									=			list(__UpperCamelCase    )
        lowercase_			:       str									=			list(__UpperCamelCase    )
        lowercase_			:       Dict									=			list(__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			conv_bias
        lowercase_			:       Dict									=			num_conv_pos_embeddings
        lowercase_			:       List[str]									=			num_conv_pos_embedding_groups
        lowercase_			:       Optional[Any]									=			len(self.conv_dim    )
        lowercase_			:       Any									=			num_hidden_layers
        lowercase_			:       List[Any]									=			intermediate_size
        lowercase_			:       List[Any]									=			hidden_act
        lowercase_			:       Optional[int]									=			num_attention_heads
        lowercase_			:       int									=			hidden_dropout
        lowercase_			:       Dict									=			attention_dropout
        lowercase_			:       Union[str, Any]									=			activation_dropout
        lowercase_			:       Tuple									=			feat_proj_dropout
        lowercase_			:       List[str]									=			final_dropout
        lowercase_			:       Union[str, Any]									=			layerdrop
        lowercase_			:       List[str]									=			layer_norm_eps
        lowercase_			:       Optional[int]									=			initializer_range
        lowercase_			:       List[Any]									=			vocab_size
        lowercase_			:       Optional[int]									=			do_stable_layer_norm
        lowercase_			:       Union[str, Any]									=			use_weighted_layer_sum

        if (
            (len(self.conv_stride    ) != self.num_feat_extract_layers)
            or (len(self.conv_kernel    ) != self.num_feat_extract_layers)
            or (len(self.conv_dim    ) != self.num_feat_extract_layers)
        ):
             raise ValueError(
                 'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
                 ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
                 f''' {len(self.conv_dim    )}`, `len(config.conv_stride) = {len(self.conv_stride    )}`,'''
                 f''' `len(config.conv_kernel) = {len(self.conv_kernel    )}`.'''    )

        # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
        lowercase_			:       Dict									=			apply_spec_augment
        lowercase_			:       Optional[int]									=			mask_time_prob
        lowercase_			:       Union[str, Any]									=			mask_time_length
        lowercase_			:       List[str]									=			mask_time_min_masks
        lowercase_			:       List[str]									=			mask_feature_prob
        lowercase_			:       Any									=			mask_feature_length
        lowercase_			:       List[Any]									=			mask_feature_min_masks

        # parameters for pretraining with codevector quantized representations
        lowercase_			:       List[Any]									=			num_codevectors_per_group
        lowercase_			:       Optional[int]									=			num_codevector_groups
        lowercase_			:       Dict									=			contrastive_logits_temperature
        lowercase_			:       int									=			feat_quantizer_dropout
        lowercase_			:       Optional[int]									=			num_negatives
        lowercase_			:       str									=			codevector_dim
        lowercase_			:       str									=			proj_codevector_dim
        lowercase_			:       Optional[Any]									=			diversity_loss_weight

        # ctc loss
        lowercase_			:       Tuple									=			ctc_loss_reduction
        lowercase_			:       int									=			ctc_zero_infinity

        # adapter
        lowercase_			:       int									=			add_adapter
        lowercase_			:       Dict									=			adapter_kernel_size
        lowercase_			:       List[str]									=			adapter_stride
        lowercase_			:       Dict									=			num_adapter_layers
        lowercase_			:       Dict									=			output_hidden_size or hidden_size
        lowercase_			:       Optional[Any]									=			adapter_attn_dim

        # SequenceClassification-specific parameter. Feel free to ignore for other classes.
        lowercase_			:       Dict									=			classifier_proj_size

        # XVector-specific parameters. Feel free to ignore for other classes.
        lowercase_			:       Any									=			list(__UpperCamelCase    )
        lowercase_			:       str									=			list(__UpperCamelCase    )
        lowercase_			:       Any									=			list(__UpperCamelCase    )
        lowercase_			:       Tuple									=			xvector_output_dim







   @property
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        return functools.reduce(operator.mul  ,self.conv_stride  ,1    )

