import flax.linen as nn
import jax
import jax.numpy as jnp
class SCREAMING_SNAKE_CASE_		(      nn.Module		):
   __lowerCAmelCase           =				42
   __lowerCAmelCase           =				jnp.floataa







   def 						lowerCamelCase_	(     self						:						str				):





    """simple docstring"""


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







   def __call__(     self						:						List[str]   ,   lowerCamelCase_						:						int				):





    """simple docstring"""


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





class SCREAMING_SNAKE_CASE_		(      nn.Module		):
   __lowerCAmelCase           =				42
   __lowerCAmelCase           =				jnp.floataa







   def 						lowerCamelCase_	(     self						:						List[Any]				):





    """simple docstring"""


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







   def __call__(     self						:						Optional[int]   ,   lowerCamelCase_						:						Any				):





    """simple docstring"""


    UpperCamelCase			  =      self.conv(lowerCamelCase_				)
    return hidden_states





class SCREAMING_SNAKE_CASE_		(      nn.Module		):
   __lowerCAmelCase           =				42
   __lowerCAmelCase           =				None
   __lowerCAmelCase           =				0.0
   __lowerCAmelCase           =				None
   __lowerCAmelCase           =				jnp.floataa







   def 						lowerCamelCase_	(     self						:						List[str]				):





    """simple docstring"""


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

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

    UpperCamelCase			  =      nn.Dense(lowerCamelCase_   ,   dtype=self.dtype				)

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

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

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







   def __call__(     self						:						Any   ,   lowerCamelCase_						:						Optional[Any]   ,   lowerCamelCase_						:						Dict   ,   lowerCamelCase_						:						Any=True				):





    """simple docstring"""


    UpperCamelCase			  =      hidden_states
    UpperCamelCase			  =      self.norma(lowerCamelCase_				)
    UpperCamelCase			  =      nn.swish(lowerCamelCase_				)
    UpperCamelCase			  =      self.conva(lowerCamelCase_				)

    UpperCamelCase			  =      self.time_emb_proj(nn.swish(lowerCamelCase_				)				)
    UpperCamelCase			  =      jnp.expand_dims(jnp.expand_dims(lowerCamelCase_   ,   1				)   ,   1				)
    UpperCamelCase			  =      hidden_states + temb

    UpperCamelCase			  =      self.norma(lowerCamelCase_				)
    UpperCamelCase			  =      nn.swish(lowerCamelCase_				)
    UpperCamelCase			  =      self.dropout(lowerCamelCase_   ,   lowerCamelCase_				)
    UpperCamelCase			  =      self.conva(lowerCamelCase_				)

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

    return hidden_states + residual

_SCREAMING_SNAKE_CASE 		=      """ABCDEFGHIJKLMNOPQRSTUVWXYZ"""





def 			lowercase(	)		->	None:







 '''simple docstring'''
 UpperCamelCase			  =      input("""Enter message: """       )
 UpperCamelCase			  =      input("""Enter key [alphanumeric]: """       )
 UpperCamelCase			  =      input("""Encrypt/Decrypt [e/d]: """       )

 if mode.lower().startswith("""e"""       ):
  UpperCamelCase			  =      """encrypt"""
  UpperCamelCase			  =      encrypt_message(UpperCamelCase_							,					UpperCamelCase_       )
 elif mode.lower().startswith("""d"""       ):
  UpperCamelCase			  =      """decrypt"""
  UpperCamelCase			  =      decrypt_message(UpperCamelCase_							,					UpperCamelCase_       )

 print(f"""\n{mode.title()}ed message:"""       )
 print(UpperCamelCase_       )





def 			lowercase(	UpperCamelCase_							,					UpperCamelCase_       )		->	str:







 '''simple docstring'''
 return translate_message(UpperCamelCase_							,					UpperCamelCase_							,					"""encrypt"""       )





def 			lowercase(	UpperCamelCase_							,					UpperCamelCase_       )		->	str:







 '''simple docstring'''
 return translate_message(UpperCamelCase_							,					UpperCamelCase_							,					"""decrypt"""       )





def 			lowercase(	UpperCamelCase_							,					UpperCamelCase_							,					UpperCamelCase_       )		->	str:







 '''simple docstring'''
 UpperCamelCase			  =      []
 UpperCamelCase			  =      0
 UpperCamelCase			  =      key.upper()

 for symbol in message:
  UpperCamelCase			  =      LETTERS.find(symbol.upper()       )
  if num != -1:
   if mode == "encrypt":
    num += LETTERS.find(key[key_index]       )
   elif mode == "decrypt":
    num -= LETTERS.find(key[key_index]       )

   num %= len(UpperCamelCase_       )

   if symbol.isupper():
    translated.append(LETTERS[num]       )
   elif symbol.islower():
    translated.append(LETTERS[num].lower()       )

   key_index += 1
   if key_index == len(UpperCamelCase_       ):
    UpperCamelCase			  =      0
  else:
   translated.append(UpperCamelCase_       )
 return "".join(UpperCamelCase_       )


if __name__ == "__main__":
     main()
