'''simple docstring'''



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


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






class 	UpperCamelCase__(       lowerCAmelCase						,    lowerCAmelCase	):
				__magic_name__    :				Tuple  		=	"maskformer-swin"

				__magic_name__    :				int  		=	{
				    "num_attention_heads": "num_heads",
				    "num_hidden_layers": "num_layers",
				}




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

										"""simple docstring"""




										super().__init__(**lowerCAmelCase				)

										UpperCAmelCase					    =     image_size
										UpperCAmelCase					    =     patch_size
										UpperCAmelCase					    =     num_channels
										UpperCAmelCase					    =     embed_dim
										UpperCAmelCase					    =     depths
										UpperCAmelCase					    =     len(lowerCAmelCase				)
										UpperCAmelCase					    =     num_heads
										UpperCAmelCase					    =     window_size
										UpperCAmelCase					    =     mlp_ratio
										UpperCAmelCase					    =     qkv_bias
										UpperCAmelCase					    =     hidden_dropout_prob
										UpperCAmelCase					    =     attention_probs_dropout_prob
										UpperCAmelCase					    =     drop_path_rate
										UpperCAmelCase					    =     hidden_act
										UpperCAmelCase					    =     use_absolute_embeddings
										UpperCAmelCase					    =     layer_norm_eps
										UpperCAmelCase					    =     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
										UpperCAmelCase					    =     int(embed_dim * 2 ** (len(lowerCAmelCase				) - 1)				)
										UpperCAmelCase					    =     ['''stem'''] + [F"""stage{idx}""" for idx in range(1				,   len(lowerCAmelCase				) + 1				)]
										UpperCAmelCase    ,    UpperCAmelCase					    =     get_aligned_output_features_output_indices(
										    out_features=lowerCAmelCase				,   out_indices=lowerCAmelCase				,   stage_names=self.stage_names				)









'''simple docstring'''



def 				lowerCamelCase__				(	A       :      int				,       A       :      int					):




						'''simple docstring'''






						while a != 0:
												UpperCAmelCase    ,    UpperCAmelCase					    =     b % a, a
						return b




def 				lowerCamelCase__				(	A       :      int				,       A       :      int					):




						'''simple docstring'''






						if gcd(A				,       A					) != 1:
												UpperCAmelCase					    =     f"""mod inverse of {a!r} and {m!r} does not exist"""
												raise ValueError(A					)
						UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     1, 0, a
						UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     0, 1, m
						while va != 0:
												UpperCAmelCase					    =     ua // va
												UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase    ,    UpperCAmelCase					    =     (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
						return ua % m





