





"""simple docstring"""


import gc
import unittest

from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline
from diffusers.utils import is_flax_available, slow
from diffusers.utils.testing_utils import require_flax


if is_flax_available():
		import jax
		import jax.numpy as jnp
		from flax.jax_utils import replicate
		from flax.training.common_utils import shard






@slow
@require_flax
class 							lowercase__			(   unittest.TestCase	):

			"""simple docstring"""







			def   _a      (      self    ):






									'''simple docstring'''







									super().tearDown()
									gc.collect()







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase   ,						UpperCamelCase				:		Optional[Any]				   =			FlaxStableDiffusionPipeline.from_pretrained(
									    """stabilityai/stable-diffusion-2"""						,   revision="""bf16"""						,   dtype=jnp.bfloataa						,   )

									UpperCamelCase				:		Union[str, Any]				   =			"""A painting of a squirrel eating a burger"""
									UpperCamelCase				:		Dict				   =			jax.device_count()
									UpperCamelCase				:		Tuple				   =			num_samples * [prompt]
									UpperCamelCase				:		Optional[Any]				   =			sd_pipe.prepare_inputs(_snake_case    )

									UpperCamelCase				:		str				   =			replicate(_snake_case    )
									UpperCamelCase				:		str				   =			shard(_snake_case    )

									UpperCamelCase				:		Dict				   =			jax.random.PRNGKey(0    )
									UpperCamelCase				:		List[str]				   =			jax.random.split(_snake_case						,   jax.device_count()    )

									UpperCamelCase				:		Tuple				   =			sd_pipe(_snake_case						,   _snake_case						,   _snake_case						,   num_inference_steps=2_5						,   jit=_snake_case    )[0]
									assert images.shape == (jax.device_count(), 1, 7_6_8, 7_6_8, 3)

									UpperCamelCase				:		Optional[Any]				   =			images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]    )
									UpperCamelCase				:		int				   =			images[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

									UpperCamelCase				:		Tuple				   =			jnp.asarray(jax.device_get(image_slice.flatten()    )    )
									UpperCamelCase				:		Optional[Any]				   =			jnp.array([0.42_38, 0.44_14, 0.43_95, 0.44_53, 0.46_29, 0.45_90, 0.45_31, 0.4_55_08, 0.45_12]    )
									print(f"""output_slice: {output_slice}"""    )
									assert jnp.abs(output_slice - expected_slice    ).max() < 1e-2







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Dict				   =			"""stabilityai/stable-diffusion-2"""
									UpperCamelCase   ,						UpperCamelCase				:		str				   =			FlaxDPMSolverMultistepScheduler.from_pretrained(_snake_case						,   subfolder="""scheduler"""    )
									UpperCamelCase   ,						UpperCamelCase				:		Any				   =			FlaxStableDiffusionPipeline.from_pretrained(
									    _snake_case						,   scheduler=_snake_case						,   revision="""bf16"""						,   dtype=jnp.bfloataa						,   )
									UpperCamelCase				:		Tuple				   =			scheduler_params

									UpperCamelCase				:		Any				   =			"""A painting of a squirrel eating a burger"""
									UpperCamelCase				:		str				   =			jax.device_count()
									UpperCamelCase				:		str				   =			num_samples * [prompt]
									UpperCamelCase				:		int				   =			sd_pipe.prepare_inputs(_snake_case    )

									UpperCamelCase				:		List[Any]				   =			replicate(_snake_case    )
									UpperCamelCase				:		Optional[int]				   =			shard(_snake_case    )

									UpperCamelCase				:		Dict				   =			jax.random.PRNGKey(0    )
									UpperCamelCase				:		Any				   =			jax.random.split(_snake_case						,   jax.device_count()    )

									UpperCamelCase				:		Dict				   =			sd_pipe(_snake_case						,   _snake_case						,   _snake_case						,   num_inference_steps=2_5						,   jit=_snake_case    )[0]
									assert images.shape == (jax.device_count(), 1, 7_6_8, 7_6_8, 3)

									UpperCamelCase				:		Union[str, Any]				   =			images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]    )
									UpperCamelCase				:		Dict				   =			images[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

									UpperCamelCase				:		Optional[int]				   =			jnp.asarray(jax.device_get(image_slice.flatten()    )    )
									UpperCamelCase				:		Optional[int]				   =			jnp.array([0.43_36, 0.4_29_69, 0.44_53, 0.41_99, 0.42_97, 0.45_31, 0.44_34, 0.44_34, 0.42_97]    )
									print(f"""output_slice: {output_slice}"""    )
									assert jnp.abs(output_slice - expected_slice    ).max() < 1e-2








from __future__ import annotations

from fractions import Fraction


def A    (							__UpperCamelCase			,						__UpperCamelCase       )    ->   bool:
			return (
			    num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
			)


def A    (							__UpperCamelCase       )    ->   list[str]:
			A__	  =     []
			A__	  =     11
			A__	  =     int('1' + '0' * digit_len       )
			for num in range(__UpperCamelCase			,						__UpperCamelCase       ):
						while den <= 99:
									if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
												if is_digit_cancelling(__UpperCamelCase			,						__UpperCamelCase       ):
															solutions.append(f'''{num}/{den}'''       )
									den += 1
						num += 1
						A__	  =     10
			return solutions


def A    (							__UpperCamelCase = 2       )    ->   int:
			A__	  =     1.0
			for fraction in fraction_list(__UpperCamelCase       ):
						A__	  =     Fraction(__UpperCamelCase       )
						result *= frac.denominator / frac.numerator
			return int(__UpperCamelCase       )


if __name__ == "__main__":
							print(solution())




