
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


_A       =					logging.get_logger(__name__)

_A       =					{
    "MBZUAI/swiftformer-xs": "https://huggingface.co/MBZUAI/swiftformer-xs/resolve/main/config.json",
}





class      _lowerCAmelCase (     __a	):
				_lowercase      		='''swiftformer'''




				def __init__( self    ,    _UpperCamelCase=3    ,    _UpperCamelCase=[3, 3, 6, 4]    ,    _UpperCamelCase=[48, 56, 112, 220]    ,    _UpperCamelCase=4    ,    _UpperCamelCase=[True, True, True, True]    ,    _UpperCamelCase="gelu"    ,    _UpperCamelCase=3    ,    _UpperCamelCase=2    ,    _UpperCamelCase=1    ,    _UpperCamelCase=0.0    ,    _UpperCamelCase=True    ,    _UpperCamelCase=1e-5    ,    _UpperCamelCase=1e-5    ,    **_UpperCamelCase    ,    )    ->				str:
							super().__init__(**_UpperCamelCase					)
							lowerCAmelCase_      =     num_channels
							lowerCAmelCase_      =     depths
							lowerCAmelCase_      =     embed_dims
							lowerCAmelCase_      =     mlp_ratio
							lowerCAmelCase_      =     downsamples
							lowerCAmelCase_      =     hidden_act
							lowerCAmelCase_      =     down_patch_size
							lowerCAmelCase_      =     down_stride
							lowerCAmelCase_      =     down_pad
							lowerCAmelCase_      =     drop_path_rate
							lowerCAmelCase_      =     use_layer_scale
							lowerCAmelCase_      =     layer_scale_init_value
							lowerCAmelCase_      =     batch_norm_eps





class      _lowerCAmelCase (     __a	):
				_lowercase      		=version.parse('''1.11'''	)




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




				@property
				def 					__a						( self					)    ->				float:
							return 1e-4





from __future__ import annotations






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			assert n > 1 and a > 0 and greatest_common_divisor(__lowerCAmelCase   ,							__lowerCAmelCase    ) == 1
			((lowerCAmelCase_)     ,  (lowerCAmelCase_)     ,  (lowerCAmelCase_))      =     extended_gcd(__lowerCAmelCase   ,							__lowerCAmelCase    )  # Implemented below
			lowerCAmelCase_      =     (b * s) % n
			return x






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			((lowerCAmelCase_)     ,  (lowerCAmelCase_))      =     extended_euclid(__lowerCAmelCase   ,							__lowerCAmelCase    )  # Implemented below
			if b < 0:
						lowerCAmelCase_      =     (b % n + n) % n
			return b






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			lowerCAmelCase_      =     invert_modulo(__lowerCAmelCase   ,							__lowerCAmelCase    )
			lowerCAmelCase_      =     (b * s) % n
			return x






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			assert a >= 0 and b >= 0

			if b == 0:
						lowerCAmelCase_     ,  lowerCAmelCase_     ,  lowerCAmelCase_      =     a, 1, 0
			else:
						((lowerCAmelCase_)     ,  (lowerCAmelCase_)     ,  (lowerCAmelCase_))      =     extended_gcd(__lowerCAmelCase   ,							a % b    )
						lowerCAmelCase_      =     q
						lowerCAmelCase_      =     p - q * (a // b)

			assert a % d == 0 and b % d == 0
			assert d == a * x + b * y

			return (d, x, y)






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			if b == 0:
						return (1, 0)
			((lowerCAmelCase_)     ,  (lowerCAmelCase_))      =     extended_euclid(__lowerCAmelCase   ,							a % b    )
			lowerCAmelCase_      =     a // b
			return (y, x - k * y)






def        lowerCamelCase__    (    __lowerCAmelCase  :  int   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


			if a < b:
						lowerCAmelCase_     ,  lowerCAmelCase_      =     b, a

			while a % b != 0:
						lowerCAmelCase_     ,  lowerCAmelCase_      =     b, a % b

			return b


if __name__ == "__main__":
			from doctest import testmod

			testmod(name="modular_division", verbose=True)
			testmod(name="modular_division2", verbose=True)
			testmod(name="invert_modulo", verbose=True)
			testmod(name="extended_gcd", verbose=True)
			testmod(name="extended_euclid", verbose=True)
			testmod(name="greatest_common_divisor", verbose=True)



