
'''simple docstring'''

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


class  _UpperCAmelCase ( nn.Module    ):

     """simple docstring"""

     a_    	=					42
     a_    	=					jnp.floataa


     def 							_lowerCAmelCase  (      self ):

       '''simple docstring'''

       a_      :	Any      =							nn.Conv(
           self.out_channels							,		kernel_size=(3, 3)							,		strides=(1, 1)							,		padding=((1, 1), (1, 1))							,		dtype=self.dtype							,		)






     def __call__(      self							,		lowerCAmelCase_ ):

       '''simple docstring'''

       a_      , a_      , a_      , a_      :	Union[str, Any]      =							hidden_states.shape
       a_      :	Tuple      =							jax.image.resize(
           lowerCAmelCase_							,		shape=(batch, height * 2, width * 2, channels)							,		method="""nearest"""							,		)
       a_      :	Tuple      =							self.conv(lowerCAmelCase_ )
       return hidden_states







class  _UpperCAmelCase ( nn.Module    ):

     """simple docstring"""

     a_    	=					42
     a_    	=					jnp.floataa


     def 							_lowerCAmelCase  (      self ):

       '''simple docstring'''

       a_      :	List[Any]      =							nn.Conv(
           self.out_channels							,		kernel_size=(3, 3)							,		strides=(2, 2)							,		padding=((1, 1), (1, 1))							,		dtype=self.dtype							,		)






     def __call__(      self							,		lowerCAmelCase_ ):

       '''simple docstring'''

       a_      :	int      =							self.conv(lowerCAmelCase_ )
       return hidden_states







class  _UpperCAmelCase ( nn.Module    ):

     """simple docstring"""

     a_    	=					42
     a_    	=					None
     a_    	=					0.0
     a_    	=					None
     a_    	=					jnp.floataa


     def 							_lowerCAmelCase  (      self ):

       '''simple docstring'''

       a_      :	Optional[int]      =							self.in_channels if self.out_channels is None else self.out_channels

       a_      :	Union[str, Any]      =							nn.GroupNorm(num_groups=32							,		epsilon=1E-5 )
       a_      :	Tuple      =							nn.Conv(
           lowerCAmelCase_							,		kernel_size=(3, 3)							,		strides=(1, 1)							,		padding=((1, 1), (1, 1))							,		dtype=self.dtype							,		)

       a_      :	Any      =							nn.Dense(lowerCAmelCase_							,		dtype=self.dtype )

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

       a_      :	Any      =							self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

       a_      :	List[str]      =							None
       if use_nin_shortcut:
         a_      :	Dict      =							nn.Conv(
             lowerCAmelCase_							,		kernel_size=(1, 1)							,		strides=(1, 1)							,		padding="""VALID"""							,		dtype=self.dtype							,		)






     def __call__(      self							,		lowerCAmelCase_							,		lowerCAmelCase_							,		lowerCAmelCase_=True ):

       '''simple docstring'''

       a_      :	int      =							hidden_states
       a_      :	Dict      =							self.norma(lowerCAmelCase_ )
       a_      :	List[Any]      =							nn.swish(lowerCAmelCase_ )
       a_      :	str      =							self.conva(lowerCAmelCase_ )

       a_      :	List[Any]      =							self.time_emb_proj(nn.swish(lowerCAmelCase_ ) )
       a_      :	Tuple      =							jnp.expand_dims(jnp.expand_dims(lowerCAmelCase_							,		1 )							,		1 )
       a_      :	List[str]      =							hidden_states + temb

       a_      :	Tuple      =							self.norma(lowerCAmelCase_ )
       a_      :	str      =							nn.swish(lowerCAmelCase_ )
       a_      :	Any      =							self.dropout(lowerCAmelCase_							,		lowerCAmelCase_ )
       a_      :	List[Any]      =							self.conva(lowerCAmelCase_ )

       if self.conv_shortcut is not None:
         a_      :	Union[str, Any]      =							self.conv_shortcut(lowerCAmelCase_ )

       return hidden_states + residual




'''simple docstring'''

def 	_snake_case						(      A_       :    Optional[int]   ):
  """simple docstring"""







  if not head:
    return True
  # split the list to two parts
  a_      , a_      :	Union[str, Any]      =							head.next, head
  while fast and fast.next:
    a_      :	Dict      =							fast.next.next
    a_      :	List[str]      =							slow.next
  a_      :	str      =							slow.next
  a_      :	Optional[int]      =							None  # Don't forget here! But forget still works!
  # reverse the second part
  a_      :	Dict      =							None
  while second:
    a_      :	Any      =							second.next
    a_      :	Any      =							node
    a_      :	Optional[Any]      =							second
    a_      :	Optional[Any]      =							nxt
  # compare two parts
  # second part has the same or one less node
  while node:
    if node.val != head.val:
      return False
    a_      :	List[str]      =							node.next
    a_      :	Dict      =							head.next
  return True






def 	_snake_case						(      A_       :    List[str]   ):
  """simple docstring"""







  if not head or not head.next:
    return True

  # 1. Get the midpoint (slow)
  a_      :	Optional[Any]      =							head
  while fast and fast.next:
    a_      , a_      :	Optional[int]      =							fast.next.next, slow.next

  # 2. Push the second half into the stack
  a_      :	List[str]      =							[slow.val]
  while slow.next:
    a_      :	List[str]      =							slow.next
    stack.append(slow.val   )

  # 3. Comparison
  while stack:
    if stack.pop() != cur.val:
      return False
    a_      :	Union[str, Any]      =							cur.next

  return True






def 	_snake_case						(      A_       :    Optional[int]   ):
  """simple docstring"""







  if not head or not head.next:
    return True
  a_      :	List[Any]      =							{}
  a_      :	int      =							0
  while head:
    if head.val in d:
      d[head.val].append(A_   )
    else:
      a_      :	int      =							[pos]
    a_      :	List[str]      =							head.next
    pos += 1
  a_      :	str      =							pos - 1
  a_      :	List[str]      =							0
  for v in d.values():
    if len(A_   ) % 2 != 0:
      middle += 1
    else:
      a_      :	Optional[int]      =							0
      for i in range(0     ,		len(A_   )   ):
        if v[i] + v[len(A_   ) - 1 - step] != checksum:
          return False
        step += 1
    if middle > 1:
      return False
  return True


