"""simple docstring"""







import unittest

import numpy as np
import torch

from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()



class  _lowerCamelCase			(unittest.TestCase     ):







				@property
				def 							__UpperCAmelCase					( self    :       List[str]						):

					"""simple docstring"""






					torch.manual_seed(0						)
					_lowercase :    Union[str, Any]							=							UNetaDModel(
					    block_out_channels=(3_2, 6_4)			,					layers_per_block=2			,					sample_size=3_2			,					in_channels=3			,					out_channels=3			,					down_block_types=('DownBlock2D', 'AttnDownBlock2D')			,					up_block_types=('AttnUpBlock2D', 'UpBlock2D')			,					)
					return model







				def 							__UpperCAmelCase					( self    :       Optional[int]						):

					"""simple docstring"""






					_lowercase :    int							=							self.dummy_uncond_unet
					_lowercase :    Optional[Any]							=							PNDMScheduler()

					_lowercase :    Dict							=							PNDMPipeline(unet=lowerCamelCase_			,					scheduler=lowerCamelCase_						)
					pndm.to(lowerCamelCase_						)
					pndm.set_progress_bar_config(disable=lowerCamelCase_						)

					_lowercase :    Dict							=							torch.manual_seed(0						)
					_lowercase :    Tuple							=							pndm(generator=lowerCamelCase_			,					num_inference_steps=2_0			,					output_type='numpy'						).images

					_lowercase :    Dict							=							torch.manual_seed(0						)
					_lowercase :    int							=							pndm(generator=lowerCamelCase_			,					num_inference_steps=2_0			,					output_type='numpy'			,					return_dict=lowerCamelCase_						)[0]

					_lowercase :    Optional[Any]							=							image[0, -3:, -3:, -1]
					_lowercase :    Optional[int]							=							image_from_tuple[0, -3:, -3:, -1]

					assert image.shape == (1, 3_2, 3_2, 3)
					_lowercase :    Union[str, Any]							=							np.array([1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0]						)

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



@slow
@require_torch
class  _lowerCamelCase			(unittest.TestCase     ):







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""simple docstring"""






					_lowercase :    Optional[Any]							=							'google/ddpm-cifar10-32'

					_lowercase :    Union[str, Any]							=							UNetaDModel.from_pretrained(lowerCamelCase_						)
					_lowercase :    int							=							PNDMScheduler()

					_lowercase :    Dict							=							PNDMPipeline(unet=lowerCamelCase_			,					scheduler=lowerCamelCase_						)
					pndm.to(lowerCamelCase_						)
					pndm.set_progress_bar_config(disable=lowerCamelCase_						)
					_lowercase :    Tuple							=							torch.manual_seed(0						)
					_lowercase :    Optional[Any]							=							pndm(generator=lowerCamelCase_			,					output_type='numpy'						).images

					_lowercase :    Tuple							=							image[0, -3:, -3:, -1]

					assert image.shape == (1, 3_2, 3_2, 3)
					_lowercase :    List[str]							=							np.array([0.1564, 0.1_4645, 0.1406, 0.1_4715, 0.1_2425, 0.1_4045, 0.1_3115, 0.1_2175, 0.125]						)

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




"""simple docstring"""







from __future__ import annotations


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Any							=							[True] * limit
	_lowercase :    Union[str, Any]							=							False
	_lowercase :    Any							=							False
	_lowercase :    List[Any]							=							True

	for i in range(3     ,int(limit**0.5 + 1			)     ,2			):
		_lowercase :    Optional[Any]							=							i * 2
		while index < limit:
			_lowercase :    int							=							False
			_lowercase :    Tuple							=							index + i

	_lowercase :    Optional[Any]							=							[2]

	for i in range(3     ,__UpperCAmelCase     ,2			):
		if is_prime[i]:
			primes.append(__UpperCAmelCase			)

	return primes


def      __lowerCAmelCase(		__UpperCAmelCase = 1_000_000			):






	"""simple docstring"""





	_lowercase :    Optional[Any]							=							prime_sieve(__UpperCAmelCase			)
	_lowercase :    int							=							0
	_lowercase :    List[Any]							=							0

	for i in range(len(__UpperCAmelCase			)			):
		for j in range(i + length     ,len(__UpperCAmelCase			)			):
			_lowercase :    List[Any]							=							sum(primes[i:j]			)
			if sol >= ceiling:
				break

			if sol in primes:
				_lowercase :    Optional[int]							=							j - i
				_lowercase :    Tuple							=							sol

	return largest


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



