'''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       snake_case						(				self:     Dict						):
    # clean up the VRAM after each test
    super().tearDown()
    gc.collect()





   def       snake_case						(				self:     Union[str, Any]						):
    __UpperCAmelCase								=       FlaxStableDiffusionPipeline.from_pretrained(
        'stabilityai/stable-diffusion-2'      ,revision='bf16'      ,dtype=jnp.bfloataa      ,)

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

    __UpperCAmelCase								=       replicate(__lowerCAmelCase						)
    __UpperCAmelCase								=       shard(__lowerCAmelCase						)

    __UpperCAmelCase								=       jax.random.PRNGKey(0						)
    __UpperCAmelCase								=       jax.random.split(__lowerCAmelCase      ,jax.device_count()						)

    __UpperCAmelCase								=       sd_pipe(__lowerCAmelCase      ,__lowerCAmelCase      ,__lowerCAmelCase      ,num_inference_steps=25      ,jit=__lowerCAmelCase						)[0]
    assert images.shape == (jax.device_count(), 1, 768, 768, 3)

    __UpperCAmelCase								=       images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]						)
    __UpperCAmelCase								=       images[0, 253:256, 253:256, -1]

    __UpperCAmelCase								=       jnp.asarray(jax.device_get(image_slice.flatten()						)						)
    __UpperCAmelCase								=       jnp.array([0.4238, 0.4414, 0.4395, 0.4453, 0.4629, 0.4590, 0.4531, 0.45508, 0.4512]						)
    print(f"""output_slice: {output_slice}"""						)
    assert jnp.abs(output_slice - expected_slice						).max() < 1e-2





   def       snake_case						(				self:     Any						):
    __UpperCAmelCase								=       """stabilityai/stable-diffusion-2"""
    __UpperCAmelCase								=       FlaxDPMSolverMultistepScheduler.from_pretrained(__lowerCAmelCase      ,subfolder='scheduler'						)
    __UpperCAmelCase								=       FlaxStableDiffusionPipeline.from_pretrained(
        __lowerCAmelCase      ,scheduler=__lowerCAmelCase      ,revision='bf16'      ,dtype=jnp.bfloataa      ,)
    __UpperCAmelCase								=       scheduler_params

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

    __UpperCAmelCase								=       replicate(__lowerCAmelCase						)
    __UpperCAmelCase								=       shard(__lowerCAmelCase						)

    __UpperCAmelCase								=       jax.random.PRNGKey(0						)
    __UpperCAmelCase								=       jax.random.split(__lowerCAmelCase      ,jax.device_count()						)

    __UpperCAmelCase								=       sd_pipe(__lowerCAmelCase      ,__lowerCAmelCase      ,__lowerCAmelCase      ,num_inference_steps=25      ,jit=__lowerCAmelCase						)[0]
    assert images.shape == (jax.device_count(), 1, 768, 768, 3)

    __UpperCAmelCase								=       images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]						)
    __UpperCAmelCase								=       images[0, 253:256, 253:256, -1]

    __UpperCAmelCase								=       jnp.asarray(jax.device_get(image_slice.flatten()						)						)
    __UpperCAmelCase								=       jnp.array([0.4336, 0.42969, 0.4453, 0.4199, 0.4297, 0.4531, 0.4434, 0.4434, 0.4297]						)
    print(f"""output_slice: {output_slice}"""						)
    assert jnp.abs(output_slice - expected_slice						).max() < 1e-2











'''simple docstring'''

from __future__ import annotations

from math import pi, sqrt



def 				snake_case       (  a_				:			float     , a_				:			float						)							->					tuple:





      """simple docstring"""

      if inductance <= 0:
            raise ValueError("""Inductance cannot be 0 or negative"""						)

      elif capacitance <= 0:
            raise ValueError("""Capacitance cannot be 0 or negative"""						)

      else:
            return (
                "Resonant frequency",
                float(1 / (2 * pi * (sqrt(inductance * capacitance						)))						),
            )


if __name__ == "__main__":
      import doctest

      doctest.testmod()






