"""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  _lowerCamelCase			(__lowerCamelCase     ):
				_snake_case     =  "wav2vec2"







				def __init__( self    :       Tuple			,					lowerCamelCase_    :       List[str]=3_2			,					lowerCamelCase_    :       str=7_6_8			,					lowerCamelCase_    :       str=1_2			,					lowerCamelCase_    :       Dict=1_2			,					lowerCamelCase_    :       Optional[Any]=3_0_7_2			,					lowerCamelCase_    :       Union[str, Any]="gelu"			,					lowerCamelCase_    :       Optional[Any]=0.1			,					lowerCamelCase_    :       Optional[Any]=0.1			,					lowerCamelCase_    :       str=0.1			,					lowerCamelCase_    :       Any=0.0			,					lowerCamelCase_    :       List[str]=0.0			,					lowerCamelCase_    :       List[Any]=0.1			,					lowerCamelCase_    :       Union[str, Any]=0.1			,					lowerCamelCase_    :       str=0.02			,					lowerCamelCase_    :       int=1E-5			,					lowerCamelCase_    :       int="group"			,					lowerCamelCase_    :       List[Any]="gelu"			,					lowerCamelCase_    :       int=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)			,					lowerCamelCase_    :       Union[str, Any]=(5, 2, 2, 2, 2, 2, 2)			,					lowerCamelCase_    :       Tuple=(1_0, 3, 3, 3, 3, 2, 2)			,					lowerCamelCase_    :       Any=False			,					lowerCamelCase_    :       Optional[int]=1_2_8			,					lowerCamelCase_    :       List[Any]=1_6			,					lowerCamelCase_    :       Union[str, Any]=False			,					lowerCamelCase_    :       Optional[int]=True			,					lowerCamelCase_    :       Optional[int]=0.05			,					lowerCamelCase_    :       Optional[int]=1_0			,					lowerCamelCase_    :       Dict=2			,					lowerCamelCase_    :       Dict=0.0			,					lowerCamelCase_    :       Any=1_0			,					lowerCamelCase_    :       Optional[int]=0			,					lowerCamelCase_    :       Union[str, Any]=3_2_0			,					lowerCamelCase_    :       Optional[Any]=2			,					lowerCamelCase_    :       Optional[int]=0.1			,					lowerCamelCase_    :       Tuple=1_0_0			,					lowerCamelCase_    :       Any=2_5_6			,					lowerCamelCase_    :       Any=2_5_6			,					lowerCamelCase_    :       Union[str, Any]=0.1			,					lowerCamelCase_    :       Tuple="sum"			,					lowerCamelCase_    :       Tuple=False			,					lowerCamelCase_    :       Union[str, Any]=False			,					lowerCamelCase_    :       int=2_5_6			,					lowerCamelCase_    :       int=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)			,					lowerCamelCase_    :       Optional[int]=(5, 3, 3, 1, 1)			,					lowerCamelCase_    :       List[str]=(1, 2, 3, 1, 1)			,					lowerCamelCase_    :       str=5_1_2			,					lowerCamelCase_    :       str=0			,					lowerCamelCase_    :       List[Any]=1			,					lowerCamelCase_    :       List[str]=2			,					lowerCamelCase_    :       Optional[Any]=False			,					lowerCamelCase_    :       Dict=3			,					lowerCamelCase_    :       Any=2			,					lowerCamelCase_    :       Union[str, Any]=3			,					lowerCamelCase_    :       int=None			,					lowerCamelCase_    :       Dict=None			,					**lowerCamelCase_    :       Optional[Any]			,					):

					"""simple docstring"""






					super().__init__(**lowerCamelCase_			,					pad_token_id=lowerCamelCase_			,					bos_token_id=lowerCamelCase_			,					eos_token_id=lowerCamelCase_						)
					_lowercase :    Optional[int]							=							hidden_size
					_lowercase :    Tuple							=							feat_extract_norm
					_lowercase :    Tuple							=							feat_extract_activation
					_lowercase :    int							=							list(lowerCamelCase_						)
					_lowercase :    int							=							list(lowerCamelCase_						)
					_lowercase :    Tuple							=							list(lowerCamelCase_						)
					_lowercase :    str							=							conv_bias
					_lowercase :    Optional[Any]							=							num_conv_pos_embeddings
					_lowercase :    Union[str, Any]							=							num_conv_pos_embedding_groups
					_lowercase :    Dict							=							len(self.conv_dim						)
					_lowercase :    Optional[Any]							=							num_hidden_layers
					_lowercase :    Union[str, Any]							=							intermediate_size
					_lowercase :    List[Any]							=							hidden_act
					_lowercase :    Optional[int]							=							num_attention_heads
					_lowercase :    Any							=							hidden_dropout
					_lowercase :    List[Any]							=							attention_dropout
					_lowercase :    str							=							activation_dropout
					_lowercase :    int							=							feat_proj_dropout
					_lowercase :    List[Any]							=							final_dropout
					_lowercase :    Optional[int]							=							layerdrop
					_lowercase :    str							=							layer_norm_eps
					_lowercase :    Tuple							=							initializer_range
					_lowercase :    Optional[Any]							=							vocab_size
					_lowercase :    Union[str, Any]							=							do_stable_layer_norm
					_lowercase :    Dict							=							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 :    Tuple							=							apply_spec_augment
					_lowercase :    str							=							mask_time_prob
					_lowercase :    Union[str, Any]							=							mask_time_length
					_lowercase :    Optional[Any]							=							mask_time_min_masks
					_lowercase :    Tuple							=							mask_feature_prob
					_lowercase :    Dict							=							mask_feature_length
					_lowercase :    str							=							mask_feature_min_masks

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

					# ctc loss
					_lowercase :    Tuple							=							ctc_loss_reduction
					_lowercase :    Tuple							=							ctc_zero_infinity

					# adapter
					_lowercase :    List[str]							=							add_adapter
					_lowercase :    str							=							adapter_kernel_size
					_lowercase :    str							=							adapter_stride
					_lowercase :    Dict							=							num_adapter_layers
					_lowercase :    int							=							output_hidden_size or hidden_size
					_lowercase :    Tuple							=							adapter_attn_dim

					# SequenceClassification-specific parameter. Feel free to ignore for other classes.
					_lowercase :    Optional[Any]							=							classifier_proj_size

					# XVector-specific parameters. Feel free to ignore for other classes.
					_lowercase :    Optional[int]							=							list(lowerCamelCase_						)
					_lowercase :    Optional[int]							=							list(lowerCamelCase_						)
					_lowercase :    List[str]							=							list(lowerCamelCase_						)
					_lowercase :    int							=							xvector_output_dim







				@property
				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






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




"""simple docstring"""







def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							[0 for i in range(len(__UpperCAmelCase			)			)]

	# initialize interval's left pointer and right pointer
	_lowercase				,      _lowercase :    str							=							0, 0

	for i in range(1     ,len(__UpperCAmelCase			)			):
		# case when current index is inside the interval
		if i <= right_pointer:
			_lowercase :    Union[str, Any]							=							min(right_pointer - i + 1     ,z_result[i - left_pointer]			)
			_lowercase :    Any							=							min_edge

		while go_next(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):
			z_result[i] += 1

		# if new index's result gives us more right interval,
		# we've to update left_pointer and right_pointer
		if i + z_result[i] - 1 > right_pointer:
			_lowercase				,      _lowercase :    Optional[int]							=							i, i + z_result[i] - 1

	return z_result


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	return i + z_result[i] < len(__UpperCAmelCase			) and s[z_result[i]] == s[i + z_result[i]]


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Union[str, Any]							=							0
	# concatenate 'pattern' and 'input_str' and call z_function
	# with concatenated string
	_lowercase :    List[str]							=							z_function(pattern + input_str			)

	for val in z_result:
		# if value is greater then length of the pattern string
		# that means this index is starting position of substring
		# which is equal to pattern string
		if val >= len(__UpperCAmelCase			):
			answer += 1

	return answer


if __name__ == "__main__":
						import doctest

						doctest.testmod()



