

'''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 							A__    (       nn.Module  ):
  A__		 =				42
  A__		 =				42
  A__		 =				0.0
  A__		 =				1
  A__		 =				1
  A__		 =				True
  A__		 =				False
  A__		 =				False
  A__		 =				False
  A__		 =				jnp.floataa





  def 						A  (		self      :	str )	->    List[str]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =[]
       _SCREAMING_SNAKE_CASE							    =[]

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

            _SCREAMING_SNAKE_CASE							    =FlaxResnetBlockaD(
                in_channels=_a							,					out_channels=self.out_channels							,					dropout_prob=self.dropout							,					dtype=self.dtype							,					)
            resnets.append(_a )

            _SCREAMING_SNAKE_CASE							    =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(_a )

       _SCREAMING_SNAKE_CASE							    =resnets
       _SCREAMING_SNAKE_CASE							    =attentions

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





  def __call__(		self      :	Dict							,					_a      :	Union[str, Any]							,					_a      :	Union[str, Any]							,					_a      :	str							,					_a      :	Optional[Any]=True )	->    List[Any]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =()

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

       if self.add_downsample:
            _SCREAMING_SNAKE_CASE							    =self.downsamplers_a(_a )
            output_states += (hidden_states,)

       return hidden_states, output_states







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





  def 						A  (		self      :	Dict )	->    Union[str, Any]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =[]

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

            _SCREAMING_SNAKE_CASE							    =FlaxResnetBlockaD(
                in_channels=_a							,					out_channels=self.out_channels							,					dropout_prob=self.dropout							,					dtype=self.dtype							,					)
            resnets.append(_a )
       _SCREAMING_SNAKE_CASE							    =resnets

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





  def __call__(		self      :	Dict							,					_a      :	int							,					_a      :	Tuple							,					_a      :	Union[str, Any]=True )	->    int:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =()

       for resnet in self.resnets:
            _SCREAMING_SNAKE_CASE							    =resnet(_a							,					_a							,					deterministic=_a )
            output_states += (hidden_states,)

       if self.add_downsample:
            _SCREAMING_SNAKE_CASE							    =self.downsamplers_a(_a )
            output_states += (hidden_states,)

       return hidden_states, output_states







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





  def 						A  (		self      :	int )	->    Dict:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =[]
       _SCREAMING_SNAKE_CASE							    =[]

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

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

            _SCREAMING_SNAKE_CASE							    =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(_a )

       _SCREAMING_SNAKE_CASE							    =resnets
       _SCREAMING_SNAKE_CASE							    =attentions

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





  def __call__(		self      :	Optional[Any]							,					_a      :	Optional[Any]							,					_a      :	Dict							,					_a      :	Union[str, Any]							,					_a      :	str							,					_a      :	List[str]=True )	->    int:





       '''simple docstring'''






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

            _SCREAMING_SNAKE_CASE							    =resnet(_a							,					_a							,					deterministic=_a )
            _SCREAMING_SNAKE_CASE							    =attn(_a							,					_a							,					deterministic=_a )

       if self.add_upsample:
            _SCREAMING_SNAKE_CASE							    =self.upsamplers_a(_a )

       return hidden_states







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





  def 						A  (		self      :	Optional[int] )	->    Union[str, Any]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =[]

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

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

       _SCREAMING_SNAKE_CASE							    =resnets

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





  def __call__(		self      :	str							,					_a      :	Dict							,					_a      :	Dict							,					_a      :	Optional[Any]							,					_a      :	str=True )	->    Optional[int]:





       '''simple docstring'''






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

            _SCREAMING_SNAKE_CASE							    =resnet(_a							,					_a							,					deterministic=_a )

       if self.add_upsample:
            _SCREAMING_SNAKE_CASE							    =self.upsamplers_a(_a )

       return hidden_states







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





  def 						A  (		self      :	List[str] )	->    Any:





       '''simple docstring'''






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

       _SCREAMING_SNAKE_CASE							    =[]

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

            _SCREAMING_SNAKE_CASE							    =FlaxResnetBlockaD(
                in_channels=self.in_channels							,					out_channels=self.in_channels							,					dropout_prob=self.dropout							,					dtype=self.dtype							,					)
            resnets.append(_a )

       _SCREAMING_SNAKE_CASE							    =resnets
       _SCREAMING_SNAKE_CASE							    =attentions





  def __call__(		self      :	Union[str, Any]							,					_a      :	List[Any]							,					_a      :	Tuple							,					_a      :	Optional[Any]							,					_a      :	str=True )	->    Union[str, Any]:





       '''simple docstring'''






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

       return hidden_states




'''simple docstring'''






from math import ceil







def 				UpperCamelCase_			(    A__					:   int = 10_01					):
  '''simple docstring'''





  lowerCAmelCase_			:      List[Any]			=   1

  for i in range(1							,    int(ceil(n / 2.0					)					)					):
    lowerCAmelCase_			:      int			=   2 * i + 1
    lowerCAmelCase_			:      Tuple			=   2 * i
    lowerCAmelCase_			:      Tuple			=   total + 4 * odd**2 - 6 * even

  return total


if __name__ == "__main__":
  import sys

  if len(sys.argv) == 1:
    print(solution())
  else:
    try:
      __A					:  str											=      int(sys.argv[1])
      print(solution(n))
    except ValueError:
      print("Invalid entry - please enter a number")



