


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





      @property
      def 							_lowercase					(		self    :       Dict							)     -> Tuple:






         """simple docstring"""







         torch.manual_seed(0							)
         UpperCAmelCase      					=  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 							_lowercase					(		self    :       List[str]							)     -> str:






         """simple docstring"""







         UpperCAmelCase      					=  self.dummy_uncond_unet
         UpperCAmelCase      					=  KarrasVeScheduler()

         UpperCAmelCase      					=  KarrasVePipeline(unet=__lowerCamelCase       ,							scheduler=__lowerCamelCase							)
         pipe.to(__lowerCamelCase							)
         pipe.set_progress_bar_config(disable=__lowerCamelCase							)

         UpperCAmelCase      					=  torch.manual_seed(0							)
         UpperCAmelCase      					=  pipe(num_inference_steps=2       ,							generator=__lowerCamelCase       ,							output_type="""numpy"""							).images

         UpperCAmelCase      					=  torch.manual_seed(0							)
         UpperCAmelCase      					=  pipe(num_inference_steps=2       ,							generator=__lowerCamelCase       ,							output_type="""numpy"""       ,							return_dict=__lowerCamelCase							)[0]

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

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





      def 							_lowercase					(		self    :       List[Any]							)     -> int:






         """simple docstring"""







         UpperCAmelCase      					=  """google/ncsnpp-celebahq-256"""
         UpperCAmelCase      					=  UNetaDModel.from_pretrained(__lowerCamelCase							)
         UpperCAmelCase      					=  KarrasVeScheduler()

         UpperCAmelCase      					=  KarrasVePipeline(unet=__lowerCamelCase       ,							scheduler=__lowerCamelCase							)
         pipe.to(__lowerCamelCase							)
         pipe.set_progress_bar_config(disable=__lowerCamelCase							)

         UpperCAmelCase      					=  torch.manual_seed(0							)
         UpperCAmelCase      					=  pipe(num_inference_steps=2_0       ,							generator=__lowerCamelCase       ,							output_type="""numpy"""							).images

         UpperCAmelCase      					=  image[0, -3:, -3:, -1]
         assert image.shape == (1, 2_5_6, 2_5_6, 3)
         UpperCAmelCase      					=  np.array([0.578, 0.5_811, 0.5_924, 0.5_809, 0.587, 0.5_886, 0.5_861, 0.5_802, 0.586]							)

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







from __future__ import annotations

import math
def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->bool:

   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5	,    int(math.sqrt(lowerCAmelCase_ ) + 1 )	,    6 ):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True


__a	 =      [num for num in range(3, 10_0001, 2) if not is_prime(num)]
def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->list[int]:
   if not isinstance(lowerCAmelCase_	,    lowerCAmelCase_ ):
      raise ValueError("""n must be an integer""" )
   if n <= 0:
      raise ValueError("""n must be >= 0""" )

   UpperCAmelCase      					=  []
   for num in range(len(lowerCAmelCase_ ) ):
      UpperCAmelCase      					=  0
      while 2 * i * i <= odd_composites[num]:
         UpperCAmelCase      					=  odd_composites[num] - 2 * i * i
         if is_prime(lowerCAmelCase_ ):
            break
         i += 1
      else:
         list_nums.append(odd_composites[num] )
         if len(lowerCAmelCase_ ) == n:
            return list_nums

   return []
def 	_UpperCamelCase					(    )    ->int:
   return compute_nums(1 )[0]


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



