



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

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

class    _A	(     nn.Module   ):
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   float						 =						0.0
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   bool						 =						True
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   jnp.dtype						 =						jnp.floataa



       def 		_lowerCamelCase      (		self							:					str):


           '''simple docstring'''

           __a							=    []
           __a							=    []

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

               __a							=    FlaxResnetBlockaD(
                   in_channels=__SCREAMING_SNAKE_CASE					,		out_channels=self.out_channels					,		dropout_prob=self.dropout					,		dtype=self.dtype					,		)
               resnets.append(__SCREAMING_SNAKE_CASE)

               __a							=    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(__SCREAMING_SNAKE_CASE)

           __a							=    resnets
           __a							=    attentions

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





       def __call__(		self							:					Tuple					,		__SCREAMING_SNAKE_CASE							:					Dict					,		__SCREAMING_SNAKE_CASE							:					Any					,		__SCREAMING_SNAKE_CASE							:					List[str]					,		__SCREAMING_SNAKE_CASE							:					Union[str, Any]=True):


           '''simple docstring'''

           __a							=    ()

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

           if self.add_downsample:
               __a							=    self.downsamplers_a(__SCREAMING_SNAKE_CASE)
               output_states += (hidden_states,)

           return hidden_states, output_states


class    _A	(     nn.Module   ):
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   float						 =						0.0
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   bool						 =						True
       UpperCamelCase__  :   jnp.dtype						 =						jnp.floataa



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


           '''simple docstring'''

           __a							=    []

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

               __a							=    FlaxResnetBlockaD(
                   in_channels=__SCREAMING_SNAKE_CASE					,		out_channels=self.out_channels					,		dropout_prob=self.dropout					,		dtype=self.dtype					,		)
               resnets.append(__SCREAMING_SNAKE_CASE)
           __a							=    resnets

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





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


           '''simple docstring'''

           __a							=    ()

           for resnet in self.resnets:
               __a							=    resnet(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)
               output_states += (hidden_states,)

           if self.add_downsample:
               __a							=    self.downsamplers_a(__SCREAMING_SNAKE_CASE)
               output_states += (hidden_states,)

           return hidden_states, output_states


class    _A	(     nn.Module   ):
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   float						 =						0.0
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   bool						 =						True
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   jnp.dtype						 =						jnp.floataa



       def 		_lowerCamelCase      (		self							:					List[str]):


           '''simple docstring'''

           __a							=    []
           __a							=    []

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

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

               __a							=    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(__SCREAMING_SNAKE_CASE)

           __a							=    resnets
           __a							=    attentions

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





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


           '''simple docstring'''

           for resnet, attn in zip(self.resnets					,		self.attentions):
               # pop res hidden states
               __a							=    res_hidden_states_tuple[-1]
               __a							=    res_hidden_states_tuple[:-1]
               __a							=    jnp.concatenate((hidden_states, res_hidden_states)					,		axis=-1)

               __a							=    resnet(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)
               __a							=    attn(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)

           if self.add_upsample:
               __a							=    self.upsamplers_a(__SCREAMING_SNAKE_CASE)

           return hidden_states


class    _A	(     nn.Module   ):
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   int
       UpperCamelCase__  :   float						 =						0.0
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   bool						 =						True
       UpperCamelCase__  :   jnp.dtype						 =						jnp.floataa



       def 		_lowerCamelCase      (		self							:					Dict):


           '''simple docstring'''

           __a							=    []

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

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

           __a							=    resnets

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





       def __call__(		self							:					Optional[int]					,		__SCREAMING_SNAKE_CASE							:					List[str]					,		__SCREAMING_SNAKE_CASE							:					List[str]					,		__SCREAMING_SNAKE_CASE							:					int					,		__SCREAMING_SNAKE_CASE							:					Optional[int]=True):


           '''simple docstring'''

           for resnet in self.resnets:
               # pop res hidden states
               __a							=    res_hidden_states_tuple[-1]
               __a							=    res_hidden_states_tuple[:-1]
               __a							=    jnp.concatenate((hidden_states, res_hidden_states)					,		axis=-1)

               __a							=    resnet(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)

           if self.add_upsample:
               __a							=    self.upsamplers_a(__SCREAMING_SNAKE_CASE)

           return hidden_states


class    _A	(     nn.Module   ):
       UpperCamelCase__  :   int
       UpperCamelCase__  :   float						 =						0.0
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   int						 =						1
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   bool						 =						False
       UpperCamelCase__  :   jnp.dtype						 =						jnp.floataa



       def 		_lowerCamelCase      (		self							:					List[Any]):


           '''simple docstring'''

           __a							=    [
               FlaxResnetBlockaD(
                   in_channels=self.in_channels					,		out_channels=self.in_channels					,		dropout_prob=self.dropout					,		dtype=self.dtype					,		)
           ]

           __a							=    []

           for _ in range(self.num_layers):
               __a							=    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(__SCREAMING_SNAKE_CASE)

               __a							=    FlaxResnetBlockaD(
                   in_channels=self.in_channels					,		out_channels=self.in_channels					,		dropout_prob=self.dropout					,		dtype=self.dtype					,		)
               resnets.append(__SCREAMING_SNAKE_CASE)

           __a							=    resnets
           __a							=    attentions





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


           '''simple docstring'''

           __a							=    self.resnets[0](__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE)
           for attn, resnet in zip(self.attentions					,		self.resnets[1:]):
               __a							=    attn(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)
               __a							=    resnet(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE					,		deterministic=__SCREAMING_SNAKE_CASE)

           return hidden_states








def 					__snake_case     (      _UpperCAmelCase       ,			_UpperCAmelCase    ):
    return base * power(_UpperCAmelCase       ,			(exponent - 1)    ) if exponent else 1


if __name__ == "__main__":
 print('''Raise base to the power of exponent using recursion...''')
 __snake_case						:List[Any]						=					int(input('''Enter the base: ''').strip())
 __snake_case						:Dict						=					int(input('''Enter the exponent: ''').strip())
 __snake_case						:int						=					power(base, abs(exponent))
 if exponent < 0:  # power() does not properly deal w/ negative exponents
  __snake_case						:Optional[Any]						=					1 / result
 print(f'{base} to the power of {exponent} is {result}')





