
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase  )						->List[Any]:
 return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase=0  )						->Any:
 return sorted(__A			,		key=lambda _lowerCamelCase  : x[column]  )
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase			,		_lowerCamelCase=float("inf"  )  )						->Optional[Any]:

 for i in range(points_counts - 1  ):
  for j in range(i + 1			,		__A  ):
   _UpperCAmelCase 				=euclidean_distance_sqr(points[i]			,		points[j]  )
   if current_dis < min_dis:
    _UpperCAmelCase 				=current_dis
 return min_dis
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase			,		_lowerCamelCase=float("inf"  )  )						->Optional[Any]:

 for i in range(min(6			,		points_counts - 1  )			,		__A  ):
  for j in range(max(0			,		i - 6  )			,		__A  ):
   _UpperCAmelCase 				=euclidean_distance_sqr(points[i]			,		points[j]  )
   if current_dis < min_dis:
    _UpperCAmelCase 				=current_dis
 return min_dis
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase			,		_lowerCamelCase  )						->str:

 # base case
 if points_counts <= 3:
  return dis_between_closest_pair(__A			,		__A  )

 # recursion
 _UpperCAmelCase 				=points_counts // 2
 _UpperCAmelCase 				=closest_pair_of_points_sqr(
     __A			,		points_sorted_on_y[:mid]			,		__A  )
 _UpperCAmelCase 				=closest_pair_of_points_sqr(
     __A			,		points_sorted_on_y[mid:]			,		points_counts - mid  )
 _UpperCAmelCase 				=min(__A			,		__A  )
 _UpperCAmelCase 				=[]
 for point in points_sorted_on_x:
  if abs(point[0] - points_sorted_on_x[mid][0]  ) < closest_pair_dis:
   cross_strip.append(__A  )

 _UpperCAmelCase 				=dis_between_closest_in_strip(
     __A			,		len(__A  )			,		__A  )
 return min(__A			,		__A  )
def 					lowerCamelCase__		(				_lowerCamelCase			,		_lowerCamelCase  )						->str:
 _UpperCAmelCase 				=column_based_sort(__A			,		column=0  )
 _UpperCAmelCase 				=column_based_sort(__A			,		column=1  )
 return (
     closest_pair_of_points_sqr(
         __A			,		__A			,		__A  )
 ) ** 0.5


if __name__ == "__main__":
       snake_case__      :		str				=       [(2, 3), (1_2, 3_0), (4_0, 5_0), (5, 1), (1_2, 1_0), (3, 4)]
       print('Distance:', closest_pair_of_points(points, len(points)))










"""simple docstring"""

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_						:    Union[str, Any]				=      False
class     lowerCAmelCase__						(	unittest.TestCase ):


	'''simple docstring'''







	pass




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


	'''simple docstring'''







	def 			_lowerCAmelCase     (      self				:       Any    )						->	List[str]:





					"""simple docstring"""


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





	def 			_lowerCAmelCase     (      self				:       Optional[Any]    )						->	List[Any]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Tuple							=     VersatileDiffusionTextToImagePipeline.from_pretrained('shi-labs/versatile-diffusion'    )
					# remove text_unet
					pipe.remove_unused_weights()
					pipe.to(_SCREAMING_SNAKE_CASE    )
					pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     'A painting of a squirrel eating a burger '
					SCREAMING_SNAKE_CASE						:							List[str]							=     torch.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							int							=     pipe(
					    prompt=_SCREAMING_SNAKE_CASE     ,       generator=_SCREAMING_SNAKE_CASE     ,       guidance_scale=7.5     ,       num_inference_steps=2     ,       output_type='numpy'    ).images

					with tempfile.TemporaryDirectory() as tmpdirname:
									pipe.save_pretrained(_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE						:							Dict							=     VersatileDiffusionTextToImagePipeline.from_pretrained(_SCREAMING_SNAKE_CASE    )
					pipe.to(_SCREAMING_SNAKE_CASE    )
					pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     generator.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							Tuple							=     pipe(
					    prompt=_SCREAMING_SNAKE_CASE     ,       generator=_SCREAMING_SNAKE_CASE     ,       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 			_lowerCAmelCase     (      self				:       Dict    )						->	Dict:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							List[Any]							=     VersatileDiffusionTextToImagePipeline.from_pretrained(
					    'shi-labs/versatile-diffusion'     ,       torch_dtype=torch.floataa    )
					pipe.to(_SCREAMING_SNAKE_CASE    )
					pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					SCREAMING_SNAKE_CASE						:							Optional[int]							=     'A painting of a squirrel eating a burger '
					SCREAMING_SNAKE_CASE						:							Dict							=     torch.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							Any							=     pipe(
					    prompt=_SCREAMING_SNAKE_CASE     ,       generator=_SCREAMING_SNAKE_CASE     ,       guidance_scale=7.5     ,       num_inference_steps=50     ,       output_type='numpy'    ).images

					SCREAMING_SNAKE_CASE						:							Tuple							=     image[0, 253:256, 253:256, -1]

					assert image.shape == (1, 512, 512, 3)
					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     np.array([0.3_3_6_7, 0.3_1_6_9, 0.2_6_5_6, 0.3_8_7_0, 0.4_7_9_0, 0.3_7_9_6, 0.4_0_0_9, 0.4_8_7_8, 0.4_7_7_8]    )

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





