



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


UpperCamelCase__ =						logging.get_logger(__name__)
class 			_lowerCAmelCase   ( _UpperCAmelCase    ,					_UpperCAmelCase			):






			"""simple docstring"""





			lowercase__      :  Dict      =			"""maskformer-swin"""

			lowercase__      :  Optional[Any]      =			{
			    """num_attention_heads""": """num_heads""",
			    """num_hidden_layers""": """num_layers""",
			}





			def __init__(				self	:       Optional[int]			,     lowercase	:       str=224			,     lowercase	:       Optional[int]=4			,     lowercase	:       Optional[int]=3			,     lowercase	:       Optional[int]=96			,     lowercase	:       List[Any]=[2, 2, 6, 2]			,     lowercase	:       int=[3, 6, 12, 24]			,     lowercase	:       Union[str, Any]=7			,     lowercase	:       Union[str, Any]=4.0			,     lowercase	:       int=True			,     lowercase	:       str=0.0			,     lowercase	:       Dict=0.0			,     lowercase	:       Tuple=0.1			,     lowercase	:       Union[str, Any]="gelu"			,     lowercase	:       int=False			,     lowercase	:       List[Any]=0.02			,     lowercase	:       List[str]=1E-5			,     lowercase	:       Any=None			,     lowercase	:       Any=None			,     **lowercase	:       Optional[int]			,     )						->					Any:
									"""simple docstring"""







									super().__init__(**lowercase   )

									__lowercase					=				image_size
									__lowercase					=				patch_size
									__lowercase					=				num_channels
									__lowercase					=				embed_dim
									__lowercase					=				depths
									__lowercase					=				len(lowercase   )
									__lowercase					=				num_heads
									__lowercase					=				window_size
									__lowercase					=				mlp_ratio
									__lowercase					=				qkv_bias
									__lowercase					=				hidden_dropout_prob
									__lowercase					=				attention_probs_dropout_prob
									__lowercase					=				drop_path_rate
									__lowercase					=				hidden_act
									__lowercase					=				use_absolute_embeddings
									__lowercase					=				layer_norm_eps
									__lowercase					=				initializer_range
									# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
									# this indicates the channel dimension after the last stage of the model
									__lowercase					=				int(embed_dim * 2 ** (len(lowercase   ) - 1)   )
									__lowercase					=				["""stem"""] + [F"stage{idx}" for idx in range(1			,     len(lowercase   ) + 1   )]
									__lowercase	,			__lowercase					=				get_aligned_output_features_output_indices(
									    out_features=lowercase			,     out_indices=lowercase			,     stage_names=self.stage_names   )










import functools
import operator

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


UpperCamelCase__ =						logging.get_logger(__name__)

UpperCamelCase__ =						{
    "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 			_lowerCAmelCase   ( _UpperCAmelCase			):






			"""simple docstring"""





			lowercase__      :  Union[str, Any]      =			"""sew"""





			def __init__(				self	:       List[Any]			,     lowercase	:       int=32			,     lowercase	:       List[str]=768			,     lowercase	:       Dict=12			,     lowercase	:       str=12			,     lowercase	:       str=3_072			,     lowercase	:       Optional[int]=2			,     lowercase	:       List[str]="gelu"			,     lowercase	:       List[str]=0.1			,     lowercase	:       Tuple=0.1			,     lowercase	:       Dict=0.1			,     lowercase	:       Any=0.0			,     lowercase	:       Dict=0.1			,     lowercase	:       Optional[int]=0.1			,     lowercase	:       List[str]=0.02			,     lowercase	:       Dict=1E-5			,     lowercase	:       Tuple="group"			,     lowercase	:       int="gelu"			,     lowercase	:       Any=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)			,     lowercase	:       Optional[int]=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)			,     lowercase	:       Any=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)			,     lowercase	:       List[str]=False			,     lowercase	:       Tuple=128			,     lowercase	:       int=16			,     lowercase	:       Union[str, Any]=True			,     lowercase	:       List[str]=0.05			,     lowercase	:       Optional[int]=10			,     lowercase	:       Any=2			,     lowercase	:       Optional[Any]=0.0			,     lowercase	:       Optional[Any]=10			,     lowercase	:       int=0			,     lowercase	:       Optional[int]="mean"			,     lowercase	:       List[Any]=False			,     lowercase	:       str=False			,     lowercase	:       int=256			,     lowercase	:       str=0			,     lowercase	:       List[Any]=1			,     lowercase	:       List[Any]=2			,     **lowercase	:       List[Any]			,     )						->					Optional[Any]:
									"""simple docstring"""







									super().__init__(**lowercase			,     pad_token_id=lowercase			,     bos_token_id=lowercase			,     eos_token_id=lowercase   )
									__lowercase					=				hidden_size
									__lowercase					=				feat_extract_norm
									__lowercase					=				feat_extract_activation
									__lowercase					=				list(lowercase   )
									__lowercase					=				list(lowercase   )
									__lowercase					=				list(lowercase   )
									__lowercase					=				conv_bias
									__lowercase					=				num_conv_pos_embeddings
									__lowercase					=				num_conv_pos_embedding_groups
									__lowercase					=				len(self.conv_dim   )
									__lowercase					=				num_hidden_layers
									__lowercase					=				intermediate_size
									__lowercase					=				squeeze_factor
									__lowercase					=				hidden_act
									__lowercase					=				num_attention_heads
									__lowercase					=				hidden_dropout
									__lowercase					=				attention_dropout
									__lowercase					=				activation_dropout
									__lowercase					=				feat_proj_dropout
									__lowercase					=				final_dropout
									__lowercase					=				layerdrop
									__lowercase					=				layer_norm_eps
									__lowercase					=				initializer_range
									__lowercase					=				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
									__lowercase					=				apply_spec_augment
									__lowercase					=				mask_time_prob
									__lowercase					=				mask_time_length
									__lowercase					=				mask_time_min_masks
									__lowercase					=				mask_feature_prob
									__lowercase					=				mask_feature_length
									__lowercase					=				mask_feature_min_masks

									# ctc loss
									__lowercase					=				ctc_loss_reduction
									__lowercase					=				ctc_zero_infinity

									# sequence classification
									__lowercase					=				use_weighted_layer_sum
									__lowercase					=				classifier_proj_size







			@property
			def 		snake_case__			(				self	:       Dict   )						->					str:
									"""simple docstring"""







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





