





"""simple docstring"""





import functools
import operator

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


lowerCAmelCase__     			=			logging.get_logger(__name__)

lowerCAmelCase__     			=			{
    '''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        _lowerCamelCase      (       _lowercase ):
						UpperCAmelCase_ =			"wav2vec2"


						def __init__(self   ,							__a=32   ,							__a=7_68   ,							__a=12   ,							__a=12   ,							__a=30_72   ,							__a="gelu"   ,							__a=0.1   ,							__a=0.1   ,							__a=0.1   ,							__a=0.0   ,							__a=0.0   ,							__a=0.1   ,							__a=0.1   ,							__a=0.02   ,							__a=1e-5   ,							__a="group"   ,							__a="gelu"   ,							__a=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)   ,							__a=(5, 2, 2, 2, 2, 2, 2)   ,							__a=(10, 3, 3, 3, 3, 2, 2)   ,							__a=False   ,							__a=1_28   ,							__a=16   ,							__a=False   ,							__a=True   ,							__a=0.05   ,							__a=10   ,							__a=2   ,							__a=0.0   ,							__a=10   ,							__a=0   ,							__a=3_20   ,							__a=2   ,							__a=0.1   ,							__a=1_00   ,							__a=2_56   ,							__a=2_56   ,							__a=0.1   ,							__a="sum"   ,							__a=False   ,							__a=False   ,							__a=2_56   ,							__a=(5_12, 5_12, 5_12, 5_12, 15_00)   ,							__a=(5, 3, 3, 1, 1)   ,							__a=(1, 2, 3, 1, 1)   ,							__a=5_12   ,							__a=0   ,							__a=1   ,							__a=2   ,							__a=False   ,							__a=3   ,							__a=2   ,							__a=3   ,							__a=None   ,							__a=None   ,							**__a   ,							) ->   int:
								super().__init__(**__a   ,							pad_token_id=__a   ,							bos_token_id=__a   ,							eos_token_id=__a		)
								UpperCamelCase   =	hidden_size
								UpperCamelCase   =	feat_extract_norm
								UpperCamelCase   =	feat_extract_activation
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	conv_bias
								UpperCamelCase   =	num_conv_pos_embeddings
								UpperCamelCase   =	num_conv_pos_embedding_groups
								UpperCamelCase   =	len(self.conv_dim		)
								UpperCamelCase   =	num_hidden_layers
								UpperCamelCase   =	intermediate_size
								UpperCamelCase   =	hidden_act
								UpperCamelCase   =	num_attention_heads
								UpperCamelCase   =	hidden_dropout
								UpperCamelCase   =	attention_dropout
								UpperCamelCase   =	activation_dropout
								UpperCamelCase   =	feat_proj_dropout
								UpperCamelCase   =	final_dropout
								UpperCamelCase   =	layerdrop
								UpperCamelCase   =	layer_norm_eps
								UpperCamelCase   =	initializer_range
								UpperCamelCase   =	vocab_size
								UpperCamelCase   =	do_stable_layer_norm
								UpperCamelCase   =	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
								UpperCamelCase   =	apply_spec_augment
								UpperCamelCase   =	mask_time_prob
								UpperCamelCase   =	mask_time_length
								UpperCamelCase   =	mask_time_min_masks
								UpperCamelCase   =	mask_feature_prob
								UpperCamelCase   =	mask_feature_length
								UpperCamelCase   =	mask_feature_min_masks

								# parameters for pretraining with codevector quantized representations
								UpperCamelCase   =	num_codevectors_per_group
								UpperCamelCase   =	num_codevector_groups
								UpperCamelCase   =	contrastive_logits_temperature
								UpperCamelCase   =	feat_quantizer_dropout
								UpperCamelCase   =	num_negatives
								UpperCamelCase   =	codevector_dim
								UpperCamelCase   =	proj_codevector_dim
								UpperCamelCase   =	diversity_loss_weight

								# ctc loss
								UpperCamelCase   =	ctc_loss_reduction
								UpperCamelCase   =	ctc_zero_infinity

								# adapter
								UpperCamelCase   =	add_adapter
								UpperCamelCase   =	adapter_kernel_size
								UpperCamelCase   =	adapter_stride
								UpperCamelCase   =	num_adapter_layers
								UpperCamelCase   =	output_hidden_size or hidden_size
								UpperCamelCase   =	adapter_attn_dim

								# SequenceClassification-specific parameter. Feel free to ignore for other classes.
								UpperCamelCase   =	classifier_proj_size

								# XVector-specific parameters. Feel free to ignore for other classes.
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	list(__a		)
								UpperCamelCase   =	xvector_output_dim




						@property
						def     snake_case_   (self		) ->   List[Any]:
								return functools.reduce(operator.mul   ,							self.conv_stride   ,							1		)













"""simple docstring"""





from typing import List

from .keymap import KEYMAP, get_character


def       a__					(					_SCREAMING_SNAKE_CASE    ):




		"""simple docstring"""


		def decorator(_SCREAMING_SNAKE_CASE    ):
				UpperCamelCase   =	getattr(_SCREAMING_SNAKE_CASE  ,	"handle_key"  ,	[]    )
				handle += [key]
				setattr(_SCREAMING_SNAKE_CASE  ,	"handle_key"  ,	_SCREAMING_SNAKE_CASE    )
				return func

		return decorator


def       a__					(					*_SCREAMING_SNAKE_CASE    ):




		"""simple docstring"""


		def decorator(_SCREAMING_SNAKE_CASE    ):
				UpperCamelCase   =	getattr(_SCREAMING_SNAKE_CASE  ,	"handle_key"  ,	[]    )
				handle += keys
				setattr(_SCREAMING_SNAKE_CASE  ,	"handle_key"  ,	_SCREAMING_SNAKE_CASE    )
				return func

		return decorator





class        _lowerCamelCase      (       _lowercase ):


						def __new__(cls   ,							__a   ,							__a   ,							__a		) ->   Any:
								UpperCamelCase   =	super().__new__(cls   ,							__a   ,							__a   ,							__a		)
								if not hasattr(__a   ,							"key_handler"		):
										setattr(__a   ,							"key_handler"   ,							{}		)
								setattr(__a   ,							"handle_input"   ,							KeyHandler.handle_input		)

								for value in attrs.values():
										UpperCamelCase   =	getattr(__a   ,							"handle_key"   ,							[]		)
										for key in handled_keys:
												UpperCamelCase   =	value
								return new_cls




						@staticmethod
						def     snake_case_   (cls		) ->   Optional[Any]:
								UpperCamelCase   =	get_character()
								if char != KEYMAP["undefined"]:
										UpperCamelCase   =	ord(__a		)
								UpperCamelCase   =	cls.key_handler.get(__a		)
								if handler:
										UpperCamelCase   =	char
										return handler(cls		)
								else:
										return None



def       a__					(					cls    ):




		"""simple docstring"""


		return KeyHandler(cls.__name__  ,	cls.__bases__  ,	cls.__dict__.copy()    )






