"""simple docstring"""




import heapq as hq
import math
from collections.abc import Iterator
class     UpperCamelCase__:





						def __init__(       self		,__UpperCAmelCase     )					->				int:
													A__	     =							str(id_     )
													A__	     =							None
													A__	     =							None
													A__	     =							[]
													A__	     =							{}  # {vertex:distance}





						def __lt__(       self		,__UpperCAmelCase     )					->				Optional[int]:
													return self.key < other.key





						def __repr__(       self     )					->				Any:
													return self.id





						def 				snake_case__	(       self		,__UpperCAmelCase     )					->				Optional[Any]:
													self.neighbors.append(__UpperCAmelCase     )





						def 				snake_case__	(       self		,__UpperCAmelCase		,__UpperCAmelCase     )					->				str:
													A__	     =							weight






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__				):






							"""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]       ,    UpperCamelCase__				)
							graph[b - 1].add_edge(graph[a - 1]       ,    UpperCamelCase__				)






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__				):






							"""simple docstring"""





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






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__				):






							"""simple docstring"""





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

							A__	     =							list(UpperCamelCase__				)
							hq.heapify(UpperCamelCase__				)

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

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






def   UpperCAmelCase					(	):






							"""simple docstring"""







if __name__ == "__main__":
				import doctest

				doctest.testmod()






"""simple docstring"""




import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation
class     UpperCamelCase__(			unittest.TestCase ):





						def 				snake_case__	(       self     )					->				str:
													A__	     =							get_activation('swish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				Optional[Any]:
													A__	     =							get_activation('silu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('mish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.Mish     )

													self.assertEqual(act(torch.tensor(-2_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('gelu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.GELU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





