


'''simple docstring'''




from __future__ import annotations





def 							a_       (						lowercase							,						lowercase							,						lowercase    )			->Tuple:






    '''simple docstring'''

    assert n > 1 and a > 0 and greatest_common_divisor(UpperCamelCase__							,						UpperCamelCase__    ) == 1
    (__lowerCamelCase)		:      Optional[Any]											=					extended_gcd(UpperCamelCase__							,						UpperCamelCase__    )  # Implemented below
    __lowerCamelCase		:      str											=					(b * s) % n
    return x





def 							a_       (						lowercase							,						lowercase    )			->List[str]:






    '''simple docstring'''

    (__lowerCamelCase)		:      Any											=					extended_euclid(UpperCamelCase__							,						UpperCamelCase__    )  # Implemented below
    if b < 0:
        __lowerCamelCase		:      Tuple											=					(b % n + n) % n
    return b





def 							a_       (						lowercase							,						lowercase							,						lowercase    )			->Union[str, Any]:






    '''simple docstring'''

    __lowerCamelCase		:      List[str]											=					invert_modulo(UpperCamelCase__							,						UpperCamelCase__    )
    __lowerCamelCase		:      List[str]											=					(b * s) % n
    return x





def 							a_       (						lowercase							,						lowercase    )			->List[str]:






    '''simple docstring'''

    assert a >= 0 and b >= 0

    if b == 0:
        __lowerCamelCase		:      Dict											=					a, 1, 0
    else:
        (__lowerCamelCase)		:      Tuple											=					extended_gcd(UpperCamelCase__							,						a % b    )
        __lowerCamelCase		:      Optional[int]											=					q
        __lowerCamelCase		:      Tuple											=					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							,						lowercase    )			->Union[str, Any]:






    '''simple docstring'''

    if b == 0:
        return (1, 0)
    (__lowerCamelCase)		:      Any											=					extended_euclid(UpperCamelCase__							,						a % b    )
    __lowerCamelCase		:      Optional[int]											=					a // b
    return (y, x - k * y)





def 							a_       (						lowercase							,						lowercase    )			->Tuple:






    '''simple docstring'''

    if a < b:
        __lowerCamelCase		:      int											=					b, a

    while a % b != 0:
        __lowerCamelCase		:      Dict											=					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'''




# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__lowercase  :      Tuple      		=				abspath(join(dirname(dirname(dirname(__file__))), """src"""))
sys.path.insert(1, git_repo_path)


# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action="""ignore""", category=FutureWarning)





def 							a_       (						lowercase    )			->Any:






				'''simple docstring'''

				from diffusers.utils.testing_utils import pytest_addoption_shared

				pytest_addoption_shared(lowercase    )





def 							a_       (						lowercase    )			->str:






				'''simple docstring'''

				from diffusers.utils.testing_utils import pytest_terminal_summary_main

				__lowerCamelCase		:      Union[str, Any]											=					terminalreporter.config.getoption("--make-reports"    )
				if make_reports:
								pytest_terminal_summary_main(lowercase							,						id=lowercase    )





