



"""simple docstring"""






from __future__ import annotations
def      A      (			_A,     _A,     _A							):




					"""simple docstring"""
					assert n > 1 and a > 0 and greatest_common_divisor(_A,     _A							) == 1
					(snake_case_)						:List[str]								=						extended_gcd(_A,     _A							)  # Implemented below
					snake_case_						:Union[str, Any]								=						(b * s) % n
					return x
def      A      (			_A,     _A							):




					"""simple docstring"""
					(snake_case_)						:List[str]								=						extended_euclid(_A,     _A							)  # Implemented below
					if b < 0:
										snake_case_						:List[str]								=						(b % n + n) % n
					return b
def      A      (			_A,     _A,     _A							):




					"""simple docstring"""
					snake_case_						:Tuple								=						invert_modulo(_A,     _A							)
					snake_case_						:Any								=						(b * s) % n
					return x
def      A      (			_A,     _A							):




					"""simple docstring"""
					assert a >= 0 and b >= 0

					if b == 0:
										snake_case_						:Union[str, Any]								=						a, 1, 0
					else:
										(snake_case_)						:Tuple								=						extended_gcd(_A,     a % b							)
										snake_case_						:int								=						q
										snake_case_						:Any								=						p - q * (a // b)

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

					return (d, x, y)
def      A      (			_A,     _A							):




					"""simple docstring"""

					if b == 0:
										return (1, 0)
					(snake_case_)						:int								=						extended_euclid(_A,     a % b							)
					snake_case_						:List[Any]								=						a // b
					return (y, x - k * y)
def      A      (			_A,     _A							):




					"""simple docstring"""

					if a < b:
										snake_case_						:Union[str, Any]								=						b, a

					while a % b != 0:
										snake_case_						:Optional[int]								=						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)










"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__UpperCAmelCase      :      Optional[int]   					=					{
    'configuration_segformer': ['SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SegformerConfig', 'SegformerOnnxConfig']
}

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__UpperCAmelCase      :      int   					=					['SegformerFeatureExtractor']
				__UpperCAmelCase      :      Dict   					=					['SegformerImageProcessor']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__UpperCAmelCase      :      Optional[Any]   					=					[
				    'SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'SegformerDecodeHead',
				    'SegformerForImageClassification',
				    'SegformerForSemanticSegmentation',
				    'SegformerLayer',
				    'SegformerModel',
				    'SegformerPreTrainedModel',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__UpperCAmelCase      :      Dict   					=					[
				    'TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFSegformerDecodeHead',
				    'TFSegformerForImageClassification',
				    'TFSegformerForSemanticSegmentation',
				    'TFSegformerModel',
				    'TFSegformerPreTrainedModel',
				]


if TYPE_CHECKING:
				from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_segformer import SegformerFeatureExtractor
								from .image_processing_segformer import SegformerImageProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_segformer import (
								    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
								    SegformerDecodeHead,
								    SegformerForImageClassification,
								    SegformerForSemanticSegmentation,
								    SegformerLayer,
								    SegformerModel,
								    SegformerPreTrainedModel,
								)
				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_segformer import (
								    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFSegformerDecodeHead,
								    TFSegformerForImageClassification,
								    TFSegformerForSemanticSegmentation,
								    TFSegformerModel,
								    TFSegformerPreTrainedModel,
								)

else:
				import sys

				__UpperCAmelCase      :      Optional[Any]   					=					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

