





import heapq as hq
import math
from collections.abc import Iterator







class __a :





   def __init__(					self				:			Tuple				,lowerCamelCase				:			int    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       str(id_    )
      __SCREAMING_SNAKE_CASE      							=       None
      __SCREAMING_SNAKE_CASE      							=       None
      __SCREAMING_SNAKE_CASE      							=       []
      __SCREAMING_SNAKE_CASE      							=       {}  # {vertex:distance}





   def __lt__(					self				:			Dict				,lowerCamelCase				:			List[str]    ):

      '''simple docstring'''

      return self.key < other.key





   def __repr__(					self				:			List[str]    ):

      '''simple docstring'''

      return self.id





   def      UpperCAmelCase__     (					self				:			List[str]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      self.neighbors.append(lowerCamelCase    )





   def      UpperCAmelCase__     (					self				:			List[Any]				,lowerCamelCase				:			Optional[int]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       weight





def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )						->					Optional[int]:

   '''simple docstring'''







   graph[a - 1].add_neighbor(graph[b - 1]      )
   graph[b - 1].add_neighbor(graph[a - 1]      )
   # add the edges:
   graph[a - 1].add_edge(graph[b - 1]							,	__SCREAMING_SNAKE_CASE      )
   graph[b - 1].add_edge(graph[a - 1]							,	__SCREAMING_SNAKE_CASE      )

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					list:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       []
   for u in graph:
      __SCREAMING_SNAKE_CASE      							=       math.inf
      __SCREAMING_SNAKE_CASE      							=       None
   __SCREAMING_SNAKE_CASE      							=       0
   __SCREAMING_SNAKE_CASE      							=       graph[:]
   while q:
      __SCREAMING_SNAKE_CASE      							=       min(__SCREAMING_SNAKE_CASE      )
      q.remove(__SCREAMING_SNAKE_CASE      )
      for v in u.neighbors:
         if (v in q) and (u.edges[v.id] < v.key):
            __SCREAMING_SNAKE_CASE      							=       u
            __SCREAMING_SNAKE_CASE      							=       u.edges[v.id]
   for i in range(1							,	len(__SCREAMING_SNAKE_CASE      )      ):
      a.append((int(graph[i].id      ) + 1, int(graph[i].pi.id      ) + 1)      )
   return a

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Iterator[tuple]:

   '''simple docstring'''







   for u in graph:
      __SCREAMING_SNAKE_CASE      							=       math.inf
      __SCREAMING_SNAKE_CASE      							=       None
   __SCREAMING_SNAKE_CASE      							=       0

   __SCREAMING_SNAKE_CASE      							=       list(__SCREAMING_SNAKE_CASE      )
   hq.heapify(__SCREAMING_SNAKE_CASE      )

   while h:
      __SCREAMING_SNAKE_CASE      							=       hq.heappop(__SCREAMING_SNAKE_CASE      )
      for v in u.neighbors:
         if (v in h) and (u.edges[v.id] < v.key):
            __SCREAMING_SNAKE_CASE      							=       u
            __SCREAMING_SNAKE_CASE      							=       u.edges[v.id]
            hq.heapify(__SCREAMING_SNAKE_CASE      )

   for i in range(1							,	len(__SCREAMING_SNAKE_CASE      )      ):
      yield (int(graph[i].id      ) + 1, int(graph[i].pi.id      ) + 1)

def 						__magic_name__       (							)						->					None:

   '''simple docstring'''







   pass


if __name__ == "__main__":
    import doctest

    doctest.testmod()












'''simple docstring'''

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







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       nn.Conv(
          self.out_channels				,kernel_size=(3, 3)				,strides=(1, 1)				,padding=((1, 1), (1, 1))				,dtype=self.dtype				,)





   def __call__(					self				:			List[Any]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       hidden_states.shape
      __SCREAMING_SNAKE_CASE      							=       jax.image.resize(
          lowerCamelCase				,shape=(batch, height * 2, width * 2, channels)				,method="""nearest"""				,)
      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







class __a (   nn.Module			):
   __UpperCamelCase   : int
   __UpperCamelCase   : jnp.dtype	      =	jnp.floataa





   def      UpperCAmelCase__     (					self				:			Optional[int]    ):

      '''simple docstring'''

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





   def __call__(					self				:			List[str]				,lowerCamelCase				:			Tuple    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.conv(lowerCamelCase    )
      return hidden_states







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





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

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       self.in_channels if self.out_channels is None else self.out_channels

      __SCREAMING_SNAKE_CASE      							=       nn.GroupNorm(num_groups=32				,epsilon=1E-5    )
      __SCREAMING_SNAKE_CASE      							=       nn.Conv(
          lowerCamelCase				,kernel_size=(3, 3)				,strides=(1, 1)				,padding=((1, 1), (1, 1))				,dtype=self.dtype				,)

      __SCREAMING_SNAKE_CASE      							=       nn.Dense(lowerCamelCase				,dtype=self.dtype    )

      __SCREAMING_SNAKE_CASE      							=       nn.GroupNorm(num_groups=32				,epsilon=1E-5    )
      __SCREAMING_SNAKE_CASE      							=       nn.Dropout(self.dropout_prob    )
      __SCREAMING_SNAKE_CASE      							=       nn.Conv(
          lowerCamelCase				,kernel_size=(3, 3)				,strides=(1, 1)				,padding=((1, 1), (1, 1))				,dtype=self.dtype				,)

      __SCREAMING_SNAKE_CASE      							=       self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

      __SCREAMING_SNAKE_CASE      							=       None
      if use_nin_shortcut:
         __SCREAMING_SNAKE_CASE      							=       nn.Conv(
             lowerCamelCase				,kernel_size=(1, 1)				,strides=(1, 1)				,padding="""VALID"""				,dtype=self.dtype				,)





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

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       hidden_states
      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE      							=       self.time_emb_proj(nn.swish(lowerCamelCase    )    )
      __SCREAMING_SNAKE_CASE      							=       jnp.expand_dims(jnp.expand_dims(lowerCamelCase				,1    )				,1    )
      __SCREAMING_SNAKE_CASE      							=       hidden_states + temb

      __SCREAMING_SNAKE_CASE      							=       self.norma(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       nn.swish(lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.dropout(lowerCamelCase				,lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       self.conva(lowerCamelCase    )

      if self.conv_shortcut is not None:
         __SCREAMING_SNAKE_CASE      							=       self.conv_shortcut(lowerCamelCase    )

      return hidden_states + residual





