



from __future__ import annotations







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase	)       ->       int:



						'''simple docstring'''






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







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase	)       ->       int:



						'''simple docstring'''






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







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase	)       ->       int:



						'''simple docstring'''






						UpperCAmelCase_     							=     invert_modulo(__UpperCAmelCase							,					__UpperCAmelCase	)
						UpperCAmelCase_     							=     (b * s) % n
						return x







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase	)       ->       tuple[int, int, int]:



						'''simple docstring'''






						assert a >= 0 and b >= 0

						if b == 0:
												UpperCAmelCase_							,      UpperCAmelCase_							,      UpperCAmelCase_     							=     a, 1, 0
						else:
												((UpperCAmelCase_)							,      (UpperCAmelCase_)							,      (UpperCAmelCase_))     							=     extended_gcd(__UpperCAmelCase							,					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			(		__UpperCAmelCase							,					__UpperCAmelCase	)       ->       tuple[int, int]:



						'''simple docstring'''






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







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase	)       ->       int:



						'''simple docstring'''






						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)







"""simple docstring"""

from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import is_torch_available, is_transformers_available


if is_transformers_available() and is_torch_available():
   from .image_encoder import PaintByExampleImageEncoder
   from .pipeline_paint_by_example import PaintByExamplePipeline



