



'''simple docstring'''

import functools
import operator

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


__lowerCAmelCase									=   logging.get_logger(__name__)

__lowerCAmelCase									=   {
    '''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 	__magic_name__						(    _UpperCamelCase   ):
							lowerCAmelCase       :    Union[str, Any]   				=					'sew'







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

									# ctc loss
									_a     :      int        =							ctc_loss_reduction
									_a     :      Optional[int]        =							ctc_zero_infinity

									# sequence classification
									_a     :      str        =							use_weighted_layer_sum
									_a     :      Tuple        =							classifier_proj_size







							@property
							def 							__lowercase			(							self					:       List[str]		):
									return functools.reduce(operator.mul	,self.conv_stride	,1		)





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_SCREAMING_SNAKE_CASE										=						logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE										=						{
    'microsoft/resnet-50': 'https://huggingface.co/microsoft/resnet-50/blob/main/config.json',
}



class 				a							(			__lowerCAmelCase       ,			__lowerCAmelCase       ):







 """simple docstring"""






 lowerCamelCase	:Any    			=		'''resnet'''
 lowerCamelCase	:Any    			=		['''basic''', '''bottleneck''']



 def __init__(					self		,				lowerCAmelCase_=3		,				lowerCAmelCase_=64		,				lowerCAmelCase_=[2_56, 5_12, 10_24, 20_48]		,				lowerCAmelCase_=[3, 4, 6, 3]		,				lowerCAmelCase_="bottleneck"		,				lowerCAmelCase_="relu"		,				lowerCAmelCase_=False		,				lowerCAmelCase_=None		,				lowerCAmelCase_=None		,				**lowerCAmelCase_		,				)  ->					Union[str, Any]:
        super().__init__(**lowerCAmelCase_							)
        if layer_type not in self.layer_types:
               raise ValueError(F'''layer_type={layer_type} is not one of {','.join(self.layer_types							)}'''							)
        _A        =  num_channels
        _A        =  embedding_size
        _A        =  hidden_sizes
        _A        =  depths
        _A        =  layer_type
        _A        =  hidden_act
        _A        =  downsample_in_first_stage
        _A        =  ["""stem"""] + [F'''stage{idx}''' for idx in range(1		,				len(lowerCAmelCase_							) + 1							)]
        _A   ,  _A        =  get_aligned_output_features_output_indices(
            out_features=lowerCAmelCase_		,				out_indices=lowerCAmelCase_		,				stage_names=self.stage_names							)



class 				a							(			__lowerCAmelCase       ):







 """simple docstring"""






 lowerCamelCase	:Optional[Any]    			=		version.parse('''1.11'''       )



 @property
 def      UpperCAmelCase							(					self							)  ->					Mapping[str, Mapping[int, str]]:
        return OrderedDict(
            [
                ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
            ]							)



 @property
 def      UpperCAmelCase							(					self							)  ->					float:
        return 1E-3




