






"""simple docstring"""





import gc
import unittest

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()






@slow
@require_torch_gpu
class      a						(					unittest.TestCase		):






    def    UpperCamelCase       (       self     :							Union[str, Any]					)     ->		str:
      # clean up the VRAM after each test
      super().tearDown()
      gc.collect()
      torch.cuda.empty_cache()






    def    UpperCamelCase       (       self     :							Optional[Any]					)     ->		Optional[Any]:
      lowerCamelCase_         =						StableDiffusionKDiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4'					)
      lowerCamelCase_         =						sd_pipe.to(__SCREAMING_SNAKE_CASE					)
      sd_pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE					)

      sd_pipe.set_scheduler('sample_euler'					)

      lowerCamelCase_         =						'A painting of a squirrel eating a burger'
      lowerCamelCase_         =						torch.manual_seed(0					)
      lowerCamelCase_         =						sd_pipe([prompt]       ,						generator=__SCREAMING_SNAKE_CASE       ,						guidance_scale=9.0       ,						num_inference_steps=20       ,						output_type='np'					)

      lowerCamelCase_         =						output.images

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

      assert image.shape == (1, 512, 512, 3)
      lowerCamelCase_         =						np.array([0.0_447, 0.0_492, 0.0_468, 0.0_408, 0.0_383, 0.0_408, 0.0_354, 0.0_380, 0.0_339]					)

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






    def    UpperCamelCase       (       self     :							Tuple					)     ->		Tuple:
      lowerCamelCase_         =						StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'					)
      lowerCamelCase_         =						sd_pipe.to(__SCREAMING_SNAKE_CASE					)
      sd_pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE					)

      sd_pipe.set_scheduler('sample_euler'					)

      lowerCamelCase_         =						'A painting of a squirrel eating a burger'
      lowerCamelCase_         =						torch.manual_seed(0					)
      lowerCamelCase_         =						sd_pipe([prompt]       ,						generator=__SCREAMING_SNAKE_CASE       ,						guidance_scale=9.0       ,						num_inference_steps=20       ,						output_type='np'					)

      lowerCamelCase_         =						output.images

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

      assert image.shape == (1, 512, 512, 3)
      lowerCamelCase_         =						np.array([0.1_237, 0.1_320, 0.1_438, 0.1_359, 0.1_390, 0.1_132, 0.1_277, 0.1_175, 0.1_112]					)

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






    def    UpperCamelCase       (       self     :							str					)     ->		int:
      lowerCamelCase_         =						StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'					)
      lowerCamelCase_         =						sd_pipe.to(__SCREAMING_SNAKE_CASE					)
      sd_pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE					)

      sd_pipe.set_scheduler('sample_dpmpp_2m'					)

      lowerCamelCase_         =						'A painting of a squirrel eating a burger'
      lowerCamelCase_         =						torch.manual_seed(0					)
      lowerCamelCase_         =						sd_pipe(
          [prompt]       ,						generator=__SCREAMING_SNAKE_CASE       ,						guidance_scale=7.5       ,						num_inference_steps=15       ,						output_type='np'       ,						use_karras_sigmas=__SCREAMING_SNAKE_CASE       ,						)

      lowerCamelCase_         =						output.images

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

      assert image.shape == (1, 512, 512, 3)
      lowerCamelCase_         =						np.array(
          [0.11_381_689, 0.12_112_921, 0.1_389_457, 0.12_549_606, 0.1_244_964, 0.10_831_517, 0.11_562_866, 0.10_867_816, 0.10_499_048]					)

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












"""simple docstring"""





from __future__ import annotations

import math







def      lowerCamelCase__       (							_lowerCamelCase       :		int )      ->				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







def      lowerCamelCase__       (							_lowerCamelCase       :		int )      ->				list[int]:
  lowerCamelCase_         =						str(_lowerCamelCase )
  lowerCamelCase_         =						[n]
  for i in range(1		,				len(_lowerCamelCase ) ):
    list_nums.append(int(str_num[i:] ) )
    list_nums.append(int(str_num[:-i] ) )
  return list_nums







def      lowerCamelCase__       (							_lowerCamelCase       :		int )      ->				bool:
  if len(str(_lowerCamelCase ) ) > 3:
    if not is_prime(int(str(_lowerCamelCase )[-3:] ) ) or not is_prime(int(str(_lowerCamelCase )[:3] ) ):
      return False
  return True







def      lowerCamelCase__       (							_lowerCamelCase       :		int = 11 )      ->				list[int]:
  lowerCamelCase_         =						[]
  lowerCamelCase_         =						13
  while len(_lowerCamelCase ) != count:
    if validate(_lowerCamelCase ):
      lowerCamelCase_         =						list_truncated_nums(_lowerCamelCase )
      if all(is_prime(_lowerCamelCase ) for i in list_nums ):
        list_truncated_primes.append(_lowerCamelCase )
    num += 2
  return list_truncated_primes







def      lowerCamelCase__       (							)      ->				int:
  return sum(compute_truncated_primes(11 ) )


if __name__ == "__main__":
  print(F'''{sum(compute_truncated_primes(11)) = }''')




