


"""simple docstring"""
import flax.linen as nn
import jax
import jax.numpy as jnp



class 			_UpperCAmelCase (							nn.Module				):






		'''simple docstring'''

		lowerCamelCase__				=42
		lowerCamelCase__				=jnp.floataa



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						Optional[int]						=				nn.Conv(
			    self.out_channels				,       kernel_size=(3, 3)				,       strides=(1, 1)				,       padding=((1, 1), (1, 1))				,       dtype=self.dtype				,       )



		def __call__(self				,       a_					):





			'''simple docstring'''

			__snake_case	,							__snake_case	,							__snake_case	,							__snake_case	:						List[Any]						=				hidden_states.shape
			__snake_case	:						Optional[Any]						=				jax.image.resize(
			    a_				,       shape=(batch, height * 2, width * 2, channels)				,       method='''nearest'''				,       )
			__snake_case	:						Union[str, Any]						=				self.conv(a_					)
			return hidden_states



class 			_UpperCAmelCase (							nn.Module				):






		'''simple docstring'''

		lowerCamelCase__				=42
		lowerCamelCase__				=jnp.floataa



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

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



		def __call__(self				,       a_					):





			'''simple docstring'''

			__snake_case	:						Dict						=				self.conv(a_					)
			return hidden_states



class 			_UpperCAmelCase (							nn.Module				):






		'''simple docstring'''

		lowerCamelCase__				=42
		lowerCamelCase__				=None
		lowerCamelCase__				=0.0
		lowerCamelCase__				=None
		lowerCamelCase__				=jnp.floataa



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						Optional[int]						=				self.in_channels if self.out_channels is None else self.out_channels

			__snake_case	:						int						=				nn.GroupNorm(num_groups=32				,       epsilon=1E-5					)
			__snake_case	:						Tuple						=				nn.Conv(
			    a_				,       kernel_size=(3, 3)				,       strides=(1, 1)				,       padding=((1, 1), (1, 1))				,       dtype=self.dtype				,       )

			__snake_case	:						Any						=				nn.Dense(a_				,       dtype=self.dtype					)

			__snake_case	:						List[str]						=				nn.GroupNorm(num_groups=32				,       epsilon=1E-5					)
			__snake_case	:						Tuple						=				nn.Dropout(self.dropout_prob					)
			__snake_case	:						Tuple						=				nn.Conv(
			    a_				,       kernel_size=(3, 3)				,       strides=(1, 1)				,       padding=((1, 1), (1, 1))				,       dtype=self.dtype				,       )

			__snake_case	:						Any						=				self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

			__snake_case	:						List[str]						=				None
			if use_nin_shortcut:
				__snake_case	:						str						=				nn.Conv(
				    a_				,       kernel_size=(1, 1)				,       strides=(1, 1)				,       padding='''VALID'''				,       dtype=self.dtype				,       )



		def __call__(self				,       a_				,       a_				,       a_=True					):





			'''simple docstring'''

			__snake_case	:						str						=				hidden_states
			__snake_case	:						Any						=				self.norma(a_					)
			__snake_case	:						Tuple						=				nn.swish(a_					)
			__snake_case	:						Tuple						=				self.conva(a_					)

			__snake_case	:						List[str]						=				self.time_emb_proj(nn.swish(a_					)					)
			__snake_case	:						Union[str, Any]						=				jnp.expand_dims(jnp.expand_dims(a_				,       1					)				,       1					)
			__snake_case	:						Union[str, Any]						=				hidden_states + temb

			__snake_case	:						Tuple						=				self.norma(a_					)
			__snake_case	:						int						=				nn.swish(a_					)
			__snake_case	:						Optional[Any]						=				self.dropout(a_				,       a_					)
			__snake_case	:						int						=				self.conva(a_					)

			if self.conv_shortcut is not None:
				__snake_case	:						Union[str, Any]						=				self.conv_shortcut(a_					)

			return hidden_states + residual









"""simple docstring"""
from ...utils import is_torch_available, is_transformers_available


if is_transformers_available() and is_torch_available():
			from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline





