


from __future__ import annotations

import math


def 				lowerCamelCase__	(      a	:   Union[str, Any]				)    ->	Optional[int]:





			"""simple docstring"""

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5	,  int(math.sqrt(a				) + 1				)	,  6				):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True


def 				lowerCamelCase__	(      a	:   Optional[int]				)    ->	Any:





			"""simple docstring"""
			a__						  =    str(a				)
			a__						  =    [n]
			for i in range(1	,  len(a				)				):
						list_nums.append(int(str_num[i:]				)				)
						list_nums.append(int(str_num[:-i]				)				)
			return list_nums


def 				lowerCamelCase__	(      a	:   Tuple				)    ->	Optional[int]:





			"""simple docstring"""
			if len(str(a				)				) > 3:
						if not is_prime(int(str(a				)[-3:]				)				) or not is_prime(int(str(a				)[:3]				)				):
									return False
			return True


def 				lowerCamelCase__	(      a	:   List[str] = 11				)    ->	Dict:





			"""simple docstring"""
			a__						  =    []
			a__						  =    13
			while len(a				) != count:
						if validate(a				):
									a__						  =    list_truncated_nums(a				)
									if all(is_prime(a				) for i in list_nums				):
												list_truncated_primes.append(a				)
						num += 2
			return list_truncated_primes


def 				lowerCamelCase__	(      )    ->	List[str]:





			"""simple docstring"""
			return sum(compute_truncated_primes(11				)				)


if __name__ == "__main__":
		print(f'''{sum(compute_truncated_primes(11)) = }''')






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


snake_case__			 =						False


class 					lowerCAmelCase_ (       unittest.TestCase):
						pass






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




						def  _snake_case					(	self						:   Tuple						)      ->Optional[int]:






									"""simple docstring"""






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




						def  _snake_case					(	self						:   Dict						)      ->Any:






									"""simple docstring"""






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

									a__ :List[Any]						  =    "A painting of a squirrel eating a burger "
									a__ :Optional[Any]						  =    torch.manual_seed(0						)
									a__ :List[Any]						  =    pipe(
									    prompt=__A   ,     generator=__A   ,     guidance_scale=7.5   ,     num_inference_steps=2   ,     output_type="numpy"						).images

									with tempfile.TemporaryDirectory() as tmpdirname:
												pipe.save_pretrained(__A						)
												a__ :List[Any]						  =    VersatileDiffusionTextToImagePipeline.from_pretrained(__A						)
									pipe.to(__A						)
									pipe.set_progress_bar_config(disable=__A						)

									a__ :Optional[int]						  =    generator.manual_seed(0						)
									a__ :List[Any]						  =    pipe(
									    prompt=__A   ,     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  _snake_case					(	self						:   Optional[Any]						)      ->List[Any]:






									"""simple docstring"""






									a__ :Tuple						  =    VersatileDiffusionTextToImagePipeline.from_pretrained(
									    "shi-labs/versatile-diffusion"   ,     torch_dtype=torch.floataa						)
									pipe.to(__A						)
									pipe.set_progress_bar_config(disable=__A						)

									a__ :Tuple						  =    "A painting of a squirrel eating a burger "
									a__ :Tuple						  =    torch.manual_seed(0						)
									a__ :Optional[Any]						  =    pipe(
									    prompt=__A   ,     generator=__A   ,     guidance_scale=7.5   ,     num_inference_steps=50   ,     output_type="numpy"						).images

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

									assert image.shape == (1, 512, 512, 3)
									a__ :Tuple						  =    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


