"""simple docstring"""





from __future__ import annotations

import unittest

import numpy as np

from transformers import OPTConfig, is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
			import tensorflow as tf

			from transformers import GPTaTokenizer, TFOPTForCausalLM, TFOPTModel



def      lowerCamelCase_(__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE=None     ,	__SCREAMING_SNAKE_CASE=None  )->    Dict:
							if attention_mask is None:
														_SCREAMING_SNAKE_CASE		:						str			  =    tf.cast(tf.math.not_equal(__SCREAMING_SNAKE_CASE     ,	config.pad_token_id  )     ,	tf.inta  )
							return {"input_ids": input_ids, "attention_mask": attention_mask}




@require_tf
class  _snake_case		:







				"""simple docstring"""






				a			=						OPTConfig
				a			=						{}
				a			=						"gelu"





				def __init__(      self							:							Any      ,    _A							:							Optional[Any]      ,    _A							:							Optional[int]=1_3      ,    _A							:							Optional[Any]=7      ,    _A							:							List[str]=True      ,    _A							:							Tuple=False      ,    _A							:							int=9_9      ,    _A							:							Dict=1_6      ,    _A							:							List[Any]=2      ,    _A							:							Tuple=4      ,    _A							:							List[str]=4      ,    _A							:							List[Any]="gelu"      ,    _A							:							int=0.1      ,    _A							:							List[Any]=0.1      ,    _A							:							Dict=2_0      ,    _A							:							int=2      ,    _A							:							Optional[Any]=1      ,    _A							:							str=0      ,    _A							:							Tuple=1_6      ,    _A							:							Optional[Any]=1_6      ,    ):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    parent
											_SCREAMING_SNAKE_CASE		:						Dict			  =    batch_size
											_SCREAMING_SNAKE_CASE		:						Dict			  =    seq_length
											_SCREAMING_SNAKE_CASE		:						str			  =    is_training
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    use_labels
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    vocab_size
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						str			  =    num_hidden_layers
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    num_attention_heads
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    intermediate_size
											_SCREAMING_SNAKE_CASE		:						Dict			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    hidden_dropout_prob
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    attention_probs_dropout_prob
											_SCREAMING_SNAKE_CASE		:						int			  =    max_position_embeddings
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    eos_token_id
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    pad_token_id
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    bos_token_id
											_SCREAMING_SNAKE_CASE		:						Any			  =    embed_dim
											_SCREAMING_SNAKE_CASE		:						str			  =    word_embed_proj_dim
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    False





				def 		_lowerCAmelCase		(      self							:							Dict):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						List[str]			  =    ids_tensor([self.batch_size, self.seq_length - 1]      ,    self.vocab_size)
											_SCREAMING_SNAKE_CASE		:						int			  =    tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size)      ,    1)
											_SCREAMING_SNAKE_CASE		:						str			  =    tf.concat([input_ids, eos_tensor]      ,    axis=1)

											_SCREAMING_SNAKE_CASE		:						Dict			  =    self.config_cls(
											    vocab_size=self.vocab_size      ,    hidden_size=self.hidden_size      ,    num_hidden_layers=self.num_hidden_layers      ,    num_attention_heads=self.num_attention_heads      ,    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      ,    embed_dim=self.embed_dim      ,    word_embed_proj_dim=self.word_embed_proj_dim      ,    is_encoder_decoder=_A      ,    **self.config_updates      ,    )
											_SCREAMING_SNAKE_CASE		:						str			  =    prepare_opt_inputs_dict(_A      ,    _A)
											return config, inputs_dict





				def 		_lowerCAmelCase		(      self							:							List[str]      ,    _A							:							Tuple      ,    _A							:							Dict):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    TFOPTModel(config=_A)
											_SCREAMING_SNAKE_CASE		:						Any			  =    inputs_dict["""input_ids"""]

											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    input_ids[:1, :]
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    inputs_dict["""attention_mask"""][:1, :]
											_SCREAMING_SNAKE_CASE		:						Dict			  =    1

											# first forward pass
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    model(_A      ,    attention_mask=_A      ,    use_cache=_A)

											_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    outputs.to_tuple()

											# create hypothetical next token and extent to next_input_ids
											_SCREAMING_SNAKE_CASE		:						int			  =    ids_tensor((self.batch_size, 3)      ,    config.vocab_size)
											_SCREAMING_SNAKE_CASE		:						int			  =    tf.cast(ids_tensor((self.batch_size, 3)      ,    2)      ,    tf.inta)

											# append to next input_ids and
											_SCREAMING_SNAKE_CASE		:						Any			  =    tf.concat([input_ids, next_tokens]      ,    axis=-1)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    tf.concat([attention_mask, next_attn_mask]      ,    axis=-1)

											_SCREAMING_SNAKE_CASE		:						List[str]			  =    model(_A      ,    attention_mask=_A)[0]
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    model(_A      ,    attention_mask=_A      ,    past_key_values=_A)[0]

											self.parent.assertEqual(next_tokens.shape[1]      ,    output_from_past.shape[1])

											# select random slice
											_SCREAMING_SNAKE_CASE		:						Any			  =    int(ids_tensor((1,)      ,    output_from_past.shape[-1]))
											_SCREAMING_SNAKE_CASE		:						Dict			  =    output_from_no_past[:, -3:, random_slice_idx]
											_SCREAMING_SNAKE_CASE		:						str			  =    output_from_past[:, :, random_slice_idx]

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




@require_tf
class  _snake_case		(    __snake_case   ,       __snake_case   ,       unittest.TestCase ):







				"""simple docstring"""






				a			=						(TFOPTModel, TFOPTForCausalLM) if is_tf_available() else ()
				a			=						(TFOPTForCausalLM,) if is_tf_available() else ()
				a			=						(
				    {"feature-extraction": TFOPTModel, "text-generation": TFOPTForCausalLM} if is_tf_available() else {}
				)
				a			=						False
				a			=						False
				a			=						False
				a			=						10





				def 		_lowerCAmelCase		(      self							:							List[Any]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						int			  =    TFOPTModelTester(self)
											_SCREAMING_SNAKE_CASE		:						Dict			  =    ConfigTester(self      ,    config_class=_A)





				def 		_lowerCAmelCase		(      self							:							Union[str, Any]):



											"""simple docstring"""







											self.config_tester.run_common_tests()





				def 		_lowerCAmelCase		(      self							:							str):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Dict			  =    self.model_tester.prepare_config_and_inputs_for_common()
											self.model_tester.check_decoder_model_past_large_inputs(*_A)





				def 		_lowerCAmelCase		(      self							:							Any):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE		:						List[str]			  =    self.model_tester.prepare_config_and_inputs_for_common()

											def _get_word_embedding_weight(_A							:							str      ,    _A							:							Union[str, Any]):
																		if hasattr(_A      ,    """weight"""):
																									return embedding_layer.weight
																		else:
																									# Here we build the word embeddings weights if not exists.
																									# And then we retry to get the attribute once built.
																									model.build()
																									if hasattr(_A      ,    """weight"""):
																																return embedding_layer.weight
																									else:
																																return None

											for model_class in self.all_model_classes:
																		for size in [config.vocab_size - 1_0, config.vocab_size + 1_0]:
																									# build the embeddings
																									_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    model_class(config=_A)
																									_SCREAMING_SNAKE_CASE		:						int			  =    _get_word_embedding_weight(_A      ,    model.get_input_embeddings())
																									_SCREAMING_SNAKE_CASE		:						List[Any]			  =    _get_word_embedding_weight(_A      ,    model.get_output_embeddings())

																									# reshape the embeddings
																									model.resize_token_embeddings(_A)
																									_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    _get_word_embedding_weight(_A      ,    model.get_input_embeddings())
																									_SCREAMING_SNAKE_CASE		:						Tuple			  =    _get_word_embedding_weight(_A      ,    model.get_output_embeddings())

																									# check that the resized embeddings size matches the desired size.
																									_SCREAMING_SNAKE_CASE		:						Tuple			  =    size if size is not None else config.vocab_size

																									self.assertEqual(new_input_embeddings.shape[0]      ,    _A)

																									# check that weights remain the same after resizing
																									_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    True
																									for pa, pa in zip(old_input_embeddings.value()      ,    new_input_embeddings.value()):
																																if tf.math.reduce_sum(tf.math.abs(pa - pa)) > 0:
																																							_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    False
																									self.assertTrue(_A)

																									if old_output_embeddings is not None and new_output_embeddings is not None:
																																self.assertEqual(new_output_embeddings.shape[0]      ,    _A)

																																_SCREAMING_SNAKE_CASE		:						Tuple			  =    True
																																for pa, pa in zip(old_output_embeddings.value()      ,    new_output_embeddings.value()):
																																							if tf.math.reduce_sum(tf.math.abs(pa - pa)) > 0:
																																														_SCREAMING_SNAKE_CASE		:						int			  =    False
																																self.assertTrue(_A)



def      lowerCamelCase_(__SCREAMING_SNAKE_CASE  )->    Dict:
							return tf.constant(__SCREAMING_SNAKE_CASE     ,	dtype=tf.intaa  )




@require_tf
class  _snake_case		(    unittest.TestCase ):







				"""simple docstring"""






				a			=						99





				def 		_lowerCAmelCase		(      self							:							Tuple):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						int			  =    tf.ones((4, 1)      ,    dtype=tf.intaa) * 2
											_SCREAMING_SNAKE_CASE		:						str			  =    tf.concat([ids_tensor((4, 6)      ,    self.vocab_size - 3) + 3, eos_column_vector]      ,    axis=1)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    input_ids.shape[0]
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    OPTConfig(
											    vocab_size=self.vocab_size      ,    hidden_size=2_4      ,    num_hidden_layers=2      ,    num_attention_heads=2      ,    ffn_dim=3_2      ,    max_position_embeddings=4_8      ,    eos_token_id=2      ,    pad_token_id=1      ,    bos_token_id=0      ,    )
											return config, input_ids, batch_size




@require_sentencepiece
@require_tf
class  _snake_case		(    unittest.TestCase ):







				"""simple docstring"""






				@slow
				def 		_lowerCAmelCase		(      self							:							List[Any]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    TFOPTModel.from_pretrained("""facebook/opt-350m""")
											_SCREAMING_SNAKE_CASE		:						Any			  =    _long_tensor([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]])
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    tf.not_equal(_A      ,    model.config.pad_token_id)
											with tf.GradientTape():
																		_SCREAMING_SNAKE_CASE		:						Tuple			  =    model(input_ids=_A      ,    attention_mask=_A).last_hidden_state
											_SCREAMING_SNAKE_CASE		:						Any			  =    (1, 1_1, 5_1_2)
											self.assertEqual(output.shape      ,    _A)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    tf.constant(
											    [[-0.2_873, -1.9_218, -0.3_033], [-1.2_710, -0.1_338, -0.1_902], [0.4_095, 0.1_214, -1.3_121]])
											self.assertTrue(np.allclose(output[:, :3, :3]      ,    _A      ,    atol=4e-3))

											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    tf.function(_A      ,    jit_compile=_A)
											_SCREAMING_SNAKE_CASE		:						Dict			  =    xla_generate(_A      ,    _A)[0]
											self.assertTrue(np.allclose(output[:, :3, :3]      ,    _A      ,    atol=4e-2))




@require_tf
@slow
class  _snake_case		(    unittest.TestCase ):







				"""simple docstring"""






				def 		_lowerCAmelCase		(      self							:							Optional[Any]):



											"""simple docstring"""







											super().setUp()
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    """facebook/opt-350m"""





				def 		_lowerCAmelCase		(      self							:							Optional[int]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    TFOPTForCausalLM.from_pretrained(self.path_model)
											_SCREAMING_SNAKE_CASE		:						int			  =    GPTaTokenizer.from_pretrained(self.path_model)

											_SCREAMING_SNAKE_CASE		:						Dict			  =    [
											    """Today is a beautiful day and I want to""",
											    """In the city of""",
											    """Paris is the capital of France and""",
											    """Computers and mobile phones have taken""",
											]
											# verify that prompt without BOS token is identical to Metaseq -> add_special_tokens=False
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    tokenizer(_A      ,    return_tensors="""tf"""      ,    padding=_A      ,    add_special_tokens=_A)
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    tf.math.reduce_mean(model(inputs.input_ids      ,    attention_mask=inputs.attention_mask)[0]      ,    axis=-1)
											_SCREAMING_SNAKE_CASE		:						int			  =    tf.constant(
											    [
											        [1.3_851, -13.8_923, -10.5_229, -10.7_533, -0.2_309, -10.2_384, -0.5_365, -9.0_947, -5.1_670],
											        [-4.7_073, -10.6_276, -3.9_415, -21.5_242, -0.2_822, -0.2_822, -0.2_822, -0.2_822, -0.2_822],
											        [0.6_247, -3.4_229, -8.9_179, -1.4_297, -14.1_650, 1.4_146, -9.0_218, -0.2_703, -0.2_703],
											        [6.4_783, -1.9_913, -10.7_926, -2.3_336, 1.5_092, -0.9_974, -6.8_213, 1.3_477, 1.3_477],
											    ])
											self.assertTrue(np.allclose(_A      ,    _A      ,    atol=1e-4))

											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    tf.function(_A      ,    jit_compile=_A)
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    tf.math.reduce_mean(xla_generate(inputs.input_ids      ,    attention_mask=inputs.attention_mask)[0]      ,    axis=-1)
											self.assertTrue(np.allclose(_A      ,    _A      ,    atol=1e-4))




@require_tf
@slow
class  _snake_case		(    unittest.TestCase ):







				"""simple docstring"""






				@property
				def 		_lowerCAmelCase		(      self							:							Optional[int]):



											"""simple docstring"""







											return [
											    "Today is a beautiful day and I want",
											    "In the city of",
											    "Paris is the capital of France and",
											    "Computers and mobile phones have taken",
											]





				def 		_lowerCAmelCase		(      self							:							Tuple):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Dict			  =    """facebook/opt-125m"""

											_SCREAMING_SNAKE_CASE		:						Dict			  =    [
											    """Today is a beautiful day and I want to""",
											    """In the city of New York, the city""",
											    """Paris is the capital of France and the capital""",
											    """Computers and mobile phones have taken over the""",
											]

											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    []
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    GPTaTokenizer.from_pretrained(_A)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    TFOPTForCausalLM.from_pretrained(_A)

											for prompt in self.prompts:
																		_SCREAMING_SNAKE_CASE		:						List[Any]			  =    tokenizer(_A      ,    return_tensors="""tf""").input_ids

																		_SCREAMING_SNAKE_CASE		:						Any			  =    model.generate(_A      ,    max_length=1_0)

																		_SCREAMING_SNAKE_CASE		:						Any			  =    tokenizer.batch_decode(_A      ,    skip_special_tokens=_A)
																		predicted_outputs += generated_string

											self.assertListEqual(_A      ,    _A)





				def 		_lowerCAmelCase		(      self							:							Dict):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Dict			  =    """facebook/opt-350m"""

											_SCREAMING_SNAKE_CASE		:						Dict			  =    GPTaTokenizer.from_pretrained(_A)
											_SCREAMING_SNAKE_CASE		:						Any			  =    TFOPTForCausalLM.from_pretrained(_A)

											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    """left"""

											# use different length sentences to test batching
											_SCREAMING_SNAKE_CASE		:						int			  =    [
											    """Hello, my dog is a little""",
											    """Today, I""",
											]

											_SCREAMING_SNAKE_CASE		:						Any			  =    tokenizer(_A      ,    return_tensors="""tf"""      ,    padding=_A)
											_SCREAMING_SNAKE_CASE		:						int			  =    inputs["""input_ids"""]

											_SCREAMING_SNAKE_CASE		:						List[str]			  =    model.generate(input_ids=_A      ,    attention_mask=inputs["""attention_mask"""])

											_SCREAMING_SNAKE_CASE		:						Tuple			  =    tokenizer(sentences[0]      ,    return_tensors="""tf""").input_ids
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    model.generate(input_ids=_A)

											_SCREAMING_SNAKE_CASE		:						str			  =    inputs_non_padded.shape[-1] - tf.math.reduce_sum(
											    tf.cast(inputs["""attention_mask"""][-1]      ,    tf.intaa))
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    tokenizer(sentences[1]      ,    return_tensors="""tf""").input_ids
											_SCREAMING_SNAKE_CASE		:						Dict			  =    model.generate(input_ids=_A      ,    max_length=model.config.max_length - num_paddings)

											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    tokenizer.batch_decode(_A      ,    skip_special_tokens=_A)
											_SCREAMING_SNAKE_CASE		:						str			  =    tokenizer.decode(output_non_padded[0]      ,    skip_special_tokens=_A)
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    tokenizer.decode(output_padded[0]      ,    skip_special_tokens=_A)

											_SCREAMING_SNAKE_CASE		:						int			  =    [
											    """Hello, my dog is a little bit of a dork.\nI'm a little bit""",
											    """Today, I was in the middle of a conversation with a friend about the""",
											]
											self.assertListEqual(_A      ,    _A)
											self.assertListEqual(_A      ,    [non_padded_sentence, padded_sentence])





				def 		_lowerCAmelCase		(      self							:							List[str]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    """facebook/opt-350m"""

											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    [
											    """Today is a beautiful day and I want to""",
											    """In the city of San Francisco, the city""",
											    """Paris is the capital of France and the capital""",
											    """Computers and mobile phones have taken over the""",
											]

											_SCREAMING_SNAKE_CASE		:						Tuple			  =    []
											_SCREAMING_SNAKE_CASE		:						str			  =    GPTaTokenizer.from_pretrained(_A)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    TFOPTForCausalLM.from_pretrained(_A)

											for prompt in self.prompts:
																		_SCREAMING_SNAKE_CASE		:						List[Any]			  =    tokenizer(_A      ,    return_tensors="""tf""").input_ids

																		_SCREAMING_SNAKE_CASE		:						Tuple			  =    model.generate(_A      ,    max_length=1_0)

																		_SCREAMING_SNAKE_CASE		:						str			  =    tokenizer.batch_decode(_A      ,    skip_special_tokens=_A)
																		predicted_outputs += generated_string

											self.assertListEqual(_A      ,    _A)



"""simple docstring"""





import functools
import operator

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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json''',
    # See all SEW models at https://huggingface.co/models?filter=sew
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"sew"





				def __init__(      self							:							List[Any]      ,    _A							:							Tuple=3_2      ,    _A							:							str=7_6_8      ,    _A							:							Dict=1_2      ,    _A							:							Tuple=1_2      ,    _A							:							Optional[Any]=3_0_7_2      ,    _A							:							List[str]=2      ,    _A							:							Dict="gelu"      ,    _A							:							Union[str, Any]=0.1      ,    _A							:							Optional[int]=0.1      ,    _A							:							Optional[int]=0.1      ,    _A							:							Optional[int]=0.0      ,    _A							:							str=0.1      ,    _A							:							Tuple=0.1      ,    _A							:							Optional[int]=0.02      ,    _A							:							Dict=1e-5      ,    _A							:							str="group"      ,    _A							:							Tuple="gelu"      ,    _A							:							Union[str, Any]=(6_4, 1_2_8, 1_2_8, 1_2_8, 1_2_8, 2_5_6, 2_5_6, 2_5_6, 2_5_6, 5_1_2, 5_1_2, 5_1_2, 5_1_2)      ,    _A							:							Optional[Any]=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)      ,    _A							:							Any=(1_0, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)      ,    _A							:							Tuple=False      ,    _A							:							Tuple=1_2_8      ,    _A							:							int=1_6      ,    _A							:							Union[str, Any]=True      ,    _A							:							Optional[Any]=0.05      ,    _A							:							List[Any]=1_0      ,    _A							:							Union[str, Any]=2      ,    _A							:							Tuple=0.0      ,    _A							:							Union[str, Any]=1_0      ,    _A							:							Optional[int]=0      ,    _A							:							Union[str, Any]="mean"      ,    _A							:							Optional[int]=False      ,    _A							:							List[Any]=False      ,    _A							:							int=2_5_6      ,    _A							:							str=0      ,    _A							:							Optional[int]=1      ,    _A							:							List[Any]=2      ,    **_A							:							Dict      ,    ):



											"""simple docstring"""







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

											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)`,"""
																		    f"""but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)"""
																		    f"""= {len(self.conv_stride)}`, `len(config.conv_kernel) = {len(self.conv_kernel)}`.""")

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

											# ctc loss
											_SCREAMING_SNAKE_CASE		:						int			  =    ctc_loss_reduction
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    ctc_zero_infinity

											# sequence classification
											_SCREAMING_SNAKE_CASE		:						Dict			  =    use_weighted_layer_sum
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    classifier_proj_size





				@property
				def 		_lowerCAmelCase		(      self							:							Any):



											"""simple docstring"""







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


