



'''simple docstring'''



import functools
import operator

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


lowerCAmelCase	:		Dict				=   logging.get_logger(__name__)

lowerCAmelCase	:		Dict				=   {
    '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json''',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}






class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     Optional[int]        =							"""sew-d"""



					def __init__(    self			,				UpperCamelCase=32			,				UpperCamelCase=768			,				UpperCamelCase=12			,				UpperCamelCase=12			,				UpperCamelCase=3072			,				UpperCamelCase=2			,				UpperCamelCase=512			,				UpperCamelCase=256			,				UpperCamelCase=True			,				UpperCamelCase=True			,				UpperCamelCase=("p2c", "c2p")			,				UpperCamelCase="layer_norm"			,				UpperCamelCase="gelu_python"			,				UpperCamelCase=0.1			,				UpperCamelCase=0.1			,				UpperCamelCase=0.1			,				UpperCamelCase=0.0			,				UpperCamelCase=0.1			,				UpperCamelCase=0.02			,				UpperCamelCase=1E-7			,				UpperCamelCase=1E-5			,				UpperCamelCase="group"			,				UpperCamelCase="gelu"			,				UpperCamelCase=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)			,				UpperCamelCase=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)			,				UpperCamelCase=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)			,				UpperCamelCase=False			,				UpperCamelCase=128			,				UpperCamelCase=16			,				UpperCamelCase=True			,				UpperCamelCase=0.05			,				UpperCamelCase=10			,				UpperCamelCase=2			,				UpperCamelCase=0.0			,				UpperCamelCase=10			,				UpperCamelCase=0			,				UpperCamelCase="mean"			,				UpperCamelCase=False			,				UpperCamelCase=False			,				UpperCamelCase=256			,				UpperCamelCase=0			,				UpperCamelCase=1			,				UpperCamelCase=2			,				**UpperCamelCase			,				)     ->			Optional[int]:
						super().__init__(**UpperCamelCase			,				pad_token_id=UpperCamelCase			,				bos_token_id=UpperCamelCase			,				eos_token_id=UpperCamelCase     )
						__lowerCAmelCase												=  hidden_size
						__lowerCAmelCase												=  feat_extract_norm
						__lowerCAmelCase												=  feat_extract_activation
						__lowerCAmelCase												=  list(UpperCamelCase     )
						__lowerCAmelCase												=  list(UpperCamelCase     )
						__lowerCAmelCase												=  list(UpperCamelCase     )
						__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												=  max_position_embeddings
						__lowerCAmelCase												=  position_buckets
						__lowerCAmelCase												=  share_att_key
						__lowerCAmelCase												=  relative_attention
						__lowerCAmelCase												=  norm_rel_ebd
						__lowerCAmelCase												=  list(UpperCamelCase     )
						__lowerCAmelCase												=  hidden_act
						__lowerCAmelCase												=  num_attention_heads
						__lowerCAmelCase												=  hidden_dropout
						__lowerCAmelCase												=  attention_dropout
						__lowerCAmelCase												=  activation_dropout
						__lowerCAmelCase												=  feat_proj_dropout
						__lowerCAmelCase												=  final_dropout
						__lowerCAmelCase												=  layer_norm_eps
						__lowerCAmelCase												=  feature_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     )     ->			Optional[int]:
						return functools.reduce(operator.mul			,				self.conv_stride			,				1     )




'''simple docstring'''



import importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


lowerCAmelCase	:		Optional[Any]				=   '''scheduler_config.json'''






class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     str        =							1
					a      :     Optional[int]        =							2
					a      :     int        =							3
					a      :     Union[str, Any]        =							4
					a      :     int        =							5
					a      :     Optional[int]        =							6
					a      :     str        =							7
					a      :     List[Any]        =							8
					a      :     List[str]        =							9
					a      :     List[str]        =							1_0
					a      :     int        =							1_1
					a      :     Any        =							1_2
					a      :     Any        =							1_3
					a      :     Tuple        =							1_4






@dataclass
class 					UpperCAmelCase__	(		UpperCamelCase__ ):
					a      :     torch.FloatTensor






class 					UpperCAmelCase__	:
					a      :     Tuple        =							SCHEDULER_CONFIG_NAME
					a      :     Union[str, Any]        =							[]
					a      :     str        =							True



					@classmethod
					def        UpperCAmelCase_ (    cls			,				UpperCamelCase = None			,				UpperCamelCase = None			,				UpperCamelCase=False			,				**UpperCamelCase			,				)     ->			int:
						__lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase												=  cls.load_config(
						    pretrained_model_name_or_path=UpperCamelCase			,				subfolder=UpperCamelCase			,				return_unused_kwargs=UpperCamelCase			,				return_commit_hash=UpperCamelCase			,				**UpperCamelCase			,				)
						return cls.from_config(UpperCamelCase			,				return_unused_kwargs=UpperCamelCase			,				**UpperCamelCase     )



					def        UpperCAmelCase_ (    self			,				UpperCamelCase			,				UpperCamelCase = False			,				**UpperCamelCase     )     ->			Dict:
						self.save_config(save_directory=UpperCamelCase			,				push_to_hub=UpperCamelCase			,				**UpperCamelCase     )



					@property
					def        UpperCAmelCase_ (    self     )     ->			str:
						return self._get_compatibles()



					@classmethod
					def        UpperCAmelCase_ (    cls     )     ->			Tuple:
						__lowerCAmelCase												=  list(set([cls.__name__] + cls._compatibles     )     )
						__lowerCAmelCase												=  importlib.import_module(__name__.split("."     )[0]     )
						__lowerCAmelCase												=  [
						    getattr(UpperCamelCase			,				UpperCamelCase     ) for c in compatible_classes_str if hasattr(UpperCamelCase			,				UpperCamelCase     )
						]
						return compatible_classes