




'''simple docstring'''


import flax.linen as nn
import jax
import jax.numpy as jnp





class    __lowercase						(  nn.Module ):
   _a							=      42
   _a							=      jnp.floataa







   def 		UpperCamelCase__			(	self      )				->    Tuple:
     __a			=					nn.Conv(
         self.out_channels      ,							kernel_size=(3, 3)      ,							strides=(1, 1)      ,							padding=((1, 1), (1, 1))      ,							dtype=self.dtype      ,							)







   def __call__(	self      ,							UpperCamelCase      )				->    List[str]:
     __a	,       __a	,       __a	,       __a			=					hidden_states.shape
     __a			=					jax.image.resize(
         UpperCamelCase      ,							shape=(batch, height * 2, width * 2, channels)      ,							method='nearest'      ,							)
     __a			=					self.conv(UpperCamelCase      )
     return hidden_states





class    __lowercase						(  nn.Module ):
   _a							=      42
   _a							=      jnp.floataa







   def 		UpperCamelCase__			(	self      )				->    Union[str, Any]:
     __a			=					nn.Conv(
         self.out_channels      ,							kernel_size=(3, 3)      ,							strides=(2, 2)      ,							padding=((1, 1), (1, 1))      ,							dtype=self.dtype      ,							)







   def __call__(	self      ,							UpperCamelCase      )				->    Any:
     # pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
     # hidden_states = jnp.pad(hidden_states, pad_width=pad)
     __a			=					self.conv(UpperCamelCase      )
     return hidden_states





class    __lowercase						(  nn.Module ):
   _a							=      42
   _a							=      None
   _a							=      0.0
   _a							=      None
   _a							=      jnp.floataa







   def 		UpperCamelCase__			(	self      )				->    Tuple:
     __a			=					self.in_channels if self.out_channels is None else self.out_channels

     __a			=					nn.GroupNorm(num_groups=32      ,							epsilon=1e-5      )
     __a			=					nn.Conv(
         UpperCamelCase      ,							kernel_size=(3, 3)      ,							strides=(1, 1)      ,							padding=((1, 1), (1, 1))      ,							dtype=self.dtype      ,							)

     __a			=					nn.Dense(UpperCamelCase      ,							dtype=self.dtype      )

     __a			=					nn.GroupNorm(num_groups=32      ,							epsilon=1e-5      )
     __a			=					nn.Dropout(self.dropout_prob      )
     __a			=					nn.Conv(
         UpperCamelCase      ,							kernel_size=(3, 3)      ,							strides=(1, 1)      ,							padding=((1, 1), (1, 1))      ,							dtype=self.dtype      ,							)

     __a			=					self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

     __a			=					None
     if use_nin_shortcut:
       __a			=					nn.Conv(
           UpperCamelCase      ,							kernel_size=(1, 1)      ,							strides=(1, 1)      ,							padding='VALID'      ,							dtype=self.dtype      ,							)







   def __call__(	self      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase=True      )				->    Tuple:
     __a			=					hidden_states
     __a			=					self.norma(UpperCamelCase      )
     __a			=					nn.swish(UpperCamelCase      )
     __a			=					self.conva(UpperCamelCase      )

     __a			=					self.time_emb_proj(nn.swish(UpperCamelCase      )      )
     __a			=					jnp.expand_dims(jnp.expand_dims(UpperCamelCase      ,							1      )      ,							1      )
     __a			=					hidden_states + temb

     __a			=					self.norma(UpperCamelCase      )
     __a			=					nn.swish(UpperCamelCase      )
     __a			=					self.dropout(UpperCamelCase      ,							UpperCamelCase      )
     __a			=					self.conva(UpperCamelCase      )

     if self.conv_shortcut is not None:
       __a			=					self.conv_shortcut(UpperCamelCase      )

     return hidden_states + residual









'''simple docstring'''


import torch

from diffusers import StableDiffusionPipeline


UpperCAmelCase_ 		=      "path-to-your-trained-model"
UpperCAmelCase_ 		=      StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda")

UpperCAmelCase_ 		=      "A photo of sks dog in a bucket"
UpperCAmelCase_ 		=      pipe(prompt, num_inference_steps=50, guidance_scale=7.5).images[0]

image.save("dog-bucket.png")



