





"""simple docstring"""




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


class  __UpperCamelCase       (		nn.Module		):
							lowerCamelCase     :      int
							lowerCamelCase     :      jnp.dtype         =jnp.floataa






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






							def __call__(     self   ,      lowerCAmelCase__   )			->				Optional[Any]:
								a, a, a, a   :	List[str]			=       hidden_states.shape
								a   :	List[Any]			=       jax.image.resize(
								    lowerCAmelCase__   ,      shape=(batch, height * 2, width * 2, channels)   ,      method="nearest"   ,      )
								a   :	List[str]			=       self.conv(lowerCAmelCase__   )
								return hidden_states


class  __UpperCamelCase       (		nn.Module		):
							lowerCamelCase     :      int
							lowerCamelCase     :      jnp.dtype         =jnp.floataa






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






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


class  __UpperCamelCase       (		nn.Module		):
							lowerCamelCase     :      int
							lowerCamelCase     :      int         =None
							lowerCamelCase     :      float         =0.0
							lowerCamelCase     :      bool         =None
							lowerCamelCase     :      jnp.dtype         =jnp.floataa






							def 					__a     (     self   )			->				int:
								a   :	Dict			=       self.in_channels if self.out_channels is None else self.out_channels

								a   :	Union[str, Any]			=       nn.GroupNorm(num_groups=32   ,      epsilon=1E-5   )
								a   :	List[Any]			=       nn.Conv(
								    lowerCAmelCase__   ,      kernel_size=(3, 3)   ,      strides=(1, 1)   ,      padding=((1, 1), (1, 1))   ,      dtype=self.dtype   ,      )

								a   :	List[Any]			=       nn.Dense(lowerCAmelCase__   ,      dtype=self.dtype   )

								a   :	Union[str, Any]			=       nn.GroupNorm(num_groups=32   ,      epsilon=1E-5   )
								a   :	Optional[int]			=       nn.Dropout(self.dropout_prob   )
								a   :	Dict			=       nn.Conv(
								    lowerCAmelCase__   ,      kernel_size=(3, 3)   ,      strides=(1, 1)   ,      padding=((1, 1), (1, 1))   ,      dtype=self.dtype   ,      )

								a   :	Union[str, Any]			=       self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

								a   :	List[str]			=       None
								if use_nin_shortcut:
									a   :	Optional[Any]			=       nn.Conv(
									    lowerCAmelCase__   ,      kernel_size=(1, 1)   ,      strides=(1, 1)   ,      padding="VALID"   ,      dtype=self.dtype   ,      )






							def __call__(     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__=True   )			->				str:
								a   :	int			=       hidden_states
								a   :	Tuple			=       self.norma(lowerCAmelCase__   )
								a   :	Any			=       nn.swish(lowerCAmelCase__   )
								a   :	int			=       self.conva(lowerCAmelCase__   )

								a   :	int			=       self.time_emb_proj(nn.swish(lowerCAmelCase__   )   )
								a   :	Tuple			=       jnp.expand_dims(jnp.expand_dims(lowerCAmelCase__   ,      1   )   ,      1   )
								a   :	Dict			=       hidden_states + temb

								a   :	str			=       self.norma(lowerCAmelCase__   )
								a   :	List[Any]			=       nn.swish(lowerCAmelCase__   )
								a   :	List[str]			=       self.dropout(lowerCAmelCase__   ,      lowerCAmelCase__   )
								a   :	List[str]			=       self.conva(lowerCAmelCase__   )

								if self.conv_shortcut is not None:
									a   :	Tuple			=       self.conv_shortcut(lowerCAmelCase__   )

								return hidden_states + residual









"""simple docstring"""




import baseaa






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					str      )				->bytes:






	'''simple docstring'''






	return baseaa.aaaencode(string.encode("utf-8"      )      )






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					bytes      )				->str:






	'''simple docstring'''






	return baseaa.aaadecode(_lowercase      ).decode("utf-8"      )


if __name__ == "__main__":
		import doctest

		doctest.testmod()


