






"""simple docstring"""



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







class        lowercase__      (							nn.Module       ):
			_UpperCAmelCase		:int
			_UpperCAmelCase		:jnp.dtype             =			jnp.floataa


			def      UpperCAmelCase__						(				self					:  Dict ):
										lowerCamelCase_	:							Tuple									=nn.Conv(
										    self.out_channels       ,	kernel_size=(3, 3)       ,	strides=(1, 1)       ,	padding=((1, 1), (1, 1))       ,	dtype=self.dtype       ,	)


			def __call__(				self					:  Optional[int]       ,	snake_case__					:  Optional[Any] ):
										lowerCamelCase_							,						lowerCamelCase_							,						lowerCamelCase_							,						lowerCamelCase_	:							str									=hidden_states.shape
										lowerCamelCase_	:							int									=jax.image.resize(
										    snake_case__       ,	shape=(batch, height * 2, width * 2, channels)       ,	method="nearest"       ,	)
										lowerCamelCase_	:							Dict									=self.conv(snake_case__ )
										return hidden_states







class        lowercase__      (							nn.Module       ):
			_UpperCAmelCase		:int
			_UpperCAmelCase		:jnp.dtype             =			jnp.floataa


			def      UpperCAmelCase__						(				self					:  Union[str, Any] ):
										lowerCamelCase_	:							Optional[int]									=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]       ,	snake_case__					:  Optional[int] ):
										# pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
										# hidden_states = jnp.pad(hidden_states, pad_width=pad)
										lowerCamelCase_	:							Any									=self.conv(snake_case__ )
										return hidden_states







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


			def      UpperCAmelCase__						(				self					:  Dict ):
										lowerCamelCase_	:							List[Any]									=self.in_channels if self.out_channels is None else self.out_channels

										lowerCamelCase_	:							Optional[int]									=nn.GroupNorm(num_groups=32       ,	epsilon=1E-5 )
										lowerCamelCase_	:							List[Any]									=nn.Conv(
										    snake_case__       ,	kernel_size=(3, 3)       ,	strides=(1, 1)       ,	padding=((1, 1), (1, 1))       ,	dtype=self.dtype       ,	)

										lowerCamelCase_	:							Optional[int]									=nn.Dense(snake_case__       ,	dtype=self.dtype )

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

										lowerCamelCase_	:							Optional[Any]									=self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

										lowerCamelCase_	:							Dict									=None
										if use_nin_shortcut:
																	lowerCamelCase_	:							int									=nn.Conv(
																	    snake_case__       ,	kernel_size=(1, 1)       ,	strides=(1, 1)       ,	padding="VALID"       ,	dtype=self.dtype       ,	)


			def __call__(				self					:  Tuple       ,	snake_case__					:  Any       ,	snake_case__					:  Optional[Any]       ,	snake_case__					:  List[Any]=True ):
										lowerCamelCase_	:							Optional[int]									=hidden_states
										lowerCamelCase_	:							str									=self.norma(snake_case__ )
										lowerCamelCase_	:							List[str]									=nn.swish(snake_case__ )
										lowerCamelCase_	:							str									=self.conva(snake_case__ )

										lowerCamelCase_	:							int									=self.time_emb_proj(nn.swish(snake_case__ ) )
										lowerCamelCase_	:							Optional[Any]									=jnp.expand_dims(jnp.expand_dims(snake_case__       ,	1 )       ,	1 )
										lowerCamelCase_	:							Any									=hidden_states + temb

										lowerCamelCase_	:							Dict									=self.norma(snake_case__ )
										lowerCamelCase_	:							List[Any]									=nn.swish(snake_case__ )
										lowerCamelCase_	:							str									=self.dropout(snake_case__       ,	snake_case__ )
										lowerCamelCase_	:							str									=self.conva(snake_case__ )

										if self.conv_shortcut is not None:
																	lowerCamelCase_	:							str									=self.conv_shortcut(snake_case__ )

										return hidden_states + residual











"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import _LazyModule


A__	:    Tuple			 = {'tokenization_byt5': ['ByT5Tokenizer']}


if TYPE_CHECKING:
						from .tokenization_byta import ByTaTokenizer
else:
						import sys

						A__	:    Dict			 = _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



