






'''simple docstring'''







def 		_UpperCAmelCase   (							__A							:   Tuple						,		__A							:   Any      ):
				print('''\nThe shortest path matrix using Floyd Warshall algorithm\n'''      )
				for i in range(__A      ):
								for j in range(__A      ):
												if dist[i][j] != float('''inf'''      ):
																print(int(dist[i][j]      )						,		end='''\t'''      )
												else:
																print('''INF'''						,		end='''\t'''      )
								print()





def 		_UpperCAmelCase   (							__A							:   Dict						,		__A							:   Optional[int]      ):
				a_		:  Dict											=      [[float('''inf'''      ) for _ in range(__A      )] for _ in range(__A      )]

				for i in range(__A      ):
								for j in range(__A      ):
												a_		:  Tuple											=      graph[i][j]

												# check vertex k against all other vertices (i, j)
				for k in range(__A      ):
								# looping through rows of graph array
								for i in range(__A      ):
												# looping through columns of graph array
												for j in range(__A      ):
																if (
																    dist[i][k] != float('''inf'''      )
																    and dist[k][j] != float('''inf'''      )
																    and dist[i][k] + dist[k][j] < dist[i][j]
																):
																				a_		:  Tuple											=      dist[i][k] + dist[k][j]

				_print_dist(__A						,		__A      )
				return dist, v


if __name__ == "__main__":
		__lowerCAmelCase       		=					int(input('Enter number of vertices: '))
		__lowerCAmelCase       		=					int(input('Enter number of edges: '))

		__lowerCAmelCase       		=					[[float('inf') for i in range(v)] for j in range(v)]

		for i in range(v):
				__lowerCAmelCase       		=					0.0

				# src and dst are indices that must be within the array size graph[e][v]
				# failure to follow this will result in an error
		for i in range(e):
				print('\nEdge ', i + 1)
				__lowerCAmelCase       		=					int(input('Enter source:'))
				__lowerCAmelCase       		=					int(input('Enter destination:'))
				__lowerCAmelCase       		=					float(input('Enter weight:'))
				__lowerCAmelCase       		=					weight

		floyd_warshall(graph, v)

		# Example Input
		# Enter number of vertices: 3
		# Enter number of edges: 2

		# # generated graph from vertex and edge inputs
		# [[inf, inf, inf], [inf, inf, inf], [inf, inf, inf]]
		# [[0.0, inf, inf], [inf, 0.0, inf], [inf, inf, 0.0]]

		# specify source, destination and weight for edge #1
		# Edge  1
		# Enter source:1
		# Enter destination:2
		# Enter weight:2

		# specify source, destination and weight for edge #2
		# Edge  2
		# Enter source:2
		# Enter destination:1
		# Enter weight:1

		# # Expected Output from the vertice, edge and src, dst, weight inputs!!
		# 0		INF	INF
		# INF	0	2
		# INF	1	0












'''simple docstring'''







import torch

from transformers import AutoModel





class 	SCREAMING_SNAKE_CASE					(					torch.nn.Module       ):






			def __init__( self      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			int="sayef/fsner-bert-base-uncased"					)			->			str:
							super(__SCREAMING_SNAKE_CASE  ,						self					).__init__()

							a_		:  str											=      AutoModel.from_pretrained(__SCREAMING_SNAKE_CASE  ,						return_dict=__SCREAMING_SNAKE_CASE					)
							a_		:  Optional[int]											=      torch.nn.CosineSimilarity(3  ,						1e-08					)
							a_		:  Dict											=      torch.nn.Softmax(dim=1					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			str  ,						**__SCREAMING_SNAKE_CASE      :			int					)			->			str:
							return self.bert(**__SCREAMING_SNAKE_CASE					).last_hidden_state






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			List[Any]					)			->			Optional[int]:
							return token_embeddings.sum(2  ,						keepdim=__SCREAMING_SNAKE_CASE					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[Any]  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]  ,						__SCREAMING_SNAKE_CASE      :			int=1					)			->			Dict:
							return self.softmax(T * self.cos(__SCREAMING_SNAKE_CASE  ,						__SCREAMING_SNAKE_CASE					)					)







			def 			SCREAMING_SNAKE_CASE      ( self      :			str  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]					)			->			Any:
							a_		:  Dict											=      W_supports['''sizes'''].tolist()
							a_		:  Tuple											=      W_supports['''start_token_id'''].item()
							a_		:  List[Any]											=      W_supports['''end_token_id'''].item()

							del W_supports["sizes"]
							del W_supports["start_token_id"]
							del W_supports["end_token_id"]

							a_		:  int											=      self.BERT(**__SCREAMING_SNAKE_CASE					)
							a_		:  Any											=      self.BERT(**__SCREAMING_SNAKE_CASE					)

							a_		:  Optional[Any]											=      None
							a_		:  Tuple											=      None

							a_		:  List[str]											=      W_supports['''input_ids'''] == start_token_id
							a_		:  Dict											=      W_supports['''input_ids'''] == end_token_id

							for i, size in enumerate(__SCREAMING_SNAKE_CASE					):
											if i == 0:
															a_		:  str											=      0
											else:
															a_		:  str											=      support_sizes[i - 1]

											a_		:  Union[str, Any]											=      S[s : s + size][start_token_masks[s : s + size]]
											a_		:  Tuple											=      S[s : s + size][end_token_masks[s : s + size]]

											a_		:  Tuple											=      torch.matmul(q[i]  ,						s_start.T					).sum(1					).softmax(0					)
											a_		:  Optional[Any]											=      torch.matmul(q[i]  ,						s_end.T					).sum(1					).softmax(0					)

											if p_starts is not None:
															a_		:  Any											=      torch.vstack((p_starts, p_start)					)
															a_		:  Dict											=      torch.vstack((p_ends, p_end)					)
											else:
															a_		:  Optional[int]											=      p_start
															a_		:  List[Any]											=      p_end

							return p_starts, p_ends




