

import unittest

import numpy as np
import torch

from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()





class 					__lowerCAmelCase	(   unittest.TestCase				):




  @property
  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        torch.manual_seed(0   )
        _lowercase      			=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   )    ->					Union[str, Any]:
        '''simple docstring'''






        _lowercase      			=self.dummy_uncond_unet
        _lowercase      			=ScoreSdeVeScheduler()

        _lowercase      			=ScoreSdeVePipeline(unet=lowerCAmelCase				,  scheduler=lowerCAmelCase   )
        sde_ve.to(lowerCAmelCase   )
        sde_ve.set_progress_bar_config(disable=lowerCAmelCase   )

        _lowercase      			=torch.manual_seed(0   )
        _lowercase      			=sde_ve(num_inference_steps=2				,  output_type='numpy'				,  generator=lowerCAmelCase   ).images

        _lowercase      			=torch.manual_seed(0   )
        _lowercase      			=sde_ve(num_inference_steps=2				,  output_type='numpy'				,  generator=lowerCAmelCase				,  return_dict=lowerCAmelCase   )[
            0
        ]

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

        assert image.shape == (1, 32, 32, 3)
        _lowercase      			=np.array([0.0, 1.0, 0.0, 0.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     A__	(							self   )    ->					List[Any]:
        '''simple docstring'''






        _lowercase      			='google/ncsnpp-church-256'
        _lowercase      			=UNetaDModel.from_pretrained(lowerCAmelCase   )

        _lowercase      			=ScoreSdeVeScheduler.from_pretrained(lowerCAmelCase   )

        _lowercase      			=ScoreSdeVePipeline(unet=lowerCAmelCase				,  scheduler=lowerCAmelCase   )
        sde_ve.to(lowerCAmelCase   )
        sde_ve.set_progress_bar_config(disable=lowerCAmelCase   )

        _lowercase      			=torch.manual_seed(0   )
        _lowercase      			=sde_ve(num_inference_steps=10				,  output_type='numpy'				,  generator=lowerCAmelCase   ).images

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

        assert image.shape == (1, 256, 256, 3)

        _lowercase      			=np.array([0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0]   )

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





def 	a (     A__      :  int	)       -> bool:





      """simple docstring"""



      return sum(i for i in range(1 ,  number // 2 + 1	) if number % i == 0	) == number


if __name__ == "__main__":
  print('Program to check whether a number is a Perfect number or not...')
  lowercase_   							=  int(input('Enter number: ').strip())
  print(f"{number} is {'' if perfect(number) else 'not '}a Perfect Number.")


