
"""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  snake_case     (							unittest.TestCase   ):

							def _lowercase					(self    ):

									"""simple docstring"""







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

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_						 = FlaxStableDiffusionPipeline.from_pretrained(
									    '''stabilityai/stable-diffusion-2'''       ,       revision='''bf16'''       ,       dtype=jnp.bfloataa       ,       )

									SCREAMING_SNAKE_CASE_						 = '''A painting of a squirrel eating a burger'''
									SCREAMING_SNAKE_CASE_						 = jax.device_count()
									SCREAMING_SNAKE_CASE_						 = num_samples * [prompt]
									SCREAMING_SNAKE_CASE_						 = sd_pipe.prepare_inputs(SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = replicate(SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = shard(SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = jax.random.PRNGKey(0    )
									SCREAMING_SNAKE_CASE_						 = jax.random.split(SCREAMING_SNAKE_CASE_       ,       jax.device_count()    )

									SCREAMING_SNAKE_CASE_						 = sd_pipe(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_inference_steps=25       ,       jit=SCREAMING_SNAKE_CASE_    )[0]
									assert images.shape == (jax.device_count(), 1, 7_68, 7_68, 3)

									SCREAMING_SNAKE_CASE_						 = images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]    )
									SCREAMING_SNAKE_CASE_						 = images[0, 2_53:2_56, 2_53:2_56, -1]

									SCREAMING_SNAKE_CASE_						 = jnp.asarray(jax.device_get(image_slice.flatten()    )    )
									SCREAMING_SNAKE_CASE_						 = 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 _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = '''stabilityai/stable-diffusion-2'''
									SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_						 = FlaxDPMSolverMultistepScheduler.from_pretrained(SCREAMING_SNAKE_CASE_       ,       subfolder='''scheduler'''    )
									SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_						 = FlaxStableDiffusionPipeline.from_pretrained(
									    SCREAMING_SNAKE_CASE_       ,       scheduler=SCREAMING_SNAKE_CASE_       ,       revision='''bf16'''       ,       dtype=jnp.bfloataa       ,       )
									SCREAMING_SNAKE_CASE_						 = scheduler_params

									SCREAMING_SNAKE_CASE_						 = '''A painting of a squirrel eating a burger'''
									SCREAMING_SNAKE_CASE_						 = jax.device_count()
									SCREAMING_SNAKE_CASE_						 = num_samples * [prompt]
									SCREAMING_SNAKE_CASE_						 = sd_pipe.prepare_inputs(SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = replicate(SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = shard(SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = jax.random.PRNGKey(0    )
									SCREAMING_SNAKE_CASE_						 = jax.random.split(SCREAMING_SNAKE_CASE_       ,       jax.device_count()    )

									SCREAMING_SNAKE_CASE_						 = sd_pipe(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       num_inference_steps=25       ,       jit=SCREAMING_SNAKE_CASE_    )[0]
									assert images.shape == (jax.device_count(), 1, 7_68, 7_68, 3)

									SCREAMING_SNAKE_CASE_						 = images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]    )
									SCREAMING_SNAKE_CASE_						 = images[0, 2_53:2_56, 2_53:2_56, -1]

									SCREAMING_SNAKE_CASE_						 = jnp.asarray(jax.device_get(image_slice.flatten()    )    )
									SCREAMING_SNAKE_CASE_						 = 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

"""simple docstring"""




from __future__ import annotations



def        _lowerCamelCase ( __a,							__a    ):
		SCREAMING_SNAKE_CASE_						 = 0
		SCREAMING_SNAKE_CASE_						 = len(__a    ) - 1

		while i < j:
				if nums[i] + nums[j] == target:
						return [i, j]
				elif nums[i] + nums[j] < target:
						SCREAMING_SNAKE_CASE_						 = i + 1
				else:
						SCREAMING_SNAKE_CASE_						 = j - 1

		return []


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(f'''{two_pointer([2, 7, 11, 15], 9) = }''')