


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







class 	snake_case_       (nn.Module				):
					UpperCAmelCase__ :   int
					UpperCAmelCase__ :   jnp.dtype   				=      jnp.floataa
					def 			lowerCamelCase__(				self       :List[str]				) ->   List[str]:
												a__					=					nn.Conv(
												    self.out_channels      ,kernel_size=(3, 3)      ,strides=(1, 1)      ,padding=((1, 1), (1, 1))      ,dtype=self.dtype      ,)



					def __call__(				self       :Any      ,__snake_case       :Any				) ->   Optional[Any]:
												a__				, a__				, a__				, a__					=					hidden_states.shape
												a__					=					jax.image.resize(
												    __snake_case      ,shape=(batch, height * 2, width * 2, channels)      ,method='nearest'      ,)
												a__					=					self.conv(__snake_case				)
												return hidden_states







class 	snake_case_       (nn.Module				):
					UpperCAmelCase__ :   int
					UpperCAmelCase__ :   jnp.dtype   				=      jnp.floataa
					def 			lowerCamelCase__(				self       :Union[str, Any]				) ->   Any:
												a__					=					nn.Conv(
												    self.out_channels      ,kernel_size=(3, 3)      ,strides=(2, 2)      ,padding=((1, 1), (1, 1))      ,dtype=self.dtype      ,)



					def __call__(				self       :Dict      ,__snake_case       :Any				) ->   Optional[Any]:
												# pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
												# hidden_states = jnp.pad(hidden_states, pad_width=pad)
												a__					=					self.conv(__snake_case				)
												return hidden_states







class 	snake_case_       (nn.Module				):
					UpperCAmelCase__ :   int
					UpperCAmelCase__ :   int   				=      None
					UpperCAmelCase__ :   float   				=      0.0
					UpperCAmelCase__ :   bool   				=      None
					UpperCAmelCase__ :   jnp.dtype   				=      jnp.floataa
					def 			lowerCamelCase__(				self       :Dict				) ->   Optional[int]:
												a__					=					self.in_channels if self.out_channels is None else self.out_channels

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

												a__					=					nn.Dense(__snake_case      ,dtype=self.dtype				)

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

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

												a__					=					None
												if use_nin_shortcut:
																			a__					=					nn.Conv(
																			    __snake_case      ,kernel_size=(1, 1)      ,strides=(1, 1)      ,padding='VALID'      ,dtype=self.dtype      ,)



					def __call__(				self       :Optional[Any]      ,__snake_case       :int      ,__snake_case       :Dict      ,__snake_case       :Any=True				) ->   Optional[int]:
												a__					=					hidden_states
												a__					=					self.norma(__snake_case				)
												a__					=					nn.swish(__snake_case				)
												a__					=					self.conva(__snake_case				)

												a__					=					self.time_emb_proj(nn.swish(__snake_case				)				)
												a__					=					jnp.expand_dims(jnp.expand_dims(__snake_case      ,1				)      ,1				)
												a__					=					hidden_states + temb

												a__					=					self.norma(__snake_case				)
												a__					=					nn.swish(__snake_case				)
												a__					=					self.dropout(__snake_case      ,__snake_case				)
												a__					=					self.conva(__snake_case				)

												if self.conv_shortcut is not None:
																			a__					=					self.conv_shortcut(__snake_case				)

												return hidden_states + residual








from .configuration_bert_masked import MaskedBertConfig
from .modeling_bert_masked import (
    MaskedBertForMultipleChoice,
    MaskedBertForQuestionAnswering,
    MaskedBertForSequenceClassification,
    MaskedBertForTokenClassification,
    MaskedBertModel,
)
from .modules import *




