


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							):
		lowerCamelCase_	:			Union[str, Any]       			=  """wav2vec2"""






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

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

				# ctc loss
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						ctc_loss_reduction
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						ctc_zero_infinity

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

				# SequenceClassification-specific parameter. Feel free to ignore for other classes.
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						classifier_proj_size

				# XVector-specific parameters. Feel free to ignore for other classes.
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						list(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:Tuple				     =						list(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:str				     =						list(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						xvector_output_dim







		@property
		def _snake_case		(						self				:     str):
				return functools.reduce(operator.mul   ,  self.conv_stride   ,  1)










from timeit import timeit


def     lowercase	(    a ):



		'''simple docstring'''




		if number < 0:
				raise ValueError("the value of input must not be negative" )
		SCREAMING_SNAKE_CASE_				:Optional[int]				     =						0
		while number:
				number &= number - 1
				result += 1
		return result


def     lowercase	(    a ):



		'''simple docstring'''




		if number < 0:
				raise ValueError("the value of input must not be negative" )
		SCREAMING_SNAKE_CASE_				:List[Any]				     =						0
		while number:
				if number % 2 == 1:
						result += 1
				number >>= 1
		return result


def     lowercase	(    ):



		'''simple docstring'''




		def do_benchmark(a ) -> None:
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						"import __main__ as z"
				print(F"Benchmark when {number = }:" )
				print(F"{get_set_bits_count_using_modulo_operator(a ) = }" )
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						timeit("z.get_set_bits_count_using_modulo_operator(25)"     , setup=a )
				print(F"timeit() runs in {timing} seconds" )
				print(F"{get_set_bits_count_using_brian_kernighans_algorithm(a ) = }" )
				SCREAMING_SNAKE_CASE_				:str				     =						timeit(
				    "z.get_set_bits_count_using_brian_kernighans_algorithm(25)"     , setup=a     , )
				print(F"timeit() runs in {timing} seconds" )

		for number in (25, 37, 58, 0):
				do_benchmark(a )
				print()


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		benchmark()






