

"""simple docstring"""


import gc
import tempfile
import unittest

import numpy as np
import torch

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


UpperCAmelCase													=False





class lowerCamelCase__   (				unittest.TestCase    ):



    '''simple docstring'''




    pass





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



    '''simple docstring'''




    def UpperCamelCase__		( self    )    ->      str:
          # clean up the VRAM after each test
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()




    def UpperCamelCase__		( self    )    ->      Any:
          A				  =		VersatileDiffusionPipeline.from_pretrained("""shi-labs/versatile-diffusion""" ,torch_dtype=torch.floataa    )
          pipe.to(lowerCamelCase_    )
          pipe.set_progress_bar_config(disable=lowerCamelCase_    )

          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.dual_guided(
              prompt="""first prompt""" ,image=lowerCamelCase_ ,text_to_image_strength=0.75 ,generator=lowerCamelCase_ ,guidance_scale=7.5 ,num_inference_steps=2 ,output_type="""numpy""" ,).images

          with tempfile.TemporaryDirectory() as tmpdirname:
                pipe.save_pretrained(lowerCamelCase_    )
                A				  =		VersatileDiffusionPipeline.from_pretrained(lowerCamelCase_ ,torch_dtype=torch.floataa    )
          pipe.to(lowerCamelCase_    )
          pipe.set_progress_bar_config(disable=lowerCamelCase_    )

          A				  =		generator.manual_seed(0    )
          A				  =		pipe.dual_guided(
              prompt="""first prompt""" ,image=lowerCamelCase_ ,text_to_image_strength=0.75 ,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    )    ->      Optional[int]:
          A				  =		VersatileDiffusionPipeline.from_pretrained("""shi-labs/versatile-diffusion""" ,torch_dtype=torch.floataa    )
          pipe.to(lowerCamelCase_    )
          pipe.set_progress_bar_config(disable=lowerCamelCase_    )

          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.dual_guided(
              prompt=lowerCamelCase_ ,image=lowerCamelCase_ ,text_to_image_strength=0.75 ,generator=lowerCamelCase_ ,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.14_48, 0.16_19, 0.17_41, 0.10_86, 0.11_47, 0.11_28, 0.11_99, 0.11_65, 0.10_01]    )

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

          A				  =		"""A painting of a squirrel eating a burger """
          A				  =		torch.manual_seed(0    )
          A				  =		pipe.text_to_image(
              prompt=lowerCamelCase_ ,generator=lowerCamelCase_ ,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.33_67, 0.31_69, 0.26_56, 0.38_70, 0.47_90, 0.37_96, 0.40_09, 0.48_78, 0.47_78]    )

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

          A				  =		pipe.image_variation(lowerCamelCase_ ,generator=lowerCamelCase_ ,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.30_76, 0.31_23, 0.32_84, 0.37_82, 0.37_70, 0.38_94, 0.42_97, 0.43_31, 0.44_56]    )

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







"""simple docstring"""


from __future__ import annotations



def   _A					(	_a	:						list[float]     ,   _a	:						list[float]				):



      """simple docstring"""






      A				  =		sorted(numsa + numsa				)
      A  ,			A				  =		divmod(len(_a				)     ,   2				)
      if mod == 1:
            return all_numbers[div]
      else:
            return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  UpperCAmelCase													=[float(x) for x in input("Enter the elements of first array: ").split()]
  UpperCAmelCase													=[float(x) for x in input("Enter the elements of second array: ").split()]
  print(f"""The median of two arrays is: {median_of_two_arrays(array_a, array_a)}""")




