





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






class 						UpperCamelCase_  (  nn.Module							):
					_a      :						int
					_a      :						jnp.dtype						    =					jnp.floataa



					def   __a     (		self     :     int						):
							lowerCamelCase_	:     Dict 						=      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]       ,      lowerCamelCase     :     str						):
							lowerCamelCase_						,      lowerCamelCase_						,      lowerCamelCase_						,      lowerCamelCase_	:     str 						=      hidden_states.shape
							lowerCamelCase_	:     str 						=      jax.image.resize(
							    lowerCamelCase       ,      shape=(batch, height * 2, width * 2, channels)       ,      method='nearest'       ,      )
							lowerCamelCase_	:     Optional[Any] 						=      self.conv(lowerCamelCase						)
							return hidden_states






class 						UpperCamelCase_  (  nn.Module							):
					_a      :						int
					_a      :						jnp.dtype						    =					jnp.floataa



					def   __a     (		self     :     int						):
							lowerCamelCase_	:     Union[str, Any] 						=      nn.Conv(
							    self.out_channels       ,      kernel_size=(3, 3)       ,      strides=(2, 2)       ,      padding=((1, 1), (1, 1))       ,      dtype=self.dtype       ,      )





					def __call__(		self     :     Union[str, Any]       ,      lowerCamelCase     :     Any						):
							# pad = ((0, 0), (0, 1), (0, 1), (0, 0))  # pad height and width dim
							# hidden_states = jnp.pad(hidden_states, pad_width=pad)
							lowerCamelCase_	:     Optional[int] 						=      self.conv(lowerCamelCase						)
							return hidden_states






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



					def   __a     (		self     :     List[str]						):
							lowerCamelCase_	:     Tuple 						=      self.in_channels if self.out_channels is None else self.out_channels

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

							lowerCamelCase_	:     Tuple 						=      nn.Dense(lowerCamelCase       ,      dtype=self.dtype						)

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

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

							lowerCamelCase_	:     Any 						=      None
							if use_nin_shortcut:
									lowerCamelCase_	:     List[Any] 						=      nn.Conv(
									    lowerCamelCase       ,      kernel_size=(1, 1)       ,      strides=(1, 1)       ,      padding='VALID'       ,      dtype=self.dtype       ,      )





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

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

							lowerCamelCase_	:     Union[str, Any] 						=      self.norma(lowerCamelCase						)
							lowerCamelCase_	:     List[Any] 						=      nn.swish(lowerCamelCase						)
							lowerCamelCase_	:     Optional[int] 						=      self.dropout(lowerCamelCase       ,      lowerCamelCase						)
							lowerCamelCase_	:     Tuple 						=      self.conva(lowerCamelCase						)

							if self.conv_shortcut is not None:
									lowerCamelCase_	:     Any 						=      self.conv_shortcut(lowerCamelCase						)

							return hidden_states + residual







_lowercase		:  Optional[Any]			       ="""
# Transformers installation
! pip install transformers datasets
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/transformers.git
"""

_lowercase		:  Union[str, Any]			       =[{"""type""": """code""", """content""": INSTALL_CONTENT}]
_lowercase		:  List[Any]			       ={
    """{processor_class}""": """FakeProcessorClass""",
    """{model_class}""": """FakeModelClass""",
    """{object_class}""": """FakeObjectClass""",
}
