



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




class   UpperCamelCase_       (     nn.Module    ):
							lowerCamelCase_           =					42
							lowerCamelCase_           =					jnp.floataa


							def      _snake_case  (							self    :Tuple		)   ->   Any:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      nn.Conv(
									    self.out_channels							,				kernel_size=(3, 3)							,				strides=(1, 1)							,				padding=((1, 1), (1, 1))							,				dtype=self.dtype							,				)


							def __call__(							self    :Union[str, Any]							,				__A    :List[Any]		)   ->   Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      hidden_states.shape
									SCREAMING_SNAKE_CASE__			=      jax.image.resize(
									    _A							,				shape=(batch, height * 2, width * 2, channels)							,				method="""nearest"""							,				)
									SCREAMING_SNAKE_CASE__			=      self.conv(_A		)
									return hidden_states




class   UpperCamelCase_       (     nn.Module    ):
							lowerCamelCase_           =					42
							lowerCamelCase_           =					jnp.floataa


							def      _snake_case  (							self    :Tuple		)   ->   List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      nn.Conv(
									    self.out_channels							,				kernel_size=(3, 3)							,				strides=(2, 2)							,				padding=((1, 1), (1, 1))							,				dtype=self.dtype							,				)


							def __call__(							self    :Optional[Any]							,				__A    :Any		)   ->   List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      self.conv(_A		)
									return hidden_states




class   UpperCamelCase_       (     nn.Module    ):
							lowerCamelCase_           =					42
							lowerCamelCase_           =					None
							lowerCamelCase_           =					0.0
							lowerCamelCase_           =					None
							lowerCamelCase_           =					jnp.floataa


							def      _snake_case  (							self    :List[str]		)   ->   int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      self.in_channels if self.out_channels is None else self.out_channels

									SCREAMING_SNAKE_CASE__			=      nn.GroupNorm(num_groups=32							,				epsilon=1E-5		)
									SCREAMING_SNAKE_CASE__			=      nn.Conv(
									    _A							,				kernel_size=(3, 3)							,				strides=(1, 1)							,				padding=((1, 1), (1, 1))							,				dtype=self.dtype							,				)

									SCREAMING_SNAKE_CASE__			=      nn.Dense(_A							,				dtype=self.dtype		)

									SCREAMING_SNAKE_CASE__			=      nn.GroupNorm(num_groups=32							,				epsilon=1E-5		)
									SCREAMING_SNAKE_CASE__			=      nn.Dropout(self.dropout_prob		)
									SCREAMING_SNAKE_CASE__			=      nn.Conv(
									    _A							,				kernel_size=(3, 3)							,				strides=(1, 1)							,				padding=((1, 1), (1, 1))							,				dtype=self.dtype							,				)

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

									SCREAMING_SNAKE_CASE__			=      None
									if use_nin_shortcut:
											SCREAMING_SNAKE_CASE__			=      nn.Conv(
											    _A							,				kernel_size=(1, 1)							,				strides=(1, 1)							,				padding="""VALID"""							,				dtype=self.dtype							,				)


							def __call__(							self    :Optional[int]							,				__A    :Dict							,				__A    :List[str]							,				__A    :int=True		)   ->   Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      hidden_states
									SCREAMING_SNAKE_CASE__			=      self.norma(_A		)
									SCREAMING_SNAKE_CASE__			=      nn.swish(_A		)
									SCREAMING_SNAKE_CASE__			=      self.conva(_A		)

									SCREAMING_SNAKE_CASE__			=      self.time_emb_proj(nn.swish(_A		)		)
									SCREAMING_SNAKE_CASE__			=      jnp.expand_dims(jnp.expand_dims(_A							,				1		)							,				1		)
									SCREAMING_SNAKE_CASE__			=      hidden_states + temb

									SCREAMING_SNAKE_CASE__			=      self.norma(_A		)
									SCREAMING_SNAKE_CASE__			=      nn.swish(_A		)
									SCREAMING_SNAKE_CASE__			=      self.dropout(_A							,				_A		)
									SCREAMING_SNAKE_CASE__			=      self.conva(_A		)

									if self.conv_shortcut is not None:
											SCREAMING_SNAKE_CASE__			=      self.conv_shortcut(_A		)

									return hidden_states + residual






import inspect
import unittest




class   UpperCamelCase_       (     unittest.TestCase    ):


							def      _snake_case  (							self    :str		)   ->   Union[str, Any]:



									"""simple docstring"""



									try:
											import diffusers  # noqa: F401
									except ImportError:
											assert False


							def      _snake_case  (							self    :Any		)   ->   Any:



									"""simple docstring"""



									import diffusers
									from diffusers.dependency_versions_table import deps

									SCREAMING_SNAKE_CASE__			=      inspect.getmembers(__A							,				inspect.isclass		)

									for cls_name, cls_module in all_classes:
											if "dummy_" in cls_module.__module__:
													for backend in cls_module._backends:
															if backend == "k_diffusion":
																	SCREAMING_SNAKE_CASE__			=      """k-diffusion"""
															elif backend == "invisible_watermark":
																	SCREAMING_SNAKE_CASE__			=      """invisible-watermark"""
															assert backend in deps, f'''{backend} is not in the deps table!'''