




'''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


_lowercase  =			False
class 						a_				(			unittest.TestCase						):
	pass





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




	def   lowercase__   (       self     :  Dict      ):
							# clean up the VRAM after each test
							super().tearDown()
							gc.collect()
							torch.cuda.empty_cache()




	def   lowercase__   (       self     :  Tuple      ):
							__snake_case						 =   VersatileDiffusionTextToImagePipeline.from_pretrained('shi-labs/versatile-diffusion'      )
							# remove text_unet
							pipe.remove_unused_weights()
							pipe.to(__lowerCAmelCase      )
							pipe.set_progress_bar_config(disable=__lowerCAmelCase      )

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

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

							__snake_case						 =   generator.manual_seed(0      )
							__snake_case						 =   pipe(
							    prompt=__lowerCAmelCase       ,		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   lowercase__   (       self     :  Union[str, Any]      ):
							__snake_case						 =   VersatileDiffusionTextToImagePipeline.from_pretrained(
							    'shi-labs/versatile-diffusion'       ,		torch_dtype=torch.floataa      )
							pipe.to(__lowerCAmelCase      )
							pipe.set_progress_bar_config(disable=__lowerCAmelCase      )

							__snake_case						 =   'A painting of a squirrel eating a burger '
							__snake_case						 =   torch.manual_seed(0      )
							__snake_case						 =   pipe(
							    prompt=__lowerCAmelCase       ,		generator=__lowerCAmelCase       ,		guidance_scale=7.5       ,		num_inference_steps=5_0       ,		output_type='numpy'      ).images

							__snake_case						 =   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)
							__snake_case						 =   np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]      )

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







'''simple docstring'''


from math import isqrt, loga
def 						lowerCamelCase__   (				a							):
						__snake_case						 =   [True] * max_number
						for i in range(2    ,	isqrt(max_number - 1							) + 1							):
												if is_prime[i]:
																		for j in range(i**2    ,	a    ,	a							):
																								__snake_case						 =   False

						return [i for i in range(2    ,	a							) if is_prime[i]]
def 						lowerCamelCase__   (				a = 800800    ,	a = 800800							):
						__snake_case						 =   degree * loga(a							)
						__snake_case						 =   int(a							)
						__snake_case						 =   calculate_prime_numbers(a							)

						__snake_case						 =   0
						__snake_case						 =   0
						__snake_case						 =   len(a							) - 1
						while left < right:
												while (
												    prime_numbers[right] * loga(prime_numbers[left]							)
												    + prime_numbers[left] * loga(prime_numbers[right]							)
												    > upper_bound
												):
																		right -= 1
												hybrid_integers_count += right - left
												left += 1

						return hybrid_integers_count


if __name__ == "__main__":
	print(f'''{solution() = }''')

