
def 					lowerCAmelCase__     (    SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_	)							->						Any:
			print('\nVertex Distance'	)
			for i in range(SCREAMING_SNAKE_CASE_	):
						if dist[i] != float('inf'	):
									print(SCREAMING_SNAKE_CASE_			,				'\t'			,				int(dist[i]	)			,				end='\t'	)
						else:
									print(SCREAMING_SNAKE_CASE_			,				'\t'			,				'INF'			,				end='\t'	)
						print()
def 					lowerCAmelCase__     (    SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_	)							->						List[Any]:
			lowerCAmelCase__ : int   =						float('inf'	)
			lowerCAmelCase__ : str   =						-1
			for i in range(SCREAMING_SNAKE_CASE_	):
						if (not vset[i]) and mdist[i] < min_val:
									lowerCAmelCase__ : int   =						i
									lowerCAmelCase__ : Optional[int]   =						mdist[i]
			return min_ind
def 					lowerCAmelCase__     (    SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_	)							->						List[Any]:
			lowerCAmelCase__ : Tuple   =						[float('inf'	) for _ in range(SCREAMING_SNAKE_CASE_	)]
			lowerCAmelCase__ : str   =						[False for _ in range(SCREAMING_SNAKE_CASE_	)]
			lowerCAmelCase__ : List[str]   =						0.0

			for _ in range(v - 1	):
						lowerCAmelCase__ : str   =						min_dist(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_	)
						lowerCAmelCase__ : int   =						True

						for i in range(SCREAMING_SNAKE_CASE_	):
									if (
									    (not vset[i])
									    and graph[u][i] != float('inf'	)
									    and mdist[u] + graph[u][i] < mdist[i]
									):
												lowerCAmelCase__ : Dict   =						mdist[u] + graph[u][i]

			print_dist(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_	)


if __name__ == "__main__":
					lowerCamelCase__        =						int(input("""Enter number of vertices: """).strip())
					lowerCamelCase__        =						int(input("""Enter number of edges: """).strip())

					lowerCamelCase__        =						[[float("""inf""") for i in range(V)] for j in range(V)]

					for i in range(V):
										lowerCamelCase__        =						0.0

					for i in range(E):
										print("""\nEdge """, i + 1)
										lowerCamelCase__        =						int(input("""Enter source:""").strip())
										lowerCamelCase__        =						int(input("""Enter destination:""").strip())
										lowerCamelCase__        =						float(input("""Enter weight:""").strip())
										lowerCamelCase__        =						weight

					lowerCamelCase__        =						int(input("""\nEnter shortest path source:""").strip())
					dijkstra(graph, V, gsrc)

import torch

from accelerate import Accelerator, DistributedType







class 	A__				:






				def __enter__(		self   : Optional[Any]  ):






							'''simple docstring'''







							if self.enabled:
										lowerCAmelCase__ : Any   =						self.model.no_sync()
										self.model_sync_obj.__enter__()

							return self






				def __exit__(		self   : int       ,	a   : int       ,	a   : Optional[Any]       ,	a   : str  ):






							'''simple docstring'''







							if self.enabled:
										# Average all models on exit
										self._sync_and_avg_model_params()
										self.model_sync_obj.__exit__(a       ,	a       ,	a  )






				def __init__(		self   : List[str]       ,	a   : Accelerator       ,	a   : torch.nn.Module       ,	a   : int       ,	a   : bool = True  ):






							'''simple docstring'''







							if accelerator.distributed_type not in [
							    DistributedType.NO,
							    DistributedType.MULTI_CPU,
							    DistributedType.MULTI_GPU,
							]:
										raise NotImplementedError('LocalSGD is supported only for CPUs and GPUs (no DeepSpeed or MegatronLM)'  )
							lowerCAmelCase__ : Union[str, Any]   =						enabled and accelerator.distributed_type != DistributedType.NO
							lowerCAmelCase__ : str   =						0
							if self.enabled:
										lowerCAmelCase__ : Dict   =						accelerator
										lowerCAmelCase__ : Dict   =						model
										lowerCAmelCase__ : Optional[int]   =						local_sgd_steps






				def 				_lowerCamelCase						(		self   : Optional[Any]  ):






							'''simple docstring'''







							self.num_steps += 1
							if not self.enabled:
										return

							if self.num_steps % self.local_sgd_steps == 0:
										self._sync_and_avg_model_params()






				def 				_lowerCamelCase						(		self   : int  ):






							'''simple docstring'''







							self.accelerator.wait_for_everyone()
							with self.accelerator.autocast():
										for param in self.model.parameters():
													lowerCAmelCase__ : Dict   =						self.accelerator.reduce(param.data       ,	reduction='mean'  )