





"""simple docstring"""


import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionDualGuidedPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


a__					:     Optional[int]							=				False



@nightly
@require_torch_gpu
class      lowercase_				(     unittest.TestCase							):

       def 		_SCREAMING_SNAKE_CASE(			self     ):






        '''simple docstring'''

        super().tearDown()
        gc.collect()
        torch.cuda.empty_cache()

       def 		_SCREAMING_SNAKE_CASE(			self     ):






        '''simple docstring'''

        snake_case__    							=				VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"     )
        # remove text_unet
        pipe.remove_unused_weights()
        pipe.to(__SCREAMING_SNAKE_CASE     )
        pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE     )

        snake_case__    							=				load_image(
            "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"     )

        snake_case__    							=				torch.manual_seed(0     )
        snake_case__    							=				pipe(
            prompt="first prompt"   ,					image=__SCREAMING_SNAKE_CASE   ,					text_to_image_strength=0.75   ,					generator=__SCREAMING_SNAKE_CASE   ,					guidance_scale=7.5   ,					num_inference_steps=2   ,					output_type="numpy"   ,					).images

        with tempfile.TemporaryDirectory() as tmpdirname:
         pipe.save_pretrained(__SCREAMING_SNAKE_CASE     )
         snake_case__    							=				VersatileDiffusionDualGuidedPipeline.from_pretrained(__SCREAMING_SNAKE_CASE     )

        pipe.to(__SCREAMING_SNAKE_CASE     )
        pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE     )

        snake_case__    							=				generator.manual_seed(0     )
        snake_case__    							=				pipe(
            prompt="first prompt"   ,					image=__SCREAMING_SNAKE_CASE   ,					text_to_image_strength=0.75   ,					generator=__SCREAMING_SNAKE_CASE   ,					guidance_scale=7.5   ,					num_inference_steps=2   ,					output_type="numpy"   ,					).images

        assert np.abs(image - new_image     ).sum() < 1e-5, "Models don't have the same forward pass"

       def 		_SCREAMING_SNAKE_CASE(			self     ):






        '''simple docstring'''

        snake_case__    							=				VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"     )
        pipe.remove_unused_weights()
        pipe.to(__SCREAMING_SNAKE_CASE     )
        pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE     )

        snake_case__    							=				"cyberpunk 2077"
        snake_case__    							=				load_image(
            "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"     )
        snake_case__    							=				torch.manual_seed(0     )
        snake_case__    							=				pipe(
            prompt=__SCREAMING_SNAKE_CASE   ,					image=__SCREAMING_SNAKE_CASE   ,					text_to_image_strength=0.75   ,					generator=__SCREAMING_SNAKE_CASE   ,					guidance_scale=7.5   ,					num_inference_steps=50   ,					output_type="numpy"   ,					).images

        snake_case__    							=				image[0, 253:256, 253:256, -1]

        assert image.shape == (1, 512, 512, 3)
        snake_case__    							=				np.array([0.0787, 0.0849, 0.0826, 0.0812, 0.0807, 0.0795, 0.0818, 0.0798, 0.0779]     )

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








"""simple docstring"""


from math import sqrt





def 							a__			(  _UpperCAmelCase	)    ->  list[int]:

 '''simple docstring'''






 snake_case__    							=				[1]
 for i in range(2	,     int(sqrt(_UpperCAmelCase	)	) + 1	,     1	):
  if number % i == 0:
   values.append(_UpperCAmelCase	)
   if int(number // i	) != i:
    values.append(int(number // i	)	)
 return sorted(_UpperCAmelCase	)





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return sum(factors(_UpperCAmelCase	)	) > n





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 snake_case__    							=				factors(_UpperCAmelCase	)
 snake_case__    							=				len(_UpperCAmelCase	)
 snake_case__    							=				[[0 for i in range(number + 1	)] for j in range(r + 1	)]
 for i in range(r + 1	):
  snake_case__    							=				True

 for i in range(1	,     number + 1	):
  snake_case__    							=				False

 for i in range(1	,     r + 1	):
  for j in range(1	,     number + 1	):
   if j < values[i - 1]:
    snake_case__    							=				subset[i - 1][j]
   else:
    snake_case__    							=				subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

 return subset[r][number] != 0





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return abundant(_UpperCAmelCase	) and not semi_perfect(_UpperCAmelCase	)


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)
   for number in (6_9, 7_0, 7_1):
      print(f'''{number} is {'' if weird(number) else 'not '}weird.''')

