






from __future__ import annotations


def __A   (				__lowerCAmelCase			,		__lowerCAmelCase			,		__lowerCAmelCase     )->  int:





						"""simple docstring"""



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


def __A   (				__lowerCAmelCase			,		__lowerCAmelCase     )->  int:





						"""simple docstring"""



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


def __A   (				__lowerCAmelCase			,		__lowerCAmelCase			,		__lowerCAmelCase     )->  int:





						"""simple docstring"""



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


def __A   (				__lowerCAmelCase			,		__lowerCAmelCase     )->  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(__lowerCAmelCase			,		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   (				__lowerCAmelCase			,		__lowerCAmelCase     )->  tuple[int, int]:





						"""simple docstring"""



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


def __A   (				__lowerCAmelCase			,		__lowerCAmelCase     )->  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)








import unittest

import torch

from diffusers import DDIMScheduler, TextToVideoZeroPipeline
from diffusers.utils import load_pt, require_torch_gpu, slow

from ..test_pipelines_common import assert_mean_pixel_difference





@slow
@require_torch_gpu
class __lowerCamelCase			(				unittest.TestCase):





	"""simple docstring"""






	def 	UpperCamelCase   (							self   ):
							"""simple docstring"""







							_UpperCAmelCase     =      'runwayml/stable-diffusion-v1-5'
							_UpperCAmelCase     =      TextToVideoZeroPipeline.from_pretrained(UpperCAmelCase	,   torch_dtype=torch.floataa   ).to('cuda'   )
							_UpperCAmelCase     =      DDIMScheduler.from_config(pipe.scheduler.config   )
							_UpperCAmelCase     =      torch.Generator(device='cuda'   ).manual_seed(0   )

							_UpperCAmelCase     =      'A bear is playing a guitar on Times Square'
							_UpperCAmelCase     =      pipe(prompt=UpperCAmelCase	,   generator=UpperCAmelCase   ).images

							_UpperCAmelCase     =      load_pt(
							    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/A bear is playing a guitar on Times Square.pt'   )

							assert_mean_pixel_difference(UpperCAmelCase	,   UpperCAmelCase   )
