



import functools
import operator

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


lowercase_													=      logging.get_logger(__name__)

lowercase_													=      {
    '''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     __a			(  SCREAMING_SNAKE_CASE					):
	SCREAMING_SNAKE_CASE  	=							"sew"



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

						# ctc loss
						__lowerCAmelCase						 =ctc_loss_reduction
						__lowerCAmelCase						 =ctc_zero_infinity

						# sequence classification
						__lowerCAmelCase						 =use_weighted_layer_sum
						__lowerCAmelCase						 =classifier_proj_size



	@property
	def 		UpperCamelCase				(    self				:     str)->				Dict:
						return functools.reduce(operator.mul					,						self.conv_stride					,						1)









def        __lowerCAmelCase		(	__lowerCamelCase						:     int					, __lowerCamelCase						:     int						)	->    bool:
					return numa ^ numa < 0


if __name__ == "__main__":
				import doctest

				doctest.testmod()




