



"""simple docstring"""
import flax.linen as nn
import jax
import jax.numpy as jnp



class       SCREAMING_SNAKE_CASE__  (					nn.Module ):
   __lowerCAmelCase  :   int
   __lowerCAmelCase  :   jnp.dtype						=						jnp.floataa

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Tuple:





    '''simple docstring'''




    UpperCAmelCase	:					List[str]	=	nn.Conv(
        self.out_channels      ,     kernel_size=(3, 3)      ,     strides=(1, 1)      ,     padding=((1, 1), (1, 1))      ,     dtype=self.dtype      ,     )




   def __call__(   self      ,     _SCREAMING_SNAKE_CASE						)  ->      Optional[Any]:





    '''simple docstring'''




    UpperCAmelCase	,		UpperCAmelCase	,		UpperCAmelCase	,		UpperCAmelCase	:					Dict	=	hidden_states.shape
    UpperCAmelCase	:					str	=	jax.image.resize(
        _SCREAMING_SNAKE_CASE      ,     shape=(batch, height * 2, width * 2, channels)      ,     method="""nearest"""      ,     )
    UpperCAmelCase	:					Optional[int]	=	self.conv(_SCREAMING_SNAKE_CASE						)
    return hidden_states



class       SCREAMING_SNAKE_CASE__  (					nn.Module ):
   __lowerCAmelCase  :   int
   __lowerCAmelCase  :   jnp.dtype						=						jnp.floataa

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





    '''simple docstring'''




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




   def __call__(   self      ,     _SCREAMING_SNAKE_CASE						)  ->      Any:





    '''simple docstring'''




    UpperCAmelCase	:					Any	=	self.conv(_SCREAMING_SNAKE_CASE						)
    return hidden_states



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

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





    '''simple docstring'''




    UpperCAmelCase	:					Optional[Any]	=	self.in_channels if self.out_channels is None else self.out_channels

    UpperCAmelCase	:					Any	=	nn.GroupNorm(num_groups=32      ,     epsilon=1E-5						)
    UpperCAmelCase	:					Optional[Any]	=	nn.Conv(
        _SCREAMING_SNAKE_CASE      ,     kernel_size=(3, 3)      ,     strides=(1, 1)      ,     padding=((1, 1), (1, 1))      ,     dtype=self.dtype      ,     )

    UpperCAmelCase	:					str	=	nn.Dense(_SCREAMING_SNAKE_CASE      ,     dtype=self.dtype						)

    UpperCAmelCase	:					str	=	nn.GroupNorm(num_groups=32      ,     epsilon=1E-5						)
    UpperCAmelCase	:					List[str]	=	nn.Dropout(self.dropout_prob						)
    UpperCAmelCase	:					str	=	nn.Conv(
        _SCREAMING_SNAKE_CASE      ,     kernel_size=(3, 3)      ,     strides=(1, 1)      ,     padding=((1, 1), (1, 1))      ,     dtype=self.dtype      ,     )

    UpperCAmelCase	:					Tuple	=	self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

    UpperCAmelCase	:					Dict	=	None
    if use_nin_shortcut:
     UpperCAmelCase	:					str	=	nn.Conv(
         _SCREAMING_SNAKE_CASE      ,     kernel_size=(1, 1)      ,     strides=(1, 1)      ,     padding="""VALID"""      ,     dtype=self.dtype      ,     )




   def __call__(   self      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE=True						)  ->      List[Any]:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	hidden_states
    UpperCAmelCase	:					Dict	=	self.norma(_SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					Tuple	=	nn.swish(_SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					Optional[int]	=	self.conva(_SCREAMING_SNAKE_CASE						)

    UpperCAmelCase	:					str	=	self.time_emb_proj(nn.swish(_SCREAMING_SNAKE_CASE						)						)
    UpperCAmelCase	:					Optional[int]	=	jnp.expand_dims(jnp.expand_dims(_SCREAMING_SNAKE_CASE      ,     1						)      ,     1						)
    UpperCAmelCase	:					Union[str, Any]	=	hidden_states + temb

    UpperCAmelCase	:					Any	=	self.norma(_SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					Union[str, Any]	=	nn.swish(_SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					int	=	self.dropout(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					Tuple	=	self.conva(_SCREAMING_SNAKE_CASE						)

    if self.conv_shortcut is not None:
     UpperCAmelCase	:					Dict	=	self.conv_shortcut(_SCREAMING_SNAKE_CASE						)

    return hidden_states + residual





"""simple docstring"""
from __future__ import annotations



class       SCREAMING_SNAKE_CASE__  :

   def __init__(   self      ,     _SCREAMING_SNAKE_CASE						)  ->      None:





    '''simple docstring'''




    UpperCAmelCase	:					Any	=	data
    UpperCAmelCase	:					Node | None	=	None
    UpperCAmelCase	:					Node | None	=	None

def       _snake_case						(						UpperCamelCase						:		Node | None						):  # In Order traversal of the tree
 if tree:
  display(tree.left						)
  print(tree.data						)
  display(tree.right						)

def       _snake_case						(						UpperCamelCase						:		Node | None						):
 return 1 + max(depth_of_tree(tree.left						)			,		depth_of_tree(tree.right						)						) if tree else 0

def       _snake_case						(						UpperCamelCase						:		Node						):
 if not tree:
  return True
 if tree.left and tree.right:
  return is_full_binary_tree(tree.left						) and is_full_binary_tree(tree.right						)
 else:
  return not tree.left and not tree.right

def       _snake_case						(						):  # Main function for testing.
 UpperCAmelCase	:					int	=	Node(1						)
 UpperCAmelCase	:					Tuple	=	Node(2						)
 UpperCAmelCase	:					Any	=	Node(3						)
 UpperCAmelCase	:					Optional[int]	=	Node(4						)
 UpperCAmelCase	:					Any	=	Node(5						)
 UpperCAmelCase	:					Optional[int]	=	Node(6						)
 UpperCAmelCase	:					int	=	Node(7						)
 UpperCAmelCase	:					str	=	Node(8						)
 UpperCAmelCase	:					str	=	Node(9						)

 print(is_full_binary_tree(UpperCamelCase						)						)
 print(depth_of_tree(UpperCamelCase						)						)
 print("""Tree is: """						)
 display(UpperCamelCase						)


if __name__ == "__main__":
      main()
