

import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


__a    :str      =			False

class   _a					(			unittest.TestCase				):




      """simple docstring"""

      pass




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




      """simple docstring"""

      def 		__A	(   self							:				List[str]	):
            # clean up the VRAM after each test
            super().tearDown()
            gc.collect()
            torch.cuda.empty_cache()





      def 		__A	(   self							:				Union[str, Any]	):
            A_						  =				VersatileDiffusionTextToImagePipeline.from_pretrained("shi-labs/versatile-diffusion"	)
            # remove text_unet
            pipe.remove_unused_weights()
            pipe.to(UpperCAmelCase	)
            pipe.set_progress_bar_config(disable=UpperCAmelCase	)

            A_						  =				"A painting of a squirrel eating a burger "
            A_						  =				torch.manual_seed(0	)
            A_						  =				pipe(
                prompt=UpperCAmelCase						,			generator=UpperCAmelCase						,			guidance_scale=7.5						,			num_inference_steps=2						,			output_type="numpy"	).images

            with tempfile.TemporaryDirectory() as tmpdirname:
                  pipe.save_pretrained(UpperCAmelCase	)
                  A_						  =				VersatileDiffusionTextToImagePipeline.from_pretrained(UpperCAmelCase	)
            pipe.to(UpperCAmelCase	)
            pipe.set_progress_bar_config(disable=UpperCAmelCase	)

            A_						  =				generator.manual_seed(0	)
            A_						  =				pipe(
                prompt=UpperCAmelCase						,			generator=UpperCAmelCase						,			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 		__A	(   self							:				Optional[int]	):
            A_						  =				VersatileDiffusionTextToImagePipeline.from_pretrained(
                "shi-labs/versatile-diffusion"						,			torch_dtype=torch.floataa	)
            pipe.to(UpperCAmelCase	)
            pipe.set_progress_bar_config(disable=UpperCAmelCase	)

            A_						  =				"A painting of a squirrel eating a burger "
            A_						  =				torch.manual_seed(0	)
            A_						  =				pipe(
                prompt=UpperCAmelCase						,			generator=UpperCAmelCase						,			guidance_scale=7.5						,			num_inference_steps=50						,			output_type="numpy"	).images

            A_						  =				image[0, 253:256, 253:256, -1]

            assert image.shape == (1, 512, 512, 3)
            A_						  =				np.array([0.3_367, 0.3_169, 0.2_656, 0.3_870, 0.4_790, 0.3_796, 0.4_009, 0.4_878, 0.4_778]	)

            assert np.abs(image_slice.flatten() - expected_slice	).max() < 1E-2
"""simple docstring"""


def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase							)				->   float:




						'''simple docstring'''



						return price * (1 + tax_rate)


if __name__ == "__main__":
	print(F'''{price_plus_tax(100, 0.25) = }''')
	print(F'''{price_plus_tax(125.50, 0.05) = }''')


