






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




class 			snake_case__   (							nn.Module):

       '''simple docstring'''
       lowerCamelCase							:				int
       lowerCamelCase							:				jnp.dtype 				= jnp.floataa



       def 					__lowercase						(							self    ) ->      int:






            '''simple docstring'''





            __snake_case			:Union[str, Any]          =						nn.Conv(
                self.out_channels			,						kernel_size=(3, 3)			,						strides=(1, 1)			,						padding=((1, 1), (1, 1))			,						dtype=self.dtype			,						)



       def __call__(							self			,						a__    ) ->      Any:






            '''simple docstring'''





            __snake_case			:Optional[Any]          =						hidden_states.shape
            __snake_case			:Optional[Any]          =						jax.image.resize(
                a__			,						shape=(batch, height * 2, width * 2, channels)			,						method="""nearest"""			,						)
            __snake_case			:Optional[int]          =						self.conv(a__    )
            return hidden_states




class 			snake_case__   (							nn.Module):

       '''simple docstring'''
       lowerCamelCase							:				int
       lowerCamelCase							:				jnp.dtype 				= jnp.floataa



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






            '''simple docstring'''





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



       def __call__(							self			,						a__    ) ->      Optional[int]:






            '''simple docstring'''





            __snake_case			:List[str]          =						self.conv(a__    )
            return hidden_states




class 			snake_case__   (							nn.Module):

       '''simple docstring'''
       lowerCamelCase							:				int
       lowerCamelCase							:				int 				= None
       lowerCamelCase							:				float 				= 0.0
       lowerCamelCase							:				bool 				= None
       lowerCamelCase							:				jnp.dtype 				= jnp.floataa



       def 					__lowercase						(							self    ) ->      List[Any]:






            '''simple docstring'''





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

            __snake_case			:Any          =						nn.GroupNorm(num_groups=32			,						epsilon=1e-5    )
            __snake_case			:Tuple          =						nn.Conv(
                a__			,						kernel_size=(3, 3)			,						strides=(1, 1)			,						padding=((1, 1), (1, 1))			,						dtype=self.dtype			,						)

            __snake_case			:Tuple          =						nn.Dense(a__			,						dtype=self.dtype    )

            __snake_case			:List[str]          =						nn.GroupNorm(num_groups=32			,						epsilon=1e-5    )
            __snake_case			:int          =						nn.Dropout(self.dropout_prob    )
            __snake_case			:Dict          =						nn.Conv(
                a__			,						kernel_size=(3, 3)			,						strides=(1, 1)			,						padding=((1, 1), (1, 1))			,						dtype=self.dtype			,						)

            __snake_case			:Optional[int]          =						self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

            __snake_case			:Optional[int]          =						None
            if use_nin_shortcut:
                 __snake_case			:Any          =						nn.Conv(
                     a__			,						kernel_size=(1, 1)			,						strides=(1, 1)			,						padding="""VALID"""			,						dtype=self.dtype			,						)



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






            '''simple docstring'''





            __snake_case			:Any          =						hidden_states
            __snake_case			:List[Any]          =						self.norma(a__    )
            __snake_case			:str          =						nn.swish(a__    )
            __snake_case			:int          =						self.conva(a__    )

            __snake_case			:Optional[Any]          =						self.time_emb_proj(nn.swish(a__    )    )
            __snake_case			:Optional[int]          =						jnp.expand_dims(jnp.expand_dims(a__			,						1    )			,						1    )
            __snake_case			:Optional[Any]          =						hidden_states + temb

            __snake_case			:Tuple          =						self.norma(a__    )
            __snake_case			:int          =						nn.swish(a__    )
            __snake_case			:Any          =						self.dropout(a__			,						a__    )
            __snake_case			:Optional[Any]          =						self.conva(a__    )

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

            return hidden_states + residual










from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass




@dataclass
class 			snake_case__   :

       '''simple docstring'''
       lowerCamelCase							:				int
       lowerCamelCase							:				int




class 			snake_case__   :

       '''simple docstring'''



       def __init__(							self			,						a__    ) ->      Any:






            '''simple docstring'''





            __snake_case			:list[list[Edge]]          =						[[] for _ in range(a__    )]
            __snake_case			:List[str]          =						size



       def __getitem__(							self			,						a__    ) ->      Iterator[Edge]:






            '''simple docstring'''





            return iter(self._graph[vertex]    )



       @property
       def 					__lowercase						(							self    ) ->      str:






            '''simple docstring'''





            return self._size



       def 					__lowercase						(							self			,						a__			,						a__			,						a__    ) ->      List[Any]:






            '''simple docstring'''





            if weight not in (0, 1):
                 raise ValueError("""Edge weight must be either 0 or 1."""    )

            if to_vertex < 0 or to_vertex >= self.size:
                 raise ValueError("""Vertex indexes must be in [0; size)."""    )

            self._graph[from_vertex].append(Edge(a__			,						a__    )    )



       def 					__lowercase						(							self			,						a__			,						a__    ) ->      int | None:






            '''simple docstring'''





            __snake_case			:Optional[Any]          =						deque([start_vertex]    )
            __snake_case			:list[int | None]          =						[None] * self.size
            __snake_case			:Tuple          =						0

            while queue:
                 __snake_case			:List[Any]          =						queue.popleft()
                 __snake_case			:Optional[Any]          =						distances[current_vertex]
                 if current_distance is None:
                      continue

                 for edge in self[current_vertex]:
                      __snake_case			:Optional[Any]          =						current_distance + edge.weight
                      __snake_case			:Dict          =						distances[edge.destination_vertex]
                      if (
                          isinstance(a__			,						a__    )
                          and new_distance >= dest_vertex_distance
                      ):
                           continue
                      __snake_case			:Dict          =						new_distance
                      if edge.weight == 0:
                           queue.appendleft(edge.destination_vertex    )
                      else:
                           queue.append(edge.destination_vertex    )

            if distances[finish_vertex] is None:
                 raise ValueError("""No path from start_vertex to finish_vertex."""    )

            return distances[finish_vertex]


if __name__ == "__main__":
     import doctest

     doctest.testmod()


