


"""simple docstring"""




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




		'''simple docstring'''







		def __init__(      self		,			lowerCAmelCase__							)	->				List[Any]:
								SCREAMING_SNAKE_CASE						=   str(id_							)
								SCREAMING_SNAKE_CASE						=   None
								SCREAMING_SNAKE_CASE						=   None
								SCREAMING_SNAKE_CASE						=   []
								SCREAMING_SNAKE_CASE						=   {}  # {vertex:distance}







		def __lt__(      self		,			lowerCAmelCase__							)	->				Union[str, Any]:
								return self.key < other.key







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







		def 				__A		(      self		,			lowerCAmelCase__							)	->				str:
								self.neighbors.append(__UpperCamelCase							)







		def 				__A		(      self		,			lowerCAmelCase__		,			lowerCAmelCase__							)	->				Optional[int]:
								SCREAMING_SNAKE_CASE						=   weight





def        lowercase     (SCREAMING_SNAKE_CASE_						:							Optional[Any]					,     SCREAMING_SNAKE_CASE_						:							List[str]					,     SCREAMING_SNAKE_CASE_						:							Optional[Any]					,     SCREAMING_SNAKE_CASE_						:							Optional[int]    )  ->		Optional[Any]:
						# add the neighbors:
						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        lowercase     (SCREAMING_SNAKE_CASE_						:							list					,     SCREAMING_SNAKE_CASE_						:							Vertex    )  ->		Any:
						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        lowercase     (SCREAMING_SNAKE_CASE_						:							list					,     SCREAMING_SNAKE_CASE_						:							Vertex    )  ->		Optional[Any]:
						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        lowercase     ()  ->		Any:
						pass


if __name__ == "__main__":
	import doctest

	doctest.testmod()



from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE		:     int         =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE		:     Union[str, Any]         =	{
    # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}

class        UpperCamelCase						(				__a				):
						a__		:List[str]      =			'''megatron-bert'''





						def __init__(self			,     __UpperCamelCase=29_056			,     __UpperCamelCase=1_024			,     __UpperCamelCase=24			,     __UpperCamelCase=16			,     __UpperCamelCase=4_096			,     __UpperCamelCase="gelu"			,     __UpperCamelCase=0.1			,     __UpperCamelCase=0.1			,     __UpperCamelCase=512			,     __UpperCamelCase=2			,     __UpperCamelCase=0.02			,     __UpperCamelCase=1E-1_2			,     __UpperCamelCase=0			,     __UpperCamelCase="absolute"			,     __UpperCamelCase=True			,     **__UpperCamelCase			,     )				->				List[Any]:
												super().__init__(pad_token_id=__UpperCamelCase			,     **__UpperCamelCase						)

												UpperCamelCase_		:							Union[str, Any]  =		vocab_size
												UpperCamelCase_		:							Union[str, Any]  =		hidden_size
												UpperCamelCase_		:							Any  =		num_hidden_layers
												UpperCamelCase_		:							str  =		num_attention_heads
												UpperCamelCase_		:							List[Any]  =		hidden_act
												UpperCamelCase_		:							Dict  =		intermediate_size
												UpperCamelCase_		:							Optional[int]  =		hidden_dropout_prob
												UpperCamelCase_		:							Dict  =		attention_probs_dropout_prob
												UpperCamelCase_		:							Any  =		max_position_embeddings
												UpperCamelCase_		:							str  =		type_vocab_size
												UpperCamelCase_		:							Tuple  =		initializer_range
												UpperCamelCase_		:							List[str]  =		layer_norm_eps
												UpperCamelCase_		:							Tuple  =		position_embedding_type
												UpperCamelCase_		:							Tuple  =		use_cache






