"""simple docstring"""







import unittest

import numpy as np
import timeout_decorator  # noqa

from transformers import BlenderbotConfig, is_flax_available
from transformers.testing_utils import jax_device, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor


if is_flax_available():
       import os

       # The slow tests are often failing with OOM error on GPU
       # This makes JAX allocate exactly what is needed on demand, and deallocate memory that is no longer needed
       # but will be slower as stated here https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html
       __SCREAMING_SNAKE_CASE								="platform"

       import jax
       import jax.numpy as jnp

       from transformers import BlenderbotTokenizer
       from transformers.models.blenderbot.modeling_flax_blenderbot import (
           FlaxBlenderbotForConditionalGeneration,
           FlaxBlenderbotModel,
           shift_tokens_right,
       )



def     lowercase__( __SCREAMING_SNAKE_CASE							:  Tuple  ,    __SCREAMING_SNAKE_CASE							:  Any  ,    __SCREAMING_SNAKE_CASE							:  Dict=None  ,    __SCREAMING_SNAKE_CASE							:  Optional[int]=None  ,    __SCREAMING_SNAKE_CASE							:  Union[str, Any]=None  ,    __SCREAMING_SNAKE_CASE							:  List[Any]=None  ,    __SCREAMING_SNAKE_CASE							:  List[str]=None  ,    __SCREAMING_SNAKE_CASE							:  Tuple=None  ,    ):
     if attention_mask is None:
          lowercase_			:       Dict									=			np.where(input_ids != config.pad_token_id  ,    1  ,    0   )
     if decoder_attention_mask is None:
          lowercase_			:       List[str]									=			np.where(decoder_input_ids != config.pad_token_id  ,    1  ,    0   )
     if head_mask is None:
          lowercase_			:       Dict									=			np.ones((config.encoder_layers, config.encoder_attention_heads)   )
     if decoder_head_mask is None:
          lowercase_			:       int									=			np.ones((config.decoder_layers, config.decoder_attention_heads)   )
     if cross_attn_head_mask is None:
          lowercase_			:       List[Any]									=			np.ones((config.decoder_layers, config.decoder_attention_heads)   )
     return {
         "input_ids": input_ids,
         "decoder_input_ids": decoder_input_ids,
         "attention_mask": attention_mask,
         "decoder_attention_mask": attention_mask,
     }







class  UpperCamelCase	:
   def __init__(    self  ,__UpperCamelCase  ,__UpperCamelCase=13  ,__UpperCamelCase=7  ,__UpperCamelCase=True  ,__UpperCamelCase=False  ,__UpperCamelCase=99  ,__UpperCamelCase=16  ,__UpperCamelCase=2  ,__UpperCamelCase=4  ,__UpperCamelCase=4  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=32  ,__UpperCamelCase=2  ,__UpperCamelCase=1  ,__UpperCamelCase=0  ,__UpperCamelCase=0.02  ,)			->   Any:


        '''simple docstring'''


        lowercase_			:       Tuple									=			parent
        lowercase_			:       Optional[int]									=			batch_size
        lowercase_			:       Optional[Any]									=			seq_length
        lowercase_			:       Any									=			is_training
        lowercase_			:       Dict									=			use_labels
        lowercase_			:       Any									=			vocab_size
        lowercase_			:       Optional[int]									=			hidden_size
        lowercase_			:       Tuple									=			num_hidden_layers
        lowercase_			:       Tuple									=			num_attention_heads
        lowercase_			:       List[Any]									=			intermediate_size
        lowercase_			:       str									=			hidden_act
        lowercase_			:       Optional[Any]									=			hidden_dropout_prob
        lowercase_			:       Dict									=			attention_probs_dropout_prob
        lowercase_			:       Dict									=			max_position_embeddings
        lowercase_			:       List[str]									=			eos_token_id
        lowercase_			:       Union[str, Any]									=			pad_token_id
        lowercase_			:       int									=			bos_token_id
        lowercase_			:       Dict									=			initializer_range
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        lowercase_			:       int									=			np.clip(ids_tensor([self.batch_size, self.seq_length - 1]  ,self.vocab_size    )  ,3  ,self.vocab_size    )
        lowercase_			:       Any									=			np.concatenate((input_ids, 2 * np.ones((self.batch_size, 1)  ,dtype=np.intaa    ))  ,-1    )

        lowercase_			:       List[str]									=			shift_tokens_right(__UpperCamelCase  ,1  ,2    )

        lowercase_			:       List[str]									=			BlenderbotConfig(
            vocab_size=self.vocab_size  ,d_model=self.hidden_size  ,encoder_layers=self.num_hidden_layers  ,decoder_layers=self.num_hidden_layers  ,encoder_attention_heads=self.num_attention_heads  ,decoder_attention_heads=self.num_attention_heads  ,encoder_ffn_dim=self.intermediate_size  ,decoder_ffn_dim=self.intermediate_size  ,dropout=self.hidden_dropout_prob  ,attention_dropout=self.attention_probs_dropout_prob  ,max_position_embeddings=self.max_position_embeddings  ,eos_token_id=self.eos_token_id  ,bos_token_id=self.bos_token_id  ,pad_token_id=self.pad_token_id  ,initializer_range=self.initializer_range  ,use_cache=__UpperCamelCase  ,)
        lowercase_			:       Tuple									=			prepare_blenderbot_inputs_dict(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )
        return config, inputs_dict
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_							,						lowercase_			:       List[Any]									=			self.prepare_config_and_inputs()
        return config, inputs_dict
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   str:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			20
        lowercase_			:       Union[str, Any]									=			model_class_name(__UpperCamelCase    )

        lowercase_			:       List[str]									=			model.encode(inputs_dict['input_ids']    )

        lowercase_							,						lowercase_			:       Union[str, Any]									=			(
            inputs_dict['decoder_input_ids'],
            inputs_dict['decoder_attention_mask'],
        )

        lowercase_			:       int									=			model.init_cache(decoder_input_ids.shape[0]  ,__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			jnp.ones((decoder_input_ids.shape[0], max_decoder_length)  ,dtype='i4'    )

        lowercase_			:       Optional[int]									=			jnp.broadcast_to(
            jnp.arange(decoder_input_ids.shape[-1] - 1    )[None, :]  ,(decoder_input_ids.shape[0], decoder_input_ids.shape[-1] - 1)  ,)
        lowercase_			:       Optional[Any]									=			model.decode(
            decoder_input_ids[:, :-1]  ,__UpperCamelCase  ,decoder_attention_mask=__UpperCamelCase  ,past_key_values=__UpperCamelCase  ,decoder_position_ids=__UpperCamelCase  ,)

        lowercase_			:       List[Any]									=			jnp.array(decoder_input_ids.shape[0] * [[decoder_input_ids.shape[-1] - 1]]  ,dtype='i4'    )
        lowercase_			:       str									=			model.decode(
            decoder_input_ids[:, -1:]  ,__UpperCamelCase  ,decoder_attention_mask=__UpperCamelCase  ,past_key_values=outputs_cache.past_key_values  ,decoder_position_ids=__UpperCamelCase  ,)

        lowercase_			:       Tuple									=			model.decode(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Any									=			np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])    )    )
        self.parent.assertTrue(diff < 1e-3  ,msg=f'''Max diff is {diff}'''    )







   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_			:       List[str]									=			20
        lowercase_			:       Optional[int]									=			model_class_name(__UpperCamelCase    )

        lowercase_			:       str									=			model.encode(inputs_dict['input_ids']    )

        lowercase_							,						lowercase_			:       Dict									=			(
            inputs_dict['decoder_input_ids'],
            inputs_dict['decoder_attention_mask'],
        )

        lowercase_			:       List[str]									=			jnp.concatenate(
            [
                decoder_attention_mask,
                jnp.zeros((decoder_attention_mask.shape[0], max_decoder_length - decoder_attention_mask.shape[1])    ),
            ]  ,axis=-1  ,)

        lowercase_			:       Tuple									=			model.init_cache(decoder_input_ids.shape[0]  ,__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       List[str]									=			jnp.broadcast_to(
            jnp.arange(decoder_input_ids.shape[-1] - 1    )[None, :]  ,(decoder_input_ids.shape[0], decoder_input_ids.shape[-1] - 1)  ,)

        lowercase_			:       List[Any]									=			model.decode(
            decoder_input_ids[:, :-1]  ,__UpperCamelCase  ,decoder_attention_mask=__UpperCamelCase  ,past_key_values=__UpperCamelCase  ,decoder_position_ids=__UpperCamelCase  ,)
        lowercase_			:       List[str]									=			jnp.array(decoder_input_ids.shape[0] * [[decoder_input_ids.shape[-1] - 1]]  ,dtype='i4'    )
        lowercase_			:       Optional[Any]									=			model.decode(
            decoder_input_ids[:, -1:]  ,__UpperCamelCase  ,past_key_values=outputs_cache.past_key_values  ,decoder_attention_mask=__UpperCamelCase  ,decoder_position_ids=__UpperCamelCase  ,)

        lowercase_			:       Optional[Any]									=			model.decode(__UpperCamelCase  ,__UpperCamelCase  ,decoder_attention_mask=__UpperCamelCase    )

        lowercase_			:       int									=			np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])    )    )
        self.parent.assertTrue(diff < 1e-3  ,msg=f'''Max diff is {diff}'''    )







@require_flax
class  UpperCamelCase	(    unittest.TestCase						):
   lowercase							=						9_9
   def     _UpperCAmelCase     (    self    )			->   Union[str, Any]:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			np.array(
            [
                [71, 82, 18, 33, 46, 91, 2],
                [68, 34, 26, 58, 30, 82, 2],
                [5, 97, 17, 39, 94, 40, 2],
                [76, 83, 94, 25, 70, 78, 2],
                [87, 59, 41, 35, 48, 66, 2],
                [55, 13, 16, 58, 5, 2, 1],  # note padding
                [64, 27, 31, 51, 12, 75, 2],
                [52, 64, 86, 17, 83, 39, 2],
                [48, 61, 9, 24, 71, 82, 2],
                [26, 1, 60, 48, 22, 13, 2],
                [21, 5, 62, 28, 14, 76, 2],
                [45, 98, 37, 86, 59, 48, 2],
                [70, 70, 50, 9, 28, 0, 2],
            ]  ,dtype=np.intaa  ,)

        lowercase_			:       Dict									=			input_ids.shape[0]
        lowercase_			:       Any									=			BlenderbotConfig(
            vocab_size=self.vocab_size  ,d_model=24  ,encoder_layers=2  ,decoder_layers=2  ,encoder_attention_heads=2  ,decoder_attention_heads=2  ,encoder_ffn_dim=32  ,decoder_ffn_dim=32  ,max_position_embeddings=48  ,eos_token_id=2  ,pad_token_id=1  ,bos_token_id=0  ,)
        return config, input_ids, batch_size
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_							,						lowercase_							,						lowercase_			:       Optional[int]									=			self._get_config_and_data()
        lowercase_			:       str									=			FlaxBlenderbotForConditionalGeneration(__UpperCamelCase    )
        lowercase_			:       int									=			lm_model(input_ids=__UpperCamelCase    )
        lowercase_			:       List[str]									=			(batch_size, input_ids.shape[1], config.vocab_size)
        self.assertEqual(outputs['logits'].shape  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Union[str, Any]:


        '''simple docstring'''


        lowercase_			:       str									=			BlenderbotConfig(
            vocab_size=self.vocab_size  ,d_model=14  ,encoder_layers=2  ,decoder_layers=2  ,encoder_attention_heads=2  ,decoder_attention_heads=2  ,encoder_ffn_dim=8  ,decoder_ffn_dim=8  ,max_position_embeddings=48  ,)
        lowercase_			:       Optional[int]									=			FlaxBlenderbotForConditionalGeneration(__UpperCamelCase    )
        lowercase_			:       Tuple									=			np.array([[71, 82, 18, 33, 46, 91, 2], [68, 34, 26, 58, 30, 2, 1]]  ,dtype=np.intaa    )
        lowercase_			:       str									=			np.array([[82, 71, 82, 18, 2], [58, 68, 2, 1, 1]]  ,dtype=np.intaa    )
        lowercase_			:       Any									=			lm_model(input_ids=__UpperCamelCase  ,decoder_input_ids=__UpperCamelCase    )
        lowercase_			:       Union[str, Any]									=			(*summary.shape, config.vocab_size)
        self.assertEqual(outputs['logits'].shape  ,__UpperCamelCase    )







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


        '''simple docstring'''


        lowercase_			:       Any									=			np.array([[71, 82, 18, 33, 2, 1, 1], [68, 34, 26, 58, 30, 82, 2]]  ,dtype=np.intaa    )
        lowercase_			:       Any									=			shift_tokens_right(__UpperCamelCase  ,1  ,2    )
        lowercase_			:       Optional[Any]									=			np.equal(__UpperCamelCase  ,1    ).astype(np.floataa    ).sum()
        lowercase_			:       Optional[int]									=			np.equal(__UpperCamelCase  ,1    ).astype(np.floataa    ).sum()
        self.assertEqual(shifted.shape  ,input_ids.shape    )
        self.assertEqual(__UpperCamelCase  ,n_pad_before - 1    )
        self.assertTrue(np.equal(shifted[:, 0]  ,2    ).all()    )







@require_flax
class  UpperCamelCase	(    lowercase_		,   unittest.TestCase		,   lowercase_						):
   lowercase							=						True
   lowercase							=						(
       (
           FlaxBlenderbotModel,
           FlaxBlenderbotForConditionalGeneration,
       )
       if is_flax_available()
       else ()
   )
   lowercase							=						(FlaxBlenderbotForConditionalGeneration,) if is_flax_available() else ()
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        lowercase_			:       Tuple									=			FlaxBlenderbotModelTester(self    )
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_							,						lowercase_			:       Any									=			self.model_tester.prepare_config_and_inputs()
        for model_class in self.all_model_classes:
             self.model_tester.check_use_cache_forward(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_							,						lowercase_			:       str									=			self.model_tester.prepare_config_and_inputs()
        for model_class in self.all_model_classes:
             self.model_tester.check_use_cache_forward_with_attn_mask(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        lowercase_							,						lowercase_			:       Optional[int]									=			self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__    ):
                  lowercase_			:       str									=			self._prepare_for_class(__UpperCamelCase  ,__UpperCamelCase    )
                  lowercase_			:       str									=			model_class(__UpperCamelCase    )

                  @jax.jit
                  def encode_jitted(__UpperCamelCase  ,__UpperCamelCase=None  ,**__UpperCamelCase    ):
                       return model.encode(input_ids=__UpperCamelCase  ,attention_mask=__UpperCamelCase    )

                  with self.subTest('JIT Enabled'    ):
                       lowercase_			:       Optional[Any]									=			encode_jitted(**__UpperCamelCase    ).to_tuple()

                  with self.subTest('JIT Disabled'    ):
                       with jax.disable_jit():
                            lowercase_			:       Dict									=			encode_jitted(**__UpperCamelCase    ).to_tuple()

                  self.assertEqual(len(__UpperCamelCase    )  ,len(__UpperCamelCase    )    )
                  for jitted_output, output in zip(__UpperCamelCase  ,__UpperCamelCase    ):
                       self.assertEqual(jitted_output.shape  ,output.shape    )
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_							,						lowercase_			:       Union[str, Any]									=			self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__    ):
                  lowercase_			:       List[str]									=			model_class(__UpperCamelCase    )
                  lowercase_			:       Optional[Any]									=			model.encode(inputs_dict['input_ids']  ,inputs_dict['attention_mask']    )

                  lowercase_			:       List[str]									=			{
                      'decoder_input_ids': inputs_dict['decoder_input_ids'],
                      'decoder_attention_mask': inputs_dict['decoder_attention_mask'],
                      'encoder_outputs': encoder_outputs,
                  }

                  @jax.jit
                  def decode_jitted(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    ):
                       return model.decode(
                           decoder_input_ids=__UpperCamelCase  ,decoder_attention_mask=__UpperCamelCase  ,encoder_outputs=__UpperCamelCase  ,)

                  with self.subTest('JIT Enabled'    ):
                       lowercase_			:       Dict									=			decode_jitted(**__UpperCamelCase    ).to_tuple()

                  with self.subTest('JIT Disabled'    ):
                       with jax.disable_jit():
                            lowercase_			:       List[str]									=			decode_jitted(**__UpperCamelCase    ).to_tuple()

                  self.assertEqual(len(__UpperCamelCase    )  ,len(__UpperCamelCase    )    )
                  for jitted_output, output in zip(__UpperCamelCase  ,__UpperCamelCase    ):
                       self.assertEqual(jitted_output.shape  ,output.shape    )
   @slow
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        for model_class_name in self.all_model_classes:
             lowercase_			:       Dict									=			model_class_name.from_pretrained('facebook/blenderbot-400M-distill'    )
             # FlaxBlenderbotForSequenceClassification expects eos token in input_ids
             lowercase_			:       Optional[int]									=			np.ones((1, 1)    ) * model.config.eos_token_id
             lowercase_			:       Dict									=			model(__UpperCamelCase    )
             self.assertIsNotNone(__UpperCamelCase    )







   @unittest.skipUnless(jax_device != 'cpu'  ,'3B test too slow on CPU.'    )
   @slow
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        lowercase_			:       Tuple									=			{'num_beams': 1, 'early_stopping': True, 'min_length': 15, 'max_length': 25}
        lowercase_			:       Optional[int]									=			{'skip_special_tokens': True, 'clean_up_tokenization_spaces': True}

        lowercase_			:       List[str]									=			FlaxBlenderbotForConditionalGeneration.from_pretrained('facebook/blenderbot-3B'  ,from_pt=__UpperCamelCase    )
        lowercase_			:       Union[str, Any]									=			BlenderbotTokenizer.from_pretrained('facebook/blenderbot-3B'    )

        lowercase_			:       List[Any]									=			['Sam']
        lowercase_			:       Optional[int]									=			tokenizer(__UpperCamelCase  ,return_tensors='jax'    )

        lowercase_			:       str									=			model.generate(**__UpperCamelCase  ,**__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			'Sam is a great name. It means "sun" in Gaelic.'

        lowercase_			:       Optional[Any]									=			tokenizer.batch_decode(__UpperCamelCase  ,**__UpperCamelCase    )
        assert generated_txt[0].strip() == tgt_text


"""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    )

