






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






class 						UpperCAmelCase__ (							nn.Module							):
		__snake_case      :       int
		__snake_case      :       jnp.dtype     =   jnp.floataa







		def  A__      (					self		):
						_A	:				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__		):
						_A  ,				_A  ,				_A  ,				_A	:				Tuple   =      hidden_states.shape
						_A	:				Optional[int]   =      jax.image.resize(
						    A__       ,shape=(batch, height * 2, width * 2, channels)       ,method='''nearest'''       ,)
						_A	:				List[Any]   =      self.conv(A__		)
						return hidden_states






class 						UpperCAmelCase__ (							nn.Module							):
		__snake_case      :       int
		__snake_case      :       jnp.dtype     =   jnp.floataa







		def  A__      (					self		):
						_A	:				List[Any]   =      nn.Conv(
						    self.out_channels       ,kernel_size=(3, 3)       ,strides=(2, 2)       ,padding=((1, 1), (1, 1))       ,dtype=self.dtype       ,)







		def __call__(					self       ,A__		):
						# pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
						# hidden_states = jnp.pad(hidden_states, pad_width=pad)
						_A	:				Optional[int]   =      self.conv(A__		)
						return hidden_states






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







		def  A__      (					self		):
						_A	:				Optional[Any]   =      self.in_channels if self.out_channels is None else self.out_channels

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

						_A	:				Optional[Any]   =      nn.Dense(A__       ,dtype=self.dtype		)

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

						_A	:				List[str]   =      self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

						_A	:				int   =      None
						if use_nin_shortcut:
										_A	:				Optional[int]   =      nn.Conv(
										    A__       ,kernel_size=(1, 1)       ,strides=(1, 1)       ,padding='''VALID'''       ,dtype=self.dtype       ,)







		def __call__(					self       ,A__       ,A__       ,A__=True		):
						_A	:				Optional[int]   =      hidden_states
						_A	:				List[Any]   =      self.norma(A__		)
						_A	:				Union[str, Any]   =      nn.swish(A__		)
						_A	:				List[str]   =      self.conva(A__		)

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

						_A	:				int   =      self.norma(A__		)
						_A	:				Optional[int]   =      nn.swish(A__		)
						_A	:				Optional[Any]   =      self.dropout(A__       ,A__		)
						_A	:				List[Any]   =      self.conva(A__		)

						if self.conv_shortcut is not None:
										_A	:				List[str]   =      self.conv_shortcut(A__		)

						return hidden_states + residual











import warnings


warnings.warn(
    'memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: '
    '`from accelerate import find_executable_batch_size` to avoid this warning.',
    FutureWarning,
)



