




from queue import Queue
from typing import TYPE_CHECKING, Optional


if TYPE_CHECKING:
		from ..models.auto import AutoTokenizer




class     snake_case__							:
				"""simple docstring"""



				def 							__UpperCAmelCase							(      self				:     str					,      __lowerCamelCase				:     Dict							)					->     List[Any]:
							raise NotImplementedError()





				def 							__UpperCAmelCase							(      self				:     List[str]							)					->     List[Any]:
							raise NotImplementedError()




class     snake_case__							(_UpperCamelCase   ):
				"""simple docstring"""



				def __init__(      self				:     List[str]					,      __lowerCamelCase				:     "AutoTokenizer"					,      __lowerCamelCase				:     bool = False					,      **__lowerCamelCase				:     str							)					->     Any:
							a    =			tokenizer
							a    =			skip_prompt
							a    =			decode_kwargs

							# variables used in the streaming process
							a    =			[]
							a    =			0
							a    =			True





				def 							__UpperCAmelCase							(      self				:     List[Any]					,      __lowerCamelCase				:     str							)					->     List[Any]:
							if len(value.shape							) > 1 and value.shape[0] > 1:
										raise ValueError("TextStreamer only supports batch size 1"							)
							elif len(value.shape							) > 1:
										a    =			value[0]

							if self.skip_prompt and self.next_tokens_are_prompt:
										a    =			False
										return

							# Add the new token to the cache and decodes the entire thing.
							self.token_cache.extend(value.tolist()							)
							a    =			self.tokenizer.decode(self.token_cache					,      **self.decode_kwargs							)

							# After the symbol for a new line, we flush the cache.
							if text.endswith("\n"							):
										a    =			text[self.print_len :]
										a    =			[]
										a    =			0
							# If the last token is a CJK character, we print the characters.
							elif len(__lowerCamelCase							) > 0 and self._is_chinese_char(ord(text[-1]							)							):
										a    =			text[self.print_len :]
										self.print_len += len(__lowerCamelCase							)
							# Otherwise, prints until the last space char (simple heuristic to avoid printing incomplete words,
							# which may change with the subsequent token -- there are probably smarter ways to do this!)
							else:
										a    =			text[self.print_len : text.rfind(" "							) + 1]
										self.print_len += len(__lowerCamelCase							)

							self.on_finalized_text(__lowerCamelCase							)





				def 							__UpperCAmelCase							(      self				:     int							)					->     int:
							# Flush the cache, if it exists
							if len(self.token_cache							) > 0:
										a    =			self.tokenizer.decode(self.token_cache					,      **self.decode_kwargs							)
										a    =			text[self.print_len :]
										a    =			[]
										a    =			0
							else:
										a    =			""

							a    =			True
							self.on_finalized_text(__lowerCamelCase					,      stream_end=__lowerCamelCase							)





				def 							__UpperCAmelCase							(      self				:     Optional[int]					,      __lowerCamelCase				:     str					,      __lowerCamelCase				:     bool = False							)					->     Dict:
							print(__lowerCamelCase					,      flush=__lowerCamelCase					,      end="" if not stream_end else None							)





				def 							__UpperCAmelCase							(      self				:     Any					,      __lowerCamelCase				:     List[Any]							)					->     Any:
							# This defines a "chinese character" as anything in the CJK Unicode block:
							#   https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)
							#
							# Note that the CJK Unicode block is NOT all Japanese and Korean characters,
							# despite its name. The modern Korean Hangul alphabet is a different block,
							# as is Japanese Hiragana and Katakana. Those alphabets are used to write
							# space-separated words, so they are not treated specially and handled
							# like the all of the other languages.
							if (
							    (cp >= 0X4e_00 and cp <= 0X9f_ff)
							    or (cp >= 0X34_00 and cp <= 0X4d_bf)  #
							    or (cp >= 0X2_00_00 and cp <= 0X2_a6_df)  #
							    or (cp >= 0X2_a7_00 and cp <= 0X2_b7_3f)  #
							    or (cp >= 0X2_b7_40 and cp <= 0X2_b8_1f)  #
							    or (cp >= 0X2_b8_20 and cp <= 0X2_ce_af)  #
							    or (cp >= 0Xf9_00 and cp <= 0Xfa_ff)
							    or (cp >= 0X2_f8_00 and cp <= 0X2_fa_1f)  #
							):  #
										return True

							return False




class     snake_case__							(_UpperCamelCase   ):
				"""simple docstring"""



				def __init__(      self				:     Tuple					,      __lowerCamelCase				:     "AutoTokenizer"					,      __lowerCamelCase				:     bool = False					,      __lowerCamelCase				:     Optional[float] = None					,      **__lowerCamelCase				:     Any							)					->     int:
							super().__init__(__lowerCamelCase					,      __lowerCamelCase					,      **__lowerCamelCase							)
							a    =			Queue()
							a    =			None
							a    =			timeout





				def 							__UpperCAmelCase							(      self				:     List[Any]					,      __lowerCamelCase				:     str					,      __lowerCamelCase				:     bool = False							)					->     Tuple:
							self.text_queue.put(__lowerCamelCase					,      timeout=self.timeout							)
							if stream_end:
										self.text_queue.put(self.stop_signal					,      timeout=self.timeout							)





				def __iter__(      self				:     Dict							)					->     str:
							return self





				def 							__UpperCAmelCase							(      self				:     Optional[int]							)					->     Union[str, Any]:
							a    =			self.text_queue.get(timeout=self.timeout							)
							if value == self.stop_signal:
										raise StopIteration()
							else:
										return value











"""simple docstring"""







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



def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[Any]:
		lowercase__   :    str				=			[[float('''inf'''	) for _ in range(__lowerCamelCase	)] for _ in range(__lowerCamelCase	)]

		for i in range(__lowerCamelCase	):
				for j in range(__lowerCamelCase	):
						lowercase__   :    List[str]				=			graph[i][j]

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

		_print_dist(__lowerCamelCase						,     __lowerCamelCase	)
		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
