



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


__lowerCamelCase  				=					False



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





 """simple docstring"""



 def lowercase_		(						self					)	->							List[Any]:




   """simple docstring"""







   super().tearDown()
   gc.collect()
   torch.cuda.empty_cache()
 def lowercase_		(						self					)	->							List[Any]:




   """simple docstring"""







   _A           =    VersatileDiffusionDualGuidedPipeline.from_pretrained('''shi-labs/versatile-diffusion'''					)
   # remove text_unet
   pipe.remove_unused_weights()
   pipe.to(a					)
   pipe.set_progress_bar_config(disable=a					)

   _A           =    load_image(
       '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''					)

   _A           =    torch.manual_seed(0					)
   _A           =    pipe(
       prompt='''first prompt'''	,    image=a	,    text_to_image_strength=0.75	,    generator=a	,    guidance_scale=7.5	,    num_inference_steps=2	,    output_type='''numpy'''	,    ).images

   with tempfile.TemporaryDirectory() as tmpdirname:
     pipe.save_pretrained(a					)
     _A           =    VersatileDiffusionDualGuidedPipeline.from_pretrained(a					)

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

   _A           =    generator.manual_seed(0					)
   _A           =    pipe(
       prompt='''first prompt'''	,    image=a	,    text_to_image_strength=0.75	,    generator=a	,    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 lowercase_		(						self					)	->							Optional[int]:




   """simple docstring"""







   _A           =    VersatileDiffusionDualGuidedPipeline.from_pretrained('''shi-labs/versatile-diffusion'''					)
   pipe.remove_unused_weights()
   pipe.to(a					)
   pipe.set_progress_bar_config(disable=a					)

   _A           =    '''cyberpunk 2077'''
   _A           =    load_image(
       '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''					)
   _A           =    torch.manual_seed(0					)
   _A           =    pipe(
       prompt=a	,    image=a	,    text_to_image_strength=0.75	,    generator=a	,    guidance_scale=7.5	,    num_inference_steps=5_0	,    output_type='''numpy'''	,    ).images

   _A           =    image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

   assert image.shape == (1, 5_1_2, 5_1_2, 3)
   _A           =    np.array([0.0_787, 0.0_849, 0.0_826, 0.0_812, 0.0_807, 0.0_795, 0.0_818, 0.0_798, 0.0_779]					)

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




from ..utils import DummyObject, requires_backends



class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[int]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Any:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Dict:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[int]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[str]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Dict:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[str]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Any:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[str]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Any:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[str]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[str]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Tuple:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[int]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[int]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							List[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							str:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Dict:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[int]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Optional[Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Union[str, Any]:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Any:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							int:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)







class 		_snake_case      (			metaclass=lowerCamelCase				):





 """simple docstring"""



 lowerCamelCase_          =			['''tokenizers''']
 def __init__(						self	,    *a	,    **a					)	->							Any:




   """simple docstring"""







   requires_backends(self	,    ['''tokenizers''']					)