






'''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 	SCREAMING_SNAKE_CASE					(					_UpperCAmelCase       ):
			snake_case__  =				'''wav2vec2'''






			def __init__( self      :			Any  ,						__SCREAMING_SNAKE_CASE      :			str=32  ,						__SCREAMING_SNAKE_CASE      :			Dict=768  ,						__SCREAMING_SNAKE_CASE      :			int=12  ,						__SCREAMING_SNAKE_CASE      :			Tuple=12  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]=3072  ,						__SCREAMING_SNAKE_CASE      :			List[Any]="gelu"  ,						__SCREAMING_SNAKE_CASE      :			int=0.1  ,						__SCREAMING_SNAKE_CASE      :			Any=0.1  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]=0.1  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]=0.0  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=0.0  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=0.1  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=0.1  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=0.02  ,						__SCREAMING_SNAKE_CASE      :			List[str]=1e-5  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]="group"  ,						__SCREAMING_SNAKE_CASE      :			str="gelu"  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=(512, 512, 512, 512, 512, 512, 512)  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=(5, 2, 2, 2, 2, 2, 2)  ,						__SCREAMING_SNAKE_CASE      :			int=(10, 3, 3, 3, 3, 2, 2)  ,						__SCREAMING_SNAKE_CASE      :			str=False  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=128  ,						__SCREAMING_SNAKE_CASE      :			str=16  ,						__SCREAMING_SNAKE_CASE      :			str=False  ,						__SCREAMING_SNAKE_CASE      :			str=True  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=0.05  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=10  ,						__SCREAMING_SNAKE_CASE      :			Any=2  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]=0.0  ,						__SCREAMING_SNAKE_CASE      :			Dict=10  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]=0  ,						__SCREAMING_SNAKE_CASE      :			int=320  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]=2  ,						__SCREAMING_SNAKE_CASE      :			Tuple=0.1  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]=100  ,						__SCREAMING_SNAKE_CASE      :			Tuple=256  ,						__SCREAMING_SNAKE_CASE      :			Dict=256  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=0.1  ,						__SCREAMING_SNAKE_CASE      :			Tuple="sum"  ,						__SCREAMING_SNAKE_CASE      :			Any=False  ,						__SCREAMING_SNAKE_CASE      :			List[str]=False  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]=256  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]=(512, 512, 512, 512, 1500)  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=(5, 3, 3, 1, 1)  ,						__SCREAMING_SNAKE_CASE      :			Dict=(1, 2, 3, 1, 1)  ,						__SCREAMING_SNAKE_CASE      :			Tuple=512  ,						__SCREAMING_SNAKE_CASE      :			List[str]=0  ,						__SCREAMING_SNAKE_CASE      :			Any=1  ,						__SCREAMING_SNAKE_CASE      :			Dict=2  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]=False  ,						__SCREAMING_SNAKE_CASE      :			List[Any]=3  ,						__SCREAMING_SNAKE_CASE      :			str=2  ,						__SCREAMING_SNAKE_CASE      :			Tuple=3  ,						__SCREAMING_SNAKE_CASE      :			Dict=None  ,						__SCREAMING_SNAKE_CASE      :			Tuple=None  ,						**__SCREAMING_SNAKE_CASE      :			Any  ,						)			->			Union[str, Any]:
							super().__init__(**A_  ,						pad_token_id=A_  ,						bos_token_id=A_  ,						eos_token_id=A_					)
							a_		:  List[Any]											=      hidden_size
							a_		:  Optional[Any]											=      feat_extract_norm
							a_		:  List[Any]											=      feat_extract_activation
							a_		:  int											=      list(A_					)
							a_		:  List[Any]											=      list(A_					)
							a_		:  Optional[Any]											=      list(A_					)
							a_		:  Union[str, Any]											=      conv_bias
							a_		:  List[Any]											=      num_conv_pos_embeddings
							a_		:  Union[str, Any]											=      num_conv_pos_embedding_groups
							a_		:  Tuple											=      len(self.conv_dim					)
							a_		:  Dict											=      num_hidden_layers
							a_		:  str											=      intermediate_size
							a_		:  Optional[int]											=      hidden_act
							a_		:  Optional[int]											=      num_attention_heads
							a_		:  Optional[int]											=      hidden_dropout
							a_		:  int											=      attention_dropout
							a_		:  List[str]											=      activation_dropout
							a_		:  List[Any]											=      feat_proj_dropout
							a_		:  List[Any]											=      final_dropout
							a_		:  str											=      layerdrop
							a_		:  Optional[Any]											=      layer_norm_eps
							a_		:  List[Any]											=      initializer_range
							a_		:  Optional[Any]											=      vocab_size
							a_		:  Optional[int]											=      do_stable_layer_norm
							a_		:  Optional[int]											=      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
							a_		:  List[str]											=      apply_spec_augment
							a_		:  List[str]											=      mask_time_prob
							a_		:  List[str]											=      mask_time_length
							a_		:  int											=      mask_time_min_masks
							a_		:  Optional[int]											=      mask_feature_prob
							a_		:  Optional[int]											=      mask_feature_length
							a_		:  Optional[int]											=      mask_feature_min_masks

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

							# ctc loss
							a_		:  int											=      ctc_loss_reduction
							a_		:  int											=      ctc_zero_infinity

							# adapter
							a_		:  Dict											=      add_adapter
							a_		:  str											=      adapter_kernel_size
							a_		:  int											=      adapter_stride
							a_		:  str											=      num_adapter_layers
							a_		:  str											=      output_hidden_size or hidden_size
							a_		:  Dict											=      adapter_attn_dim

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

							# XVector-specific parameters. Feel free to ignore for other classes.
							a_		:  List[Any]											=      list(A_					)
							a_		:  Any											=      list(A_					)
							a_		:  Tuple											=      list(A_					)
							a_		:  Tuple											=      xvector_output_dim







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












'''simple docstring'''







from __future__ import annotations





def 		_UpperCAmelCase   (							__A							:   list[int]      ):
				a_		:  int											=      len(__A      ) // 2

				# choose the middle 3 elements
				a_		:  Dict											=      lst[m - 1 : m + 2]

				# if middle element is peak
				if three[1] > three[0] and three[1] > three[2]:
								return three[1]

				# if increasing, recurse on right
				elif three[0] < three[2]:
								if len(lst[:m]      ) == 2:
												m -= 1
								return peak(lst[m:]      )

				# decreasing
				else:
								if len(lst[:m]      ) == 2:
												m += 1
								return peak(lst[:m]      )


if __name__ == "__main__":
		import doctest

		doctest.testmod()




