



import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin

@skip_mps
class 			__snake_case   ( SCREAMING_SNAKE_CASE      ,SCREAMING_SNAKE_CASE      ,unittest.TestCase):







							'''simple docstring'''






							UpperCamelCase__					:   int       =       IFImgaImgPipeline
							UpperCamelCase__					:   Optional[int]       =       TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""width""", """height"""}
							UpperCamelCase__					:   int       =       TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
							UpperCamelCase__					:   Tuple       =       PipelineTesterMixin.required_optional_params - {"""latents"""}


							def _a   (				self		):
											return self._get_dummy_components()


							def _a   (				self	,	a_	,	a_=0		):
											if str(a_		).startswith("""mps"""		):
															a__					   =		torch.manual_seed(a_		)
											else:
															a__					   =		torch.Generator(device=a_		).manual_seed(a_		)

											a__					   =		floats_tensor((1, 3, 32, 32)	,	rng=random.Random(a_		)		).to(a_		)

											a__					   =		{
											    """prompt""": """A painting of a squirrel eating a burger""",
											    """image""": image,
											    """generator""": generator,
											    """num_inference_steps""": 2,
											    """output_type""": """numpy""",
											}

											return inputs


							def _a   (				self		):
											self._test_save_load_optional_components()


							@unittest.skipIf(
							    torch_device != """cuda""" or not is_xformers_available()	,	reason="""XFormers attention is only available with CUDA and `xformers` installed"""	,	)
							def _a   (				self		):
											self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3		)


							@unittest.skipIf(torch_device != """cuda"""	,	reason="""float16 requires CUDA"""		)
							def _a   (				self		):
											# Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
											super().test_save_load_floataa(expected_max_diff=1E-1		)


							@unittest.skipIf(torch_device != """cuda"""	,	reason="""float16 requires CUDA"""		)
							def _a   (				self		):
											super().test_floataa_inference(expected_max_diff=1E-1		)


							def _a   (				self		):
											self._test_attention_slicing_forward_pass(expected_max_diff=1E-2		)


							def _a   (				self		):
											self._test_save_load_local()







							def _a   (				self		):
											self._test_inference_batch_single_identical(
											    expected_max_diff=1E-2	,	)






UpperCAmelCase							=       (1, 153, 370, 371, 1_634, 24_678_051, 115_132_219_018_763_992_565_095_597_973_971_522_401)
UpperCAmelCase							=       (-153, -1, 0, 1.2, 200, "A", [], {}, None)

def       A_   (						__a  :					int		):

				"""simple docstring"""
				if not isinstance(__a			,		__a		) or n < 1:
								return False

				# Initialization of sum and number of digits.
				a__					   =		0
				a__					   =		0
				a__					   =		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
				a__					   =		n
				while temp > 0:
								a__					   =		temp % 10
								total += rem**number_of_digits
								temp //= 10
				return n == total

def       A_   (						__a  :					int		):

				"""simple docstring"""
				if not isinstance(__a			,		__a		) or n < 1:
								return False

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

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

				return n == total

def       A_   (						__a  :					int		):

				"""simple docstring"""
				if not isinstance(__a			,		__a		) or n < 1:
								return False
				a__					   =		len(str(__a		)		)  # 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(__a		) ** expo for i in str(__a		)		)

def       A_   (						):

				"""simple docstring"""
				a__					   =		int(input("""Enter an integer to see if it is an Armstrong number: """		).strip()		)
				print(F'''{num} is {"" if armstrong_number(__a		) else "not "}an Armstrong number.'''		)
				print(F'''{num} is {"" if narcissistic_number(__a		) else "not "}an Armstrong number.'''		)
				print(F'''{num} is {"" if pluperfect_number(__a		) else "not "}an Armstrong number.'''		)


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	main()

