


"""simple docstring"""






_lowerCamelCase  =	(1, 153, 370, 371, 1634, 24678051, 115132219018763992565095597973971522401)
_lowerCamelCase  =	(-153, -1, 0, 1.2, 200, "A", [], {}, None)


def __lowercase  (   lowerCamelCase_	:   int	):
				if not isinstance(lowerCamelCase_    ,       lowerCamelCase_	) or n < 1:
								return False

				# Initialization of sum and number of digits.
				SCREAMING_SNAKE_CASE__  				=					0
				SCREAMING_SNAKE_CASE__  				=					0
				SCREAMING_SNAKE_CASE__  				=					n
				# Calculation of digits of the number
				while temp > 0:
								number_of_digits += 1
								temp //= 10
				# Dividing number into separate digits and find Armstrong number
				SCREAMING_SNAKE_CASE__  				=					n
				while temp > 0:
								SCREAMING_SNAKE_CASE__  				=					temp % 10
								total += rem**number_of_digits
								temp //= 10
				return n == total


def __lowercase  (   lowerCamelCase_	:   int	):
				if not isinstance(lowerCamelCase_    ,       lowerCamelCase_	) or n < 1:
								return False

				# Init a "histogram" of the digits
				SCREAMING_SNAKE_CASE__  				=					[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
				SCREAMING_SNAKE_CASE__  				=					0
				SCREAMING_SNAKE_CASE__  				=					0
				SCREAMING_SNAKE_CASE__  				=					n
				while temp > 0:
								SCREAMING_SNAKE_CASE__				,   SCREAMING_SNAKE_CASE__  				=					divmod(lowerCamelCase_    ,       10	)
								digit_histogram[rem] += 1
								digit_total += 1

				for cnt, i in zip(lowerCamelCase_    ,       range(len(lowerCamelCase_	)	)	):
								total += cnt * i**digit_total

				return n == total


def __lowercase  (   lowerCamelCase_	:   int	):
				if not isinstance(lowerCamelCase_    ,       lowerCamelCase_	) or n < 1:
								return False
				SCREAMING_SNAKE_CASE__  				=					len(str(lowerCamelCase_	)	)  # the power that all digits will be raised to
				# check if sum of each digit multiplied expo times is equal to number
				return n == sum(int(lowerCamelCase_	) ** expo for i in str(lowerCamelCase_	)	)


def __lowercase  (   ):
				SCREAMING_SNAKE_CASE__  				=					int(input("Enter an integer to see if it is an Armstrong number: "	).strip()	)
				print(F'''{num} is {"" if armstrong_number(lowerCamelCase_	) else "not "}an Armstrong number.'''	)
				print(F'''{num} is {"" if narcissistic_number(lowerCamelCase_	) else "not "}an Armstrong number.'''	)
				print(F'''{num} is {"" if pluperfect_number(lowerCamelCase_	) else "not "}an Armstrong number.'''	)


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	main()




"""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


_lowerCamelCase  =	False


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





				"""simple docstring"""







				def 	lowerCAmelCase__		(    self  ):
								# clean up the VRAM after each test
								super().tearDown()
								gc.collect()
								torch.cuda.empty_cache()



				def 	lowerCAmelCase__		(    self  ):
								SCREAMING_SNAKE_CASE__  				=					VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"  )
								# remove text_unet
								pipe.remove_unused_weights()
								pipe.to(UpperCAmelCase__  )
								pipe.set_progress_bar_config(disable=UpperCAmelCase__  )

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

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

								with tempfile.TemporaryDirectory() as tmpdirname:
												pipe.save_pretrained(UpperCAmelCase__  )
												SCREAMING_SNAKE_CASE__  				=					VersatileDiffusionDualGuidedPipeline.from_pretrained(UpperCAmelCase__  )

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

								SCREAMING_SNAKE_CASE__  				=					generator.manual_seed(0  )
								SCREAMING_SNAKE_CASE__  				=					pipe(
								    prompt="first prompt"							,		image=UpperCAmelCase__							,		text_to_image_strength=0.75							,		generator=UpperCAmelCase__							,		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 	lowerCAmelCase__		(    self  ):
								SCREAMING_SNAKE_CASE__  				=					VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"  )
								pipe.remove_unused_weights()
								pipe.to(UpperCAmelCase__  )
								pipe.set_progress_bar_config(disable=UpperCAmelCase__  )

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

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

								assert image.shape == (1, 512, 512, 3)
								SCREAMING_SNAKE_CASE__  				=					np.array([0.0_787, 0.0_849, 0.0_826, 0.0_812, 0.0_807, 0.0_795, 0.0_818, 0.0_798, 0.0_779]  )

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