'''simple docstring'''

from __future__ import annotations
def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase     ):
 print(F"""Vertex\tShortest Distance from vertex {src}"""     )
 for i, d in enumerate(UpperCAmelCase     ):
  print(F"""{i}\t\t{d}"""     )
def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase     ):
 for j in range(UpperCAmelCase     ):
  lowercase__ ,							lowercase__ ,							lowercase__				:    List[Any]  =					(graph[j][k] for k in ['''src''', '''dst''', '''weight'''])
  if distance[u] != float('''inf'''     ) and distance[u] + w < distance[v]:
   return True
 return False
def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase     ):
 lowercase__				:    str  =					[float('''inf'''     )] * vertex_count
 lowercase__				:    Optional[int]  =					0.0

 for _ in range(vertex_count - 1     ):
  for j in range(UpperCAmelCase     ):
   lowercase__ ,							lowercase__ ,							lowercase__				:    Dict  =					(graph[j][k] for k in ['''src''', '''dst''', '''weight'''])

   if distance[u] != float('''inf'''     ) and distance[u] + w < distance[v]:
    lowercase__				:    Dict  =					distance[u] + w

 lowercase__				:    Dict  =					check_negative_cycle(UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase     )
 if negative_cycle_exists:
  raise Exception('''Negative cycle found'''     )

 return distance


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  __a: Optional[int]          =   int(input("""Enter number of vertices: """).strip())
  __a: Union[str, Any]          =   int(input("""Enter number of edges: """).strip())

  __a: list[dict[str, int]]          =   [{} for _ in range(E)]

  for i in range(E):
    print("""Edge """, i + 1)
    __a   ,			__a   ,			__a: str          =   (
        int(x)
        for x in input("""Enter source, destination, weight: """).strip().split(""" """)
    )
    __a: Optional[Any]          =   {"""src""": src, """dst""": dest, """weight""": weight}

  __a: Tuple          =   int(input("""\nEnter shortest path source:""").strip())
  __a: Tuple          =   bellman_ford(graph, V, E, source)
  print_distance(shortest_distance, 0)


'''simple docstring'''

import os
from argparse import ArgumentParser
from typing import List

import torch.utils.data

from datasets import Dataset, IterableDataset
from datasets.distributed import split_dataset_by_node


__a: Optional[int]          =   4
__a: Optional[Any]          =   3



class 			UpperCAmelCase  (						a__					):





       '''simple docstring'''



       pass


def 			__UpperCamelCase       (   UpperCAmelCase     ):
 for shard in shards:
  for i in range(UpperCAmelCase     ):
   yield {"i": i, "shard": shard}
def 			__UpperCamelCase       (   ):
 lowercase__				:    Tuple  =					int(os.environ['''RANK''']     )
 lowercase__				:    List[str]  =					int(os.environ['''WORLD_SIZE''']     )

 lowercase__				:    Optional[Any]  =					ArgumentParser()
 parser.add_argument('''--streaming'''		,     type=UpperCAmelCase     )
 parser.add_argument('''--local_rank'''		,     type=UpperCAmelCase     )
 parser.add_argument('''--num_workers'''		,     type=UpperCAmelCase		,     default=0     )
 lowercase__				:    List[Any]  =					parser.parse_args()
 lowercase__				:    List[str]  =					args.streaming
 lowercase__				:    str  =					args.num_workers

 lowercase__				:    Optional[int]  =					{'''shards''': [F"""shard_{shard_idx}""" for shard_idx in range(UpperCAmelCase     )]}
 lowercase__				:    Tuple  =					IterableDataset.from_generator(UpperCAmelCase		,     gen_kwargs=UpperCAmelCase     )
 if not streaming:
  lowercase__				:    int  =					Dataset.from_list(list(UpperCAmelCase     )     )

 lowercase__				:    str  =					split_dataset_by_node(UpperCAmelCase		,     rank=UpperCAmelCase		,     world_size=UpperCAmelCase     )
 lowercase__				:    Optional[int]  =					torch.utils.data.DataLoader(UpperCAmelCase		,     num_workers=UpperCAmelCase     )

 lowercase__				:    Dict  =					NUM_SHARDS * NUM_ITEMS_PER_SHARD
 lowercase__				:    Optional[Any]  =					full_size // world_size
 expected_local_size += int(rank < (full_size % world_size)     )

 lowercase__				:    Union[str, Any]  =					sum(1 for _ in dataloader     )
 if local_size != expected_local_size:
  raise FailedTestError(F"""local_size {local_size} != expected_local_size {expected_local_size}"""     )


if __name__ == "__main__":
  main()

