



"""simple docstring"""
from typing import Any, Dict, Optional

import torch
import torch.nn.functional as F
from torch import nn

from ..utils import maybe_allow_in_graph
from .activations import get_activation
from .attention_processor import Attention
from .embeddings import CombinedTimestepLabelEmbeddings
@maybe_allow_in_graph
class 					a	(  nn.Module       ):



  def __init__(						self :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					List[str]=0.0       ,		lowerCAmelCase :					Optional[int] = None       ,		lowerCAmelCase :					str = "geglu"       ,		lowerCAmelCase :					Optional[int] = None       ,		lowerCAmelCase :					bool = False       ,		lowerCAmelCase :					bool = False       ,		lowerCAmelCase :					bool = False       ,		lowerCAmelCase :					bool = False       ,		lowerCAmelCase :					bool = True       ,		lowerCAmelCase :					str = "layer_norm"       ,		lowerCAmelCase :					bool = False       ,		)     ->					Any:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=only_cross_attention

     SCREAMING_SNAKE_CASE_: str     			=(num_embeds_ada_norm is not None) and norm_type == """ada_norm_zero"""
     SCREAMING_SNAKE_CASE_: List[Any]     			=(num_embeds_ada_norm is not None) and norm_type == """ada_norm"""

     if norm_type in ("ada_norm", "ada_norm_zero") and num_embeds_ada_norm is None:
        raise ValueError(
            f'''`norm_type` is set to {norm_type}, but `num_embeds_ada_norm` is not defined. Please make sure to'''
            f''' define `num_embeds_ada_norm` if setting `norm_type` to {norm_type}.'''		)

     # Define 3 blocks. Each block has its own normalization layer.
     # 1. Self-Attn
     if self.use_ada_layer_norm:
        SCREAMING_SNAKE_CASE_: Optional[int]     			=AdaLayerNorm(lowerCAmelCase       ,		lowerCAmelCase		)
     elif self.use_ada_layer_norm_zero:
        SCREAMING_SNAKE_CASE_: Tuple     			=AdaLayerNormZero(lowerCAmelCase       ,		lowerCAmelCase		)
     else:
        SCREAMING_SNAKE_CASE_: str     			=nn.LayerNorm(lowerCAmelCase       ,		elementwise_affine=lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: str     			=Attention(
         query_dim=lowerCAmelCase       ,		heads=lowerCAmelCase       ,		dim_head=lowerCAmelCase       ,		dropout=lowerCAmelCase       ,		bias=lowerCAmelCase       ,		cross_attention_dim=cross_attention_dim if only_cross_attention else None       ,		upcast_attention=lowerCAmelCase       ,		)

     # 2. Cross-Attn
     if cross_attention_dim is not None or double_self_attention:
        # We currently only use AdaLayerNormZero for self attention where there will only be one attention block.
        # I.e. the number of returned modulation chunks from AdaLayerZero would not make sense if returned during
        # the second cross attention block.
        SCREAMING_SNAKE_CASE_: int     			=(
            AdaLayerNorm(lowerCAmelCase       ,		lowerCAmelCase		)
            if self.use_ada_layer_norm
            else nn.LayerNorm(lowerCAmelCase       ,		elementwise_affine=lowerCAmelCase		)
        )
        SCREAMING_SNAKE_CASE_: str     			=Attention(
            query_dim=lowerCAmelCase       ,		cross_attention_dim=cross_attention_dim if not double_self_attention else None       ,		heads=lowerCAmelCase       ,		dim_head=lowerCAmelCase       ,		dropout=lowerCAmelCase       ,		bias=lowerCAmelCase       ,		upcast_attention=lowerCAmelCase       ,		)  # is self-attn if encoder_hidden_states is none
     else:
        SCREAMING_SNAKE_CASE_: Optional[int]     			=None
        SCREAMING_SNAKE_CASE_: Optional[Any]     			=None

     # 3. Feed-forward
     SCREAMING_SNAKE_CASE_: List[str]     			=nn.LayerNorm(lowerCAmelCase       ,		elementwise_affine=lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: List[str]     			=FeedForward(lowerCAmelCase       ,		dropout=lowerCAmelCase       ,		activation_fn=lowerCAmelCase       ,		final_dropout=lowerCAmelCase		)

     # let chunk size default to None
     SCREAMING_SNAKE_CASE_: str     			=None
     SCREAMING_SNAKE_CASE_: List[Any]     			=0



  def 	lowerCamelCase__       (						self :					Tuple       ,		lowerCAmelCase :					Optional[int]       ,		lowerCAmelCase :					int		)     ->					Any:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Dict     			=chunk_size
     SCREAMING_SNAKE_CASE_: Optional[Any]     			=dim





  def 	lowerCamelCase__       (						self :					Tuple       ,		lowerCAmelCase :					torch.FloatTensor       ,		lowerCAmelCase :					Optional[torch.FloatTensor] = None       ,		lowerCAmelCase :					Optional[torch.FloatTensor] = None       ,		lowerCAmelCase :					Optional[torch.FloatTensor] = None       ,		lowerCAmelCase :					Optional[torch.LongTensor] = None       ,		lowerCAmelCase :					Dict[str, Any] = None       ,		lowerCAmelCase :					Optional[torch.LongTensor] = None       ,		)     ->					List[Any]:


     '''simple docstring'''




     if self.use_ada_layer_norm:
        SCREAMING_SNAKE_CASE_: Optional[int]     			=self.norma(lowerCAmelCase       ,		lowerCAmelCase		)
     elif self.use_ada_layer_norm_zero:
        SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: str     			=self.norma(
            lowerCAmelCase       ,		lowerCAmelCase       ,		lowerCAmelCase       ,		hidden_dtype=hidden_states.dtype		)
     else:
        SCREAMING_SNAKE_CASE_: Tuple     			=self.norma(lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: Any     			=cross_attention_kwargs if cross_attention_kwargs is not None else {}

     SCREAMING_SNAKE_CASE_: List[str]     			=self.attna(
         lowerCAmelCase       ,		encoder_hidden_states=encoder_hidden_states if self.only_cross_attention else None       ,		attention_mask=lowerCAmelCase       ,		**lowerCAmelCase       ,		)
     if self.use_ada_layer_norm_zero:
        SCREAMING_SNAKE_CASE_: str     			=gate_msa.unsqueeze(1		) * attn_output
     SCREAMING_SNAKE_CASE_: str     			=attn_output + hidden_states

     # 2. Cross-Attention
     if self.attna is not None:
        SCREAMING_SNAKE_CASE_: Any     			=(
            self.norma(lowerCAmelCase       ,		lowerCAmelCase		) if self.use_ada_layer_norm else self.norma(lowerCAmelCase		)
        )

        SCREAMING_SNAKE_CASE_: List[str]     			=self.attna(
            lowerCAmelCase       ,		encoder_hidden_states=lowerCAmelCase       ,		attention_mask=lowerCAmelCase       ,		**lowerCAmelCase       ,		)
        SCREAMING_SNAKE_CASE_: Any     			=attn_output + hidden_states

     # 3. Feed-forward
     SCREAMING_SNAKE_CASE_: str     			=self.norma(lowerCAmelCase		)

     if self.use_ada_layer_norm_zero:
        SCREAMING_SNAKE_CASE_: Optional[int]     			=norm_hidden_states * (1 + scale_mlp[:, None]) + shift_mlp[:, None]

     if self._chunk_size is not None:
        # "feed_forward_chunk_size" can be used to save memory
        if norm_hidden_states.shape[self._chunk_dim] % self._chunk_size != 0:
           raise ValueError(
               f'''`hidden_states` dimension to be chunked: {norm_hidden_states.shape[self._chunk_dim]} has to be divisible by chunk size: {self._chunk_size}. Make sure to set an appropriate `chunk_size` when calling `unet.enable_forward_chunking`.'''		)

        SCREAMING_SNAKE_CASE_: str     			=norm_hidden_states.shape[self._chunk_dim] // self._chunk_size
        SCREAMING_SNAKE_CASE_: int     			=torch.cat(
            [self.ff(lowerCAmelCase		) for hid_slice in norm_hidden_states.chunk(lowerCAmelCase       ,		dim=self._chunk_dim		)]       ,		dim=self._chunk_dim       ,		)
     else:
        SCREAMING_SNAKE_CASE_: int     			=self.ff(lowerCAmelCase		)

     if self.use_ada_layer_norm_zero:
        SCREAMING_SNAKE_CASE_: List[Any]     			=gate_mlp.unsqueeze(1		) * ff_output

     SCREAMING_SNAKE_CASE_: Optional[Any]     			=ff_output + hidden_states

     return hidden_states







class 					a	(  nn.Module       ):



  def __init__(						self :					Dict       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					Optional[int] = None       ,		lowerCAmelCase :					int = 4       ,		lowerCAmelCase :					float = 0.0       ,		lowerCAmelCase :					str = "geglu"       ,		lowerCAmelCase :					bool = False       ,		)     ->					Optional[int]:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: Optional[Any]     			=int(dim * mult		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=dim_out if dim_out is not None else dim

     if activation_fn == "gelu":
        SCREAMING_SNAKE_CASE_: Union[str, Any]     			=GELU(lowerCAmelCase       ,		lowerCAmelCase		)
     if activation_fn == "gelu-approximate":
        SCREAMING_SNAKE_CASE_: int     			=GELU(lowerCAmelCase       ,		lowerCAmelCase       ,		approximate="""tanh"""		)
     elif activation_fn == "geglu":
        SCREAMING_SNAKE_CASE_: Optional[Any]     			=GEGLU(lowerCAmelCase       ,		lowerCAmelCase		)
     elif activation_fn == "geglu-approximate":
        SCREAMING_SNAKE_CASE_: Optional[Any]     			=ApproximateGELU(lowerCAmelCase       ,		lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: Optional[int]     			=nn.ModuleList([]		)
     # project in
     self.net.append(lowerCAmelCase		)
     # project dropout
     self.net.append(nn.Dropout(lowerCAmelCase		)		)
     # project out
     self.net.append(nn.Linear(lowerCAmelCase       ,		lowerCAmelCase		)		)
     # FF as used in Vision Transformer, MLP-Mixer, etc. have a final dropout
     if final_dropout:
        self.net.append(nn.Dropout(lowerCAmelCase		)		)





  def 	lowerCamelCase__       (						self :					int       ,		lowerCAmelCase :					str		)     ->					Dict:


     '''simple docstring'''




     for module in self.net:
        SCREAMING_SNAKE_CASE_: List[Any]     			=module(lowerCAmelCase		)
     return hidden_states







class 					a	(  nn.Module       ):



  def __init__(						self :					Optional[int]       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					str = "none"		)     ->					Optional[int]:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: str     			=nn.Linear(lowerCAmelCase       ,		lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=approximate



  def 	lowerCamelCase__       (						self :					str       ,		lowerCAmelCase :					Optional[Any]		)     ->					Optional[int]:


     '''simple docstring'''




     if gate.device.type != "mps":
        return F.gelu(lowerCAmelCase       ,		approximate=self.approximate		)
     # mps: gelu is not implemented for float16
     return F.gelu(gate.to(dtype=torch.floataa		)       ,		approximate=self.approximate		).to(dtype=gate.dtype		)





  def 	lowerCamelCase__       (						self :					Optional[Any]       ,		lowerCAmelCase :					Dict		)     ->					Union[str, Any]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Any     			=self.proj(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Optional[Any]     			=self.gelu(lowerCAmelCase		)
     return hidden_states







class 					a	(  nn.Module       ):



  def __init__(						self :					List[str]       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int		)     ->					Union[str, Any]:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: Any     			=nn.Linear(lowerCAmelCase       ,		dim_out * 2		)



  def 	lowerCamelCase__       (						self :					str       ,		lowerCAmelCase :					List[str]		)     ->					Union[str, Any]:


     '''simple docstring'''




     if gate.device.type != "mps":
        return F.gelu(lowerCAmelCase		)
     # mps: gelu is not implemented for float16
     return F.gelu(gate.to(dtype=torch.floataa		)		).to(dtype=gate.dtype		)





  def 	lowerCamelCase__       (						self :					List[str]       ,		lowerCAmelCase :					Tuple		)     ->					Optional[Any]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Tuple     			=self.proj(lowerCAmelCase		).chunk(2       ,		dim=-1		)
     return hidden_states * self.gelu(lowerCAmelCase		)







class 					a	(  nn.Module       ):



  def __init__(						self :					Tuple       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int		)     ->					List[str]:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: List[str]     			=nn.Linear(lowerCAmelCase       ,		lowerCAmelCase		)





  def 	lowerCamelCase__       (						self :					Optional[int]       ,		lowerCAmelCase :					List[Any]		)     ->					int:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=self.proj(lowerCAmelCase		)
     return x * torch.sigmoid(1.7_0_2 * x		)







class 					a	(  nn.Module       ):



  def __init__(						self :					int       ,		lowerCAmelCase :					List[str]       ,		lowerCAmelCase :					List[str]		)     ->					Optional[Any]:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: Any     			=nn.Embedding(lowerCAmelCase       ,		lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: List[Any]     			=nn.SiLU()
     SCREAMING_SNAKE_CASE_: int     			=nn.Linear(lowerCAmelCase       ,		embedding_dim * 2		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=nn.LayerNorm(lowerCAmelCase       ,		elementwise_affine=lowerCAmelCase		)





  def 	lowerCamelCase__       (						self :					Tuple       ,		lowerCAmelCase :					str       ,		lowerCAmelCase :					Any		)     ->					Any:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Optional[Any]     			=self.linear(self.silu(self.emb(lowerCAmelCase		)		)		)
     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Dict     			=torch.chunk(lowerCAmelCase       ,		2		)
     SCREAMING_SNAKE_CASE_: Any     			=self.norm(lowerCAmelCase		) * (1 + scale) + shift
     return x







class 					a	(  nn.Module       ):



  def __init__(						self :					List[str]       ,		lowerCAmelCase :					List[str]       ,		lowerCAmelCase :					Any		)     ->					Union[str, Any]:


     '''simple docstring'''




     super().__init__()

     SCREAMING_SNAKE_CASE_: str     			=CombinedTimestepLabelEmbeddings(lowerCAmelCase       ,		lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: List[Any]     			=nn.SiLU()
     SCREAMING_SNAKE_CASE_: Optional[Any]     			=nn.Linear(lowerCAmelCase       ,		6 * embedding_dim       ,		bias=lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Tuple     			=nn.LayerNorm(lowerCAmelCase       ,		elementwise_affine=lowerCAmelCase       ,		eps=1E-6		)





  def 	lowerCamelCase__       (						self :					Tuple       ,		lowerCAmelCase :					Optional[Any]       ,		lowerCAmelCase :					str       ,		lowerCAmelCase :					Tuple       ,		lowerCAmelCase :					List[str]=None		)     ->					Optional[int]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: List[str]     			=self.linear(self.silu(self.emb(lowerCAmelCase       ,		lowerCAmelCase       ,		hidden_dtype=lowerCAmelCase		)		)		)
     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Optional[int]     			=emb.chunk(6       ,		dim=1		)
     SCREAMING_SNAKE_CASE_: int     			=self.norm(lowerCAmelCase		) * (1 + scale_msa[:, None]) + shift_msa[:, None]
     return x, gate_msa, shift_mlp, scale_mlp, gate_mlp







class 					a	(  nn.Module       ):



  def __init__(						self :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					Optional[str] = None       ,		lowerCAmelCase :					float = 1E-5		)     ->					str:


     '''simple docstring'''




     super().__init__()
     SCREAMING_SNAKE_CASE_: List[Any]     			=num_groups
     SCREAMING_SNAKE_CASE_: Any     			=eps

     if act_fn is None:
        SCREAMING_SNAKE_CASE_: List[Any]     			=None
     else:
        SCREAMING_SNAKE_CASE_: Optional[Any]     			=get_activation(lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: List[str]     			=nn.Linear(lowerCAmelCase       ,		out_dim * 2		)





  def 	lowerCamelCase__       (						self :					Optional[int]       ,		lowerCAmelCase :					int       ,		lowerCAmelCase :					Optional[Any]		)     ->					Union[str, Any]:


     '''simple docstring'''




     if self.act:
        SCREAMING_SNAKE_CASE_: Dict     			=self.act(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: int     			=self.linear(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Tuple     			=emb[:, :, None, None]
     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: int     			=emb.chunk(2       ,		dim=1		)

     SCREAMING_SNAKE_CASE_: Optional[Any]     			=F.group_norm(lowerCAmelCase       ,		self.num_groups       ,		eps=self.eps		)
     SCREAMING_SNAKE_CASE_: List[Any]     			=x * (1 + scale) + shift
     return x








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



  def 	lowerCamelCase__       (						self :					Dict		)     ->					str:


     '''simple docstring'''




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



  def 	lowerCamelCase__       (						self :					Optional[Any]		)     ->					int:


     '''simple docstring'''




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

     SCREAMING_SNAKE_CASE_: Union[str, Any]     			="""A painting of a squirrel eating a burger"""
     SCREAMING_SNAKE_CASE_: Any     			=jax.device_count()
     SCREAMING_SNAKE_CASE_: Dict     			=num_samples * [prompt]
     SCREAMING_SNAKE_CASE_: List[Any]     			=sd_pipe.prepare_inputs(lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=replicate(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=shard(lowerCAmelCase		)

     SCREAMING_SNAKE_CASE_: Dict     			=jax.random.PRNGKey(0		)
     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=jax.random.split(lowerCAmelCase       ,		jax.device_count()		)

     SCREAMING_SNAKE_CASE_: Tuple     			=sd_pipe(lowerCAmelCase       ,		lowerCAmelCase       ,		lowerCAmelCase       ,		num_inference_steps=25       ,		jit=lowerCAmelCase		)[0]
     assert images.shape == (jax.device_count(), 1, 768, 768, 3)

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

     SCREAMING_SNAKE_CASE_: Optional[int]     			=jnp.asarray(jax.device_get(image_slice.flatten()		)		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=jnp.array([0.4_2_3_8, 0.4_4_1_4, 0.4_3_9_5, 0.4_4_5_3, 0.4_6_2_9, 0.4_5_9_0, 0.4_5_3_1, 0.4_5_5_0_8, 0.4_5_1_2]		)
     print(f'''output_slice: {output_slice}'''		)
     assert jnp.abs(output_slice - expected_slice		).max() < 1E-2





  def 	lowerCamelCase__       (						self :					List[str]		)     ->					Dict:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: int     			="""stabilityai/stable-diffusion-2"""
     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Optional[int]     			=FlaxDPMSolverMultistepScheduler.from_pretrained(lowerCAmelCase       ,		subfolder="""scheduler"""		)
     SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Optional[int]     			=FlaxStableDiffusionPipeline.from_pretrained(
         lowerCAmelCase       ,		scheduler=lowerCAmelCase       ,		revision="""bf16"""       ,		dtype=jnp.bfloataa       ,		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=scheduler_params

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

     SCREAMING_SNAKE_CASE_: Tuple     			=replicate(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=shard(lowerCAmelCase		)

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

     SCREAMING_SNAKE_CASE_: Tuple     			=sd_pipe(lowerCAmelCase       ,		lowerCAmelCase       ,		lowerCAmelCase       ,		num_inference_steps=25       ,		jit=lowerCAmelCase		)[0]
     assert images.shape == (jax.device_count(), 1, 768, 768, 3)

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

     SCREAMING_SNAKE_CASE_: Optional[Any]     			=jnp.asarray(jax.device_get(image_slice.flatten()		)		)
     SCREAMING_SNAKE_CASE_: Optional[int]     			=jnp.array([0.4_3_3_6, 0.4_2_9_6_9, 0.4_4_5_3, 0.4_1_9_9, 0.4_2_9_7, 0.4_5_3_1, 0.4_4_3_4, 0.4_4_3_4, 0.4_2_9_7]		)
     print(f'''output_slice: {output_slice}'''		)
     assert jnp.abs(output_slice - expected_slice		).max() < 1E-2



