





import torch

def 						__magic_name__       (							)						->					List[Any]:

   '''simple docstring'''







   if torch.cuda.is_available():
      __SCREAMING_SNAKE_CASE      							=       torch.cuda.device_count()
   else:
      __SCREAMING_SNAKE_CASE      							=       0
   print(f"""Successfully ran on {num_gpus} GPUs"""      )


if __name__ == "__main__":
    main()












'''simple docstring'''

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







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

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





   def __call__(					self				:			List[Any]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       hidden_states.shape
      __SCREAMING_SNAKE_CASE      							=       jax.image.resize(
          lowerCamelCase				,shape=(batch, height * 2, width * 2, channels)				,method="""nearest"""				,)
      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

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





   def __call__(					self				:			List[str]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







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





   def      UpperCAmelCase__     (					self				:			Union[str, Any]    ):

      '''simple docstring'''

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

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

      __SCREAMING_SNAKE_CASE      							=       nn.Dense(lowerCamelCase				,dtype=self.dtype    )

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

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

      __SCREAMING_SNAKE_CASE      							=       None
      if use_nin_shortcut:
         __SCREAMING_SNAKE_CASE      							=       nn.Conv(
             lowerCamelCase				,kernel_size=(1, 1)				,strides=(1, 1)				,padding="""VALID"""				,dtype=self.dtype				,)





   def __call__(					self				:			List[str]				,lowerCamelCase				:			Optional[int]				,lowerCamelCase				:			Tuple				,lowerCamelCase				:			Union[str, Any]=True    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       hidden_states
      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE      							=       self.time_emb_proj(nn.swish(lowerCamelCase    )    )
      __SCREAMING_SNAKE_CASE      							=       jnp.expand_dims(jnp.expand_dims(lowerCamelCase				,1    )				,1    )
      __SCREAMING_SNAKE_CASE      							=       hidden_states + temb

      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.dropout(lowerCamelCase				,lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

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

      return hidden_states + residual





