





"""simple docstring"""





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

from .attention_flax import FlaxTransformeraDModel
from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD

class 		lowercase					(					nn.Module					):
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      0.0
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      True
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      jnp.floataa





      def     _snake_case			(       self )		->     Tuple:
            lowerCAmelCase  						=       []
            lowerCAmelCase  						=       []

            for i in range(self.num_layers ):
                  lowerCAmelCase  						=       self.in_channels if i == 0 else self.out_channels

                  lowerCAmelCase  						=       FlaxResnetBlockaD(
                      in_channels=lowercase      ,						out_channels=self.out_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
                  resnets.append(lowercase )

                  lowerCAmelCase  						=       FlaxTransformeraDModel(
                      in_channels=self.out_channels      ,						n_heads=self.num_attention_heads      ,						d_head=self.out_channels // self.num_attention_heads      ,						depth=1      ,						use_linear_projection=self.use_linear_projection      ,						only_cross_attention=self.only_cross_attention      ,						use_memory_efficient_attention=self.use_memory_efficient_attention      ,						dtype=self.dtype      ,						)
                  attentions.append(lowercase )

            lowerCAmelCase  						=       resnets
            lowerCAmelCase  						=       attentions

            if self.add_downsample:
                  lowerCAmelCase  						=       FlaxDownsampleaD(self.out_channels      ,						dtype=self.dtype )





      def __call__(       self      ,						lowercase      ,						lowercase      ,						lowercase      ,						lowercase=True )		->     Optional[Any]:
            lowerCAmelCase  						=       ()

            for resnet, attn in zip(self.resnets      ,						self.attentions ):
                  lowerCAmelCase  						=       resnet(lowercase      ,						lowercase      ,						deterministic=lowercase )
                  lowerCAmelCase  						=       attn(lowercase      ,						lowercase      ,						deterministic=lowercase )
                  output_states += (hidden_states,)

            if self.add_downsample:
                  lowerCAmelCase  						=       self.downsamplers_a(lowercase )
                  output_states += (hidden_states,)

            return hidden_states, output_states







class 		lowercase					(					nn.Module					):
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      0.0
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      True
      _SCREAMING_SNAKE_CASE					=      jnp.floataa





      def     _snake_case			(       self )		->     Optional[Any]:
            lowerCAmelCase  						=       []

            for i in range(self.num_layers ):
                  lowerCAmelCase  						=       self.in_channels if i == 0 else self.out_channels

                  lowerCAmelCase  						=       FlaxResnetBlockaD(
                      in_channels=lowercase      ,						out_channels=self.out_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
                  resnets.append(lowercase )
            lowerCAmelCase  						=       resnets

            if self.add_downsample:
                  lowerCAmelCase  						=       FlaxDownsampleaD(self.out_channels      ,						dtype=self.dtype )





      def __call__(       self      ,						lowercase      ,						lowercase      ,						lowercase=True )		->     Tuple:
            lowerCAmelCase  						=       ()

            for resnet in self.resnets:
                  lowerCAmelCase  						=       resnet(lowercase      ,						lowercase      ,						deterministic=lowercase )
                  output_states += (hidden_states,)

            if self.add_downsample:
                  lowerCAmelCase  						=       self.downsamplers_a(lowercase )
                  output_states += (hidden_states,)

            return hidden_states, output_states







class 		lowercase					(					nn.Module					):
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      0.0
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      True
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      jnp.floataa





      def     _snake_case			(       self )		->     Tuple:
            lowerCAmelCase  						=       []
            lowerCAmelCase  						=       []

            for i in range(self.num_layers ):
                  lowerCAmelCase  						=       self.in_channels if (i == self.num_layers - 1) else self.out_channels
                  lowerCAmelCase  						=       self.prev_output_channel if i == 0 else self.out_channels

                  lowerCAmelCase  						=       FlaxResnetBlockaD(
                      in_channels=resnet_in_channels + res_skip_channels      ,						out_channels=self.out_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
                  resnets.append(lowercase )

                  lowerCAmelCase  						=       FlaxTransformeraDModel(
                      in_channels=self.out_channels      ,						n_heads=self.num_attention_heads      ,						d_head=self.out_channels // self.num_attention_heads      ,						depth=1      ,						use_linear_projection=self.use_linear_projection      ,						only_cross_attention=self.only_cross_attention      ,						use_memory_efficient_attention=self.use_memory_efficient_attention      ,						dtype=self.dtype      ,						)
                  attentions.append(lowercase )

            lowerCAmelCase  						=       resnets
            lowerCAmelCase  						=       attentions

            if self.add_upsample:
                  lowerCAmelCase  						=       FlaxUpsampleaD(self.out_channels      ,						dtype=self.dtype )





      def __call__(       self      ,						lowercase      ,						lowercase      ,						lowercase      ,						lowercase      ,						lowercase=True )		->     Any:
            for resnet, attn in zip(self.resnets      ,						self.attentions ):
                  # pop res hidden states
                  lowerCAmelCase  						=       res_hidden_states_tuple[-1]
                  lowerCAmelCase  						=       res_hidden_states_tuple[:-1]
                  lowerCAmelCase  						=       jnp.concatenate((hidden_states, res_hidden_states)      ,						axis=-1 )

                  lowerCAmelCase  						=       resnet(lowercase      ,						lowercase      ,						deterministic=lowercase )
                  lowerCAmelCase  						=       attn(lowercase      ,						lowercase      ,						deterministic=lowercase )

            if self.add_upsample:
                  lowerCAmelCase  						=       self.upsamplers_a(lowercase )

            return hidden_states







class 		lowercase					(					nn.Module					):
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      0.0
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      True
      _SCREAMING_SNAKE_CASE					=      jnp.floataa





      def     _snake_case			(       self )		->     Any:
            lowerCAmelCase  						=       []

            for i in range(self.num_layers ):
                  lowerCAmelCase  						=       self.in_channels if (i == self.num_layers - 1) else self.out_channels
                  lowerCAmelCase  						=       self.prev_output_channel if i == 0 else self.out_channels

                  lowerCAmelCase  						=       FlaxResnetBlockaD(
                      in_channels=resnet_in_channels + res_skip_channels      ,						out_channels=self.out_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
                  resnets.append(lowercase )

            lowerCAmelCase  						=       resnets

            if self.add_upsample:
                  lowerCAmelCase  						=       FlaxUpsampleaD(self.out_channels      ,						dtype=self.dtype )





      def __call__(       self      ,						lowercase      ,						lowercase      ,						lowercase      ,						lowercase=True )		->     str:
            for resnet in self.resnets:
                  # pop res hidden states
                  lowerCAmelCase  						=       res_hidden_states_tuple[-1]
                  lowerCAmelCase  						=       res_hidden_states_tuple[:-1]
                  lowerCAmelCase  						=       jnp.concatenate((hidden_states, res_hidden_states)      ,						axis=-1 )

                  lowerCAmelCase  						=       resnet(lowercase      ,						lowercase      ,						deterministic=lowercase )

            if self.add_upsample:
                  lowerCAmelCase  						=       self.upsamplers_a(lowercase )

            return hidden_states







class 		lowercase					(					nn.Module					):
      _SCREAMING_SNAKE_CASE					=      42
      _SCREAMING_SNAKE_CASE					=      0.0
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      1
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      False
      _SCREAMING_SNAKE_CASE					=      jnp.floataa





      def     _snake_case			(       self )		->     Any:
            # there is always at least one resnet
            lowerCAmelCase  						=       [
                FlaxResnetBlockaD(
                    in_channels=self.in_channels      ,						out_channels=self.in_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
            ]

            lowerCAmelCase  						=       []

            for _ in range(self.num_layers ):
                  lowerCAmelCase  						=       FlaxTransformeraDModel(
                      in_channels=self.in_channels      ,						n_heads=self.num_attention_heads      ,						d_head=self.in_channels // self.num_attention_heads      ,						depth=1      ,						use_linear_projection=self.use_linear_projection      ,						use_memory_efficient_attention=self.use_memory_efficient_attention      ,						dtype=self.dtype      ,						)
                  attentions.append(lowercase )

                  lowerCAmelCase  						=       FlaxResnetBlockaD(
                      in_channels=self.in_channels      ,						out_channels=self.in_channels      ,						dropout_prob=self.dropout      ,						dtype=self.dtype      ,						)
                  resnets.append(lowercase )

            lowerCAmelCase  						=       resnets
            lowerCAmelCase  						=       attentions





      def __call__(       self      ,						lowercase      ,						lowercase      ,						lowercase      ,						lowercase=True )		->     Optional[int]:
            lowerCAmelCase  						=       self.resnets[0](lowercase      ,						lowercase )
            for attn, resnet in zip(self.attentions      ,						self.resnets[1:] ):
                  lowerCAmelCase  						=       attn(lowercase      ,						lowercase      ,						deterministic=lowercase )
                  lowerCAmelCase  						=       resnet(lowercase      ,						lowercase      ,						deterministic=lowercase )

            return hidden_states













"""simple docstring"""





SCREAMING_SNAKE_CASE__					=   {
    "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.",
    "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.",
    "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-",
    "V": "...-", "W": ".--", "X": "-..-", "Y": "-.--", "Z": "--..", "1": ".----",
    "2": "..---", "3": "...--", "4": "....-", "5": ".....", "6": "-....", "7": "--...",
    "8": "---..", "9": "----.", "0": "-----", "&": ".-...", "@": ".--.-.",
    ":": "---...", ",": "--..--", ".": ".-.-.-", "'": ".----.", "\"": ".-..-.",
    "?": "..--..", "/": "-..-.", "=": "-...-", "+": ".-.-.", "-": "-....-",
    "(": "-.--.", ")": "-.--.-", "!": "-.-.--", " ": "/"
}  # Exclamation mark is not in ITU-R recommendation
# fmt: on
SCREAMING_SNAKE_CASE__					=   {value: key for key, value in MORSE_CODE_DICT.items()}


def 			UpperCAmelCase__							(  SCREAMING_SNAKE_CASE     :						str			):







      '''simple docstring'''




      return " ".join(MORSE_CODE_DICT[char] for char in message.upper()			)


def 			UpperCAmelCase__							(  SCREAMING_SNAKE_CASE     :						str			):







      '''simple docstring'''




      return "".join(REVERSE_DICT[char] for char in message.split()			)


def 			UpperCAmelCase__							(  ):







      '''simple docstring'''




      lowerCAmelCase  						=       """Morse code here!"""
      print(SCREAMING_SNAKE_CASE			)
      lowerCAmelCase  						=       encrypt(SCREAMING_SNAKE_CASE			)
      print(SCREAMING_SNAKE_CASE			)
      lowerCAmelCase  						=       decrypt(SCREAMING_SNAKE_CASE			)
      print(SCREAMING_SNAKE_CASE			)


if __name__ == "__main__":
       main()






