





"""simple docstring"""



import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionDualGuidedPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


a_				=    False






@nightly
@require_torch_gpu
class 	__snake_case      (	unittest.TestCase  ):





 """simple docstring"""


 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     super().tearDown()
     gc.collect()
     torch.cuda.empty_cache()

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		Tuple						=  VersatileDiffusionDualGuidedPipeline.from_pretrained('''shi-labs/versatile-diffusion'''						)
     # remove text_unet
     pipe.remove_unused_weights()
     pipe.to(__lowerCamelCase						)
     pipe.set_progress_bar_config(disable=__lowerCamelCase						)

     __A					:		List[Any]						=  load_image(
         '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''						)

     __A					:		Optional[int]						=  torch.manual_seed(0						)
     __A					:		str						=  pipe(
         prompt='''first prompt'''      ,		image=__lowerCamelCase      ,		text_to_image_strength=0.7_5      ,		generator=__lowerCamelCase      ,		guidance_scale=7.5      ,		num_inference_steps=2      ,		output_type='''numpy'''      ,		).images

     with tempfile.TemporaryDirectory() as tmpdirname:
         pipe.save_pretrained(__lowerCamelCase						)
         __A					:		Optional[int]						=  VersatileDiffusionDualGuidedPipeline.from_pretrained(__lowerCamelCase						)

     pipe.to(__lowerCamelCase						)
     pipe.set_progress_bar_config(disable=__lowerCamelCase						)

     __A					:		Union[str, Any]						=  generator.manual_seed(0						)
     __A					:		List[Any]						=  pipe(
         prompt='''first prompt'''      ,		image=__lowerCamelCase      ,		text_to_image_strength=0.7_5      ,		generator=__lowerCamelCase      ,		guidance_scale=7.5      ,		num_inference_steps=2      ,		output_type='''numpy'''      ,		).images

     assert np.abs(image - new_image						).sum() < 1e-5, "Models don't have the same forward pass"







 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		List[Any]						=  VersatileDiffusionDualGuidedPipeline.from_pretrained('''shi-labs/versatile-diffusion'''						)
     pipe.remove_unused_weights()
     pipe.to(__lowerCamelCase						)
     pipe.set_progress_bar_config(disable=__lowerCamelCase						)

     __A					:		Union[str, Any]						=  '''cyberpunk 2077'''
     __A					:		List[str]						=  load_image(
         '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''						)
     __A					:		Union[str, Any]						=  torch.manual_seed(0						)
     __A					:		Dict						=  pipe(
         prompt=__lowerCamelCase      ,		image=__lowerCamelCase      ,		text_to_image_strength=0.7_5      ,		generator=__lowerCamelCase      ,		guidance_scale=7.5      ,		num_inference_steps=50      ,		output_type='''numpy'''      ,		).images

     __A					:		Union[str, Any]						=  image[0, 253:256, 253:256, -1]

     assert image.shape == (1, 512, 512, 3)
     __A					:		Union[str, Any]						=  np.array([0.0_7_8_7, 0.0_8_4_9, 0.0_8_2_6, 0.0_8_1_2, 0.0_8_0_7, 0.0_7_9_5, 0.0_8_1_8, 0.0_7_9_8, 0.0_7_7_9]						)

     assert np.abs(image_slice.flatten() - expected_slice						).max() < 1e-2











"""simple docstring"""



from __future__ import annotations

import sys







def 	__lowercase  (     snake_case_						:						int       ,snake_case_						:						int		)     ->tuple[int, int]:



    '''simple docstring'''







    if abs(snake_case_		) == 1:
        return a, 0
    elif abs(snake_case_		) == 1:
        return 0, b

    __A				, __A					:		int						=  a, b
    __A				, __A					:		Any						=  1, 0
    __A				, __A					:		int						=  0, 1

    while remainder != 0:
        __A					:		List[Any]						=  old_remainder // remainder
        __A				, __A					:		int						=  remainder, old_remainder - quotient * remainder
        __A				, __A					:		List[Any]						=  coeff_a, old_coeff_a - quotient * coeff_a
        __A				, __A					:		Union[str, Any]						=  coeff_b, old_coeff_b - quotient * coeff_b

    # sign correction for negative numbers
    if a < 0:
        __A					:		Optional[Any]						=  -old_coeff_a
    if b < 0:
        __A					:		List[Any]						=  -old_coeff_b

    return old_coeff_a, old_coeff_b







def 	__lowercase  (     )     ->List[str]:



    '''simple docstring'''







    if len(sys.argv		) < 3:
        print('''2 integer arguments required'''		)
        return 1
    __A					:		Optional[int]						=  int(sys.argv[1]		)
    __A					:		Tuple						=  int(sys.argv[2]		)
    print(extended_euclidean_algorithm(snake_case_       ,snake_case_		)		)
    return 0


if __name__ == "__main__":
       raise SystemExit(main())




