




'''simple docstring'''




import functools
import operator

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


a_      :		List[str]							      =       logging.get_logger(__name__)

a_      :		Dict							      =       {
    """microsoft/unispeech-large-1500h-cv""": (
        """https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json"""
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}


class   __UpperCamelCase       ( lowerCamelCase__				):
       lowercase	:    str      						='unispeech'






       def __init__(							self,		lowerCAmelCase=32,		lowerCAmelCase=768,		lowerCAmelCase=12,		lowerCAmelCase=12,		lowerCAmelCase=3_072,		lowerCAmelCase="gelu",		lowerCAmelCase=0.1,		lowerCAmelCase=0.1,		lowerCAmelCase=0.1,		lowerCAmelCase=0.0,		lowerCAmelCase=0.0,		lowerCAmelCase=0.1,		lowerCAmelCase=0.1,		lowerCAmelCase=0.0_2,		lowerCAmelCase=1e-5,		lowerCAmelCase="group",		lowerCAmelCase="gelu",		lowerCAmelCase=(512, 512, 512, 512, 512, 512, 512),		lowerCAmelCase=(5, 2, 2, 2, 2, 2, 2),		lowerCAmelCase=(10, 3, 3, 3, 3, 2, 2),		lowerCAmelCase=False,		lowerCAmelCase=128,		lowerCAmelCase=16,		lowerCAmelCase=False,		lowerCAmelCase=True,		lowerCAmelCase=0.0_5,		lowerCAmelCase=10,		lowerCAmelCase=2,		lowerCAmelCase=0.0,		lowerCAmelCase=10,		lowerCAmelCase=0,		lowerCAmelCase=320,		lowerCAmelCase=2,		lowerCAmelCase=0.1,		lowerCAmelCase=100,		lowerCAmelCase=256,		lowerCAmelCase=256,		lowerCAmelCase=0.1,		lowerCAmelCase="mean",		lowerCAmelCase=False,		lowerCAmelCase=False,		lowerCAmelCase=256,		lowerCAmelCase=80,		lowerCAmelCase=0,		lowerCAmelCase=1,		lowerCAmelCase=2,		lowerCAmelCase=0.5,		**lowerCAmelCase,		):



              """simple docstring"""







              super().__init__(**lowerCAmelCase,		pad_token_id=lowerCAmelCase,		bos_token_id=lowerCAmelCase,		eos_token_id=lowerCAmelCase  )
              lowerCamelCase_							=hidden_size
              lowerCamelCase_							=feat_extract_norm
              lowerCamelCase_							=feat_extract_activation
              lowerCamelCase_							=list(lowerCAmelCase  )
              lowerCamelCase_							=list(lowerCAmelCase  )
              lowerCamelCase_							=list(lowerCAmelCase  )
              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_							=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_							=num_ctc_classes
              lowerCamelCase_							=vocab_size
              lowerCamelCase_							=do_stable_layer_norm
              lowerCamelCase_							=use_weighted_layer_sum
              lowerCamelCase_							=classifier_proj_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)`, 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
              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

              # parameters for pretraining with codevector quantized representations
              lowerCamelCase_							=num_codevectors_per_group
              lowerCamelCase_							=num_codevector_groups
              lowerCamelCase_							=contrastive_logits_temperature
              lowerCamelCase_							=feat_quantizer_dropout
              lowerCamelCase_							=num_negatives
              lowerCamelCase_							=codevector_dim
              lowerCamelCase_							=proj_codevector_dim
              lowerCamelCase_							=diversity_loss_weight

              # ctc loss
              lowerCamelCase_							=ctc_loss_reduction
              lowerCamelCase_							=ctc_zero_infinity

              # pretraining loss
              lowerCamelCase_							=replace_prob






       @property
       def      lowercase__     (							self  ):



              """simple docstring"""







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









"""simple docstring"""






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


__snake_case							:   Optional[int]      =    logging.get_logger(__name__)



class 			A__   (  __SCREAMING_SNAKE_CASE  ,		__SCREAMING_SNAKE_CASE							):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE          =	'maskformer-swin'

	SCREAMING_SNAKE_CASE          =	{
	    'num_attention_heads': 'num_heads',
	    'num_hidden_layers': 'num_layers',
	}

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

				"""simple docstring"""

				super().__init__(**_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase      :  int												=       image_size
				__lowerCAmelCase      :  Any												=       patch_size
				__lowerCAmelCase      :  Tuple												=       num_channels
				__lowerCAmelCase      :  Any												=       embed_dim
				__lowerCAmelCase      :  Any												=       depths
				__lowerCAmelCase      :  Dict												=       len(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       num_heads
				__lowerCAmelCase      :  Tuple												=       window_size
				__lowerCAmelCase      :  Dict												=       mlp_ratio
				__lowerCAmelCase      :  Any												=       qkv_bias
				__lowerCAmelCase      :  Union[str, Any]												=       hidden_dropout_prob
				__lowerCAmelCase      :  int												=       attention_probs_dropout_prob
				__lowerCAmelCase      :  Tuple												=       drop_path_rate
				__lowerCAmelCase      :  int												=       hidden_act
				__lowerCAmelCase      :  Optional[int]												=       use_absolute_embeddings
				__lowerCAmelCase      :  List[str]												=       layer_norm_eps
				__lowerCAmelCase      :  Any												=       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
				__lowerCAmelCase      :  Optional[Any]												=       int(embed_dim * 2 ** (len(_SCREAMING_SNAKE_CASE) - 1))
				__lowerCAmelCase      :  Any												=       ["stem"] + [F"""stage{idx}""" for idx in range(1       ,			len(_SCREAMING_SNAKE_CASE) + 1)]
				__lowerCAmelCase						,	__lowerCAmelCase      :  List[str]												=       get_aligned_output_features_output_indices(
				    out_features=_SCREAMING_SNAKE_CASE       ,			out_indices=_SCREAMING_SNAKE_CASE       ,			stage_names=self.stage_names)