





from __future__ import annotations

def      a    (   _lowercase :  int			,    _lowercase :  int			,    _lowercase :  int							)  ->int:
		assert n > 1 and a > 0 and greatest_common_divisor(_lowercase			,    _lowercase							) == 1
		((UpperCamelCase__)	,      (UpperCamelCase__)	,      (UpperCamelCase__))								=						extended_gcd(_lowercase			,    _lowercase							)  # Implemented below
		UpperCamelCase__								=						(b * s) % n
		return x

def      a    (   _lowercase :  int			,    _lowercase :  int							)  ->int:
		((UpperCamelCase__)	,      (UpperCamelCase__))								=						extended_euclid(_lowercase			,    _lowercase							)  # Implemented below
		if b < 0:
				UpperCamelCase__								=						(b % n + n) % n
		return b

def      a    (   _lowercase :  int			,    _lowercase :  int			,    _lowercase :  int							)  ->int:
		UpperCamelCase__								=						invert_modulo(_lowercase			,    _lowercase							)
		UpperCamelCase__								=						(b * s) % n
		return x

def      a    (   _lowercase :  int			,    _lowercase :  int							)  ->tuple[int, int, int]:
		assert a >= 0 and b >= 0

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

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

		return (d, x, y)

def      a    (   _lowercase :  int			,    _lowercase :  int							)  ->tuple[int, int]:
		if b == 0:
				return (1, 0)
		((UpperCamelCase__)	,      (UpperCamelCase__))								=						extended_euclid(_lowercase			,    a % b							)
		UpperCamelCase__								=						a // b
		return (y, x - k * y)

def      a    (   _lowercase :  int			,    _lowercase :  int							)  ->int:
		if a < b:
				UpperCamelCase__	,      UpperCamelCase__								=						b, a

		while a % b != 0:
				UpperCamelCase__	,      UpperCamelCase__								=						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)












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowerCAmelCase 	=      {"configuration_visual_bert": ["VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VisualBertConfig"]}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCAmelCase 	=      [
				    "VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "VisualBertForMultipleChoice",
				    "VisualBertForPreTraining",
				    "VisualBertForQuestionAnswering",
				    "VisualBertForRegionToPhraseAlignment",
				    "VisualBertForVisualReasoning",
				    "VisualBertLayer",
				    "VisualBertModel",
				    "VisualBertPreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_visual_bert import (
								    VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    VisualBertForMultipleChoice,
								    VisualBertForPreTraining,
								    VisualBertForQuestionAnswering,
								    VisualBertForRegionToPhraseAlignment,
								    VisualBertForVisualReasoning,
								    VisualBertLayer,
								    VisualBertModel,
								    VisualBertPreTrainedModel,
								)


else:
				import sys

				__lowerCAmelCase 	=      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





