



'''simple docstring'''



import unittest

import numpy as np
import torch

from diffusers import KarrasVePipeline, KarrasVeScheduler, 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 				__lowerCamelCase     (							self  :  Dict):







											'''simple docstring'''

											torch.manual_seed(0)
											__lowercase       	=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 				__lowerCamelCase     (							self  :  str):







											'''simple docstring'''

											__lowercase       	=self.dummy_uncond_unet
											__lowercase       	=KarrasVeScheduler()

											__lowercase       	=KarrasVePipeline(unet=_lowerCAmelCase  ,       scheduler=_lowerCAmelCase)
											pipe.to(_lowerCAmelCase)
											pipe.set_progress_bar_config(disable=_lowerCAmelCase)

											__lowercase       	=torch.manual_seed(0)
											__lowercase       	=pipe(num_inference_steps=2  ,       generator=_lowerCAmelCase  ,       output_type='numpy').images

											__lowercase       	=torch.manual_seed(0)
											__lowercase       	=pipe(num_inference_steps=2  ,       generator=_lowerCAmelCase  ,       output_type='numpy'  ,       return_dict=_lowerCAmelCase)[0]

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

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





				'''simple docstring'''





				def 				__lowerCamelCase     (							self  :  List[Any]):







											'''simple docstring'''

											__lowercase       	='google/ncsnpp-celebahq-256'
											__lowercase       	=UNetaDModel.from_pretrained(_lowerCAmelCase)
											__lowercase       	=KarrasVeScheduler()

											__lowercase       	=KarrasVePipeline(unet=_lowerCAmelCase  ,       scheduler=_lowerCAmelCase)
											pipe.to(_lowerCAmelCase)
											pipe.set_progress_bar_config(disable=_lowerCAmelCase)

											__lowercase       	=torch.manual_seed(0)
											__lowercase       	=pipe(num_inference_steps=2_0  ,       generator=_lowerCAmelCase  ,       output_type='numpy').images

											__lowercase       	=image[0, -3:, -3:, -1]
											assert image.shape == (1, 2_5_6, 2_5_6, 3)
											__lowercase       	=np.array([0.578, 0.5811, 0.5924, 0.5809, 0.587, 0.5886, 0.5861, 0.5802, 0.586])

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








'''simple docstring'''



from functools import lru_cache



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							__lowercase       	=2
							__lowercase       	=set()
							while i * i <= n:
														if n % i:
																					i += 1
														else:
																					n //= i
																					factors.add(_lowerCAmelCase					)
							if n > 1:
														factors.add(_lowerCAmelCase					)
							return factors



@lru_cache
def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							return len(unique_prime_factors(_lowerCAmelCase					)					)



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							return len(set(_lowerCAmelCase					)					) in (0, 1)



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							__lowercase       	=2

							while True:
														# Increment each value of a generated range
														__lowercase       	=[base + i for i in range(_lowerCAmelCase					)]

														# Run elements through out unique_prime_factors function
														# Append our target number to the end.
														__lowercase       	=[upf_len(_lowerCAmelCase					) for x in group]
														checker.append(_lowerCAmelCase					)

														# If all numbers in the list are equal, return the group variable.
														if equality(_lowerCAmelCase					):
																					return group

														# Increment our base variable by 1
														base += 1



def   _A       (   _lowerCAmelCase = 4					):



							"""simple docstring"""



							__lowercase       	=run(_lowerCAmelCase					)
							return results[0] if len(_lowerCAmelCase					) else None


if __name__ == "__main__":
		print(solution())



