



'''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 				__lowerCamelCase     (							self  :  Tuple):







											'''simple docstring'''

											__lowercase       	=nn.Conv(
											    self.out_channels  ,       kernel_size=(3, 3)  ,       strides=(1, 1)  ,       padding=((1, 1), (1, 1))  ,       dtype=self.dtype  ,       )

				def __call__(							self  :  Dict  ,       _lowerCAmelCase  :  int):







											'''simple docstring'''

											__lowercase	,				__lowercase	,				__lowercase	,				__lowercase       	=hidden_states.shape
											__lowercase       	=jax.image.resize(
											    _lowerCAmelCase  ,       shape=(batch, height * 2, width * 2, channels)  ,       method='nearest'  ,       )
											__lowercase       	=self.conv(_lowerCAmelCase)
											return hidden_states





class _UpperCamelCase		(     nn.Module		):





				'''simple docstring'''





				lowerCAmelCase__					    =    42
				lowerCAmelCase__					    =    jnp.floataa

				def 				__lowerCamelCase     (							self  :  Tuple):







											'''simple docstring'''

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

				def __call__(							self  :  str  ,       _lowerCAmelCase  :  Optional[Any]):







											'''simple docstring'''

											__lowercase       	=self.conv(_lowerCAmelCase)
											return hidden_states





class _UpperCamelCase		(     nn.Module		):





				'''simple docstring'''





				lowerCAmelCase__					    =    42
				lowerCAmelCase__					    =    None
				lowerCAmelCase__					    =    0.0
				lowerCAmelCase__					    =    None
				lowerCAmelCase__					    =    jnp.floataa

				def 				__lowerCamelCase     (							self  :  Any):







											'''simple docstring'''

											__lowercase       	=self.in_channels if self.out_channels is None else self.out_channels

											__lowercase       	=nn.GroupNorm(num_groups=3_2  ,       epsilon=1e-5)
											__lowercase       	=nn.Conv(
											    _lowerCAmelCase  ,       kernel_size=(3, 3)  ,       strides=(1, 1)  ,       padding=((1, 1), (1, 1))  ,       dtype=self.dtype  ,       )

											__lowercase       	=nn.Dense(_lowerCAmelCase  ,       dtype=self.dtype)

											__lowercase       	=nn.GroupNorm(num_groups=3_2  ,       epsilon=1e-5)
											__lowercase       	=nn.Dropout(self.dropout_prob)
											__lowercase       	=nn.Conv(
											    _lowerCAmelCase  ,       kernel_size=(3, 3)  ,       strides=(1, 1)  ,       padding=((1, 1), (1, 1))  ,       dtype=self.dtype  ,       )

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

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

				def __call__(							self  :  int  ,       _lowerCAmelCase  :  int  ,       _lowerCAmelCase  :  Optional[int]  ,       _lowerCAmelCase  :  Optional[Any]=True):







											'''simple docstring'''

											__lowercase       	=hidden_states
											__lowercase       	=self.norma(_lowerCAmelCase)
											__lowercase       	=nn.swish(_lowerCAmelCase)
											__lowercase       	=self.conva(_lowerCAmelCase)

											__lowercase       	=self.time_emb_proj(nn.swish(_lowerCAmelCase))
											__lowercase       	=jnp.expand_dims(jnp.expand_dims(_lowerCAmelCase  ,       1)  ,       1)
											__lowercase       	=hidden_states + temb

											__lowercase       	=self.norma(_lowerCAmelCase)
											__lowercase       	=nn.swish(_lowerCAmelCase)
											__lowercase       	=self.dropout(_lowerCAmelCase  ,       _lowerCAmelCase)
											__lowercase       	=self.conva(_lowerCAmelCase)

											if self.conv_shortcut is not None:
																		__lowercase       	=self.conv_shortcut(_lowerCAmelCase)

											return hidden_states + residual








'''simple docstring'''



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							if number > 0:
														raise ValueError('input must be a negative integer'					)
							__lowercase       	=len(bin(_lowerCAmelCase					)[3:]					)
							__lowercase       	=bin(abs(_lowerCAmelCase					) - (1 << binary_number_length)					)[3:]
							__lowercase       	=(
							    (
							        '1'
							        + '0' * (binary_number_length - len(_lowerCAmelCase					))
							        + twos_complement_number
							    )
							    if number < 0
							    else '0'
							)
							return "0b" + twos_complement_number


if __name__ == "__main__":
		import doctest

		doctest.testmod()



