


import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


SCREAMING_SNAKE_CASE       :		Union[str, Any]         =				False






class      UpperCamelCase					(		unittest.TestCase     ):


   '''simple docstring'''







   pass






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


   '''simple docstring'''







   def 		UpperCamelCase  (     self		):
        lowercase_       :Optional[Any]     =       VersatileDiffusionImageVariationPipeline.from_pretrained('''shi-labs/versatile-diffusion'''		)
        pipe.to(UpperCamelCase_		)
        pipe.set_progress_bar_config(disable=UpperCamelCase_		)

        lowercase_       :int     =       load_image(
            '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''		)
        lowercase_       :List[Any]     =       torch.manual_seed(0		)
        lowercase_       :Dict     =       pipe(
            image=UpperCamelCase_   ,							generator=UpperCamelCase_   ,							guidance_scale=7.5   ,							num_inference_steps=50   ,							output_type='''numpy'''   ,							).images

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

        assert image.shape == (1, 512, 512, 3)
        lowercase_       :int     =       np.array([0.0441, 0.0469, 0.0507, 0.0575, 0.0632, 0.0650, 0.0865, 0.0909, 0.0945]		)

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





from __future__ import annotations




def     UpperCamelCase    (      _a       ,		_a = None       ,		_a = None		)					->							None:
     '''simple docstring'''





     if start is None:
          lowercase_       :str     =       0

     if end is None:
          lowercase_       :str     =       len(_a		) - 1

     if start >= end:
          return

     lowercase_       :Dict     =       (start + end) // 2

     slowsort(_a       ,		_a       ,		_a		)
     slowsort(_a       ,		mid + 1       ,		_a		)

     if sequence[end] < sequence[mid]:
          lowercase_    ,      lowercase_       :List[Any]     =       sequence[mid], sequence[end]

     slowsort(_a       ,		_a       ,		end - 1		)


if __name__ == "__main__":
   from doctest import testmod

   testmod()

