



"""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 		__UpperCAmelCase				(	unittest.TestCase					):







 """simple docstring"""




 @property
 def  A  (				self					: Optional[Any]	)->	Any:
   torch.manual_seed(0	)
   __UpperCamelCase  						=							UNetaDModel(
       block_out_channels=(32, 64)						, layers_per_block=2						, sample_size=32						, in_channels=3						, out_channels=3						, down_block_types=("DownBlock2D", "AttnDownBlock2D")						, up_block_types=("AttnUpBlock2D", "UpBlock2D")						, )
   return model





 def  A  (				self					: Any	)->	Optional[Any]:
   __UpperCamelCase  						=							self.dummy_uncond_unet
   __UpperCamelCase  						=							PNDMScheduler()

   __UpperCamelCase  						=							PNDMPipeline(unet=UpperCAmelCase_						, scheduler=UpperCAmelCase_	)
   pndm.to(UpperCAmelCase_	)
   pndm.set_progress_bar_config(disable=UpperCAmelCase_	)

   __UpperCamelCase  						=							torch.manual_seed(0	)
   __UpperCamelCase  						=							pndm(generator=UpperCAmelCase_						, num_inference_steps=20						, output_type="numpy"	).images

   __UpperCamelCase  						=							torch.manual_seed(0	)
   __UpperCamelCase  						=							pndm(generator=UpperCAmelCase_						, num_inference_steps=20						, output_type="numpy"						, return_dict=UpperCAmelCase_	)[0]

   __UpperCamelCase  						=							image[0, -3:, -3:, -1]
   __UpperCamelCase  						=							image_from_tuple[0, -3:, -3:, -1]

   assert image.shape == (1, 32, 32, 3)
   __UpperCamelCase  						=							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 		__UpperCAmelCase				(	unittest.TestCase					):







 """simple docstring"""




 def  A  (				self					: Tuple	)->	Optional[int]:
   __UpperCamelCase  						=							"google/ddpm-cifar10-32"

   __UpperCamelCase  						=							UNetaDModel.from_pretrained(UpperCAmelCase_	)
   __UpperCamelCase  						=							PNDMScheduler()

   __UpperCamelCase  						=							PNDMPipeline(unet=UpperCAmelCase_						, scheduler=UpperCAmelCase_	)
   pndm.to(UpperCAmelCase_	)
   pndm.set_progress_bar_config(disable=UpperCAmelCase_	)
   __UpperCamelCase  						=							torch.manual_seed(0	)
   __UpperCamelCase  						=							pndm(generator=UpperCAmelCase_						, output_type="numpy"	).images

   __UpperCamelCase  						=							image[0, -3:, -3:, -1]

   assert image.shape == (1, 32, 32, 3)
   __UpperCamelCase  						=							np.array([0.1_564, 0.14_645, 0.1_406, 0.14_715, 0.12_425, 0.14_045, 0.13_115, 0.12_175, 0.125]	)

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




'''simple docstring'''





def 							lowerCamelCase	(					_snake_case	:    int = 50_000_000							):





    '''simple docstring'''


    lowercase__									=    set()
    lowercase__									=    int((limit - 24) ** (1 / 2)							)

    lowercase__									=    set(range(3  ,prime_square_limit + 1  ,2							)							)
    primes.add(2							)
    for p in range(3  ,prime_square_limit + 1  ,2							):
        if p not in primes:
            continue
        primes.difference_update(set(range(p * p  ,prime_square_limit + 1  ,_snake_case							)							)							)

    for primea in primes:
        lowercase__									=    primea * primea
        for primea in primes:
            lowercase__									=    primea * primea * primea
            if square + cube >= limit - 16:
                break
            for primea in primes:
                lowercase__									=    primea * primea * primea * primea
                lowercase__									=    square + cube + tetr
                if total >= limit:
                    break
                ret.add(_snake_case							)

    return len(_snake_case							)


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




