

'''simple docstring'''


import copy
import random

from transformers import CLIPTokenizer



class 					lowercase						(  lowercase__ ):


							def __init__(			self    ,			*_snake_case    ,			**_snake_case)							->				Union[str, Any]:
								super().__init__(*__lowercase    ,			**__lowercase)
								UpperCAmelCase_		:      List[Any]       	=					{}


							def 						_snake_case							(			self    ,			_snake_case    ,			*_snake_case    ,			**_snake_case)							->				List[str]:
								UpperCAmelCase_		:      Optional[Any]       	=					super().add_tokens(__lowercase    ,			*__lowercase    ,			**__lowercase)
								if num_added_tokens == 0:
									raise ValueError(
									    F"""The tokenizer already contains the token {placeholder_token}. Please pass a different"""
									    ' `placeholder_token` that is not already in the tokenizer.')


							def 						_snake_case							(			self    ,			_snake_case    ,			*_snake_case    ,			_snake_case=1    ,			**_snake_case)							->				Union[str, Any]:
								UpperCAmelCase_		:      Union[str, Any]       	=					[]
								if num_vec_per_token == 1:
									self.try_adding_tokens(__lowercase    ,			*__lowercase    ,			**__lowercase)
									output.append(__lowercase)
								else:
									UpperCAmelCase_		:      Optional[int]       	=					[]
									for i in range(__lowercase):
										UpperCAmelCase_		:      Any       	=					placeholder_token + F"""_{i}"""
										self.try_adding_tokens(__lowercase    ,			*__lowercase    ,			**__lowercase)
										output.append(__lowercase)
        # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
								for token in self.token_map:
									if token in placeholder_token:
										raise ValueError(
										    F"""The tokenizer already has placeholder token {token} that can get confused with"""
										    F""" {placeholder_token}keep placeholder tokens independent""")
								UpperCAmelCase_		:      int       	=					output


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case=False    ,			_snake_case=1.0)							->				List[Any]:
								if isinstance(__lowercase    ,			__lowercase):
									UpperCAmelCase_		:      Any       	=					[]
									for i in range(len(__lowercase)):
										output.append(self.replace_placeholder_tokens_in_text(text[i]    ,			vector_shuffle=__lowercase))
									return output
								for placeholder_token in self.token_map:
									if placeholder_token in text:
										UpperCAmelCase_		:      str       	=					self.token_map[placeholder_token]
										UpperCAmelCase_		:      Dict       	=					tokens[: 1 + int(len(__lowercase) * prop_tokens_to_load)]
										if vector_shuffle:
											UpperCAmelCase_		:      Any       	=					copy.copy(__lowercase)
											random.shuffle(__lowercase)
										UpperCAmelCase_		:      List[str]       	=					text.replace(__lowercase    ,			' '.join(__lowercase))
								return text


							def __call__(			self    ,			_snake_case    ,			*_snake_case    ,			_snake_case=False    ,			_snake_case=1.0    ,			**_snake_case)							->				List[Any]:
								return super().__call__(
								    self.replace_placeholder_tokens_in_text(
								        __lowercase    ,			vector_shuffle=__lowercase    ,			prop_tokens_to_load=__lowercase)    ,			*__lowercase    ,			**__lowercase    ,			)





							def 						_snake_case							(			self    ,			_snake_case    ,			*_snake_case    ,			_snake_case=False    ,			_snake_case=1.0    ,			**_snake_case)							->				Any:
								return super().encode(
								    self.replace_placeholder_tokens_in_text(
								        __lowercase    ,			vector_shuffle=__lowercase    ,			prop_tokens_to_load=__lowercase)    ,			*__lowercase    ,			**__lowercase    ,			)









'''simple docstring'''


import math



class 					lowercase						:


							def __init__(			self    ,			_snake_case=0)							->				Union[str, Any]:  # a graph with Node 0,1,...,N-1
								UpperCAmelCase_		:      Tuple       	=					n
								UpperCAmelCase_		:      Optional[Any]       	=					[
								    [math.inf for j in range(0    ,			_snake_case)] for i in range(0    ,			_snake_case)
								]  # adjacency matrix for weight
								UpperCAmelCase_		:      Tuple       	=					[
								    [math.inf for j in range(0    ,			_snake_case)] for i in range(0    ,			_snake_case)
								]  # dp[i][j] stores minimum distance from i to j


							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case    ,			_snake_case)							->				List[Any]:
								UpperCAmelCase_		:      Union[str, Any]       	=					w


							def 						_snake_case							(			self)							->				str:
								for k in range(0    ,			self.n):
									for i in range(0    ,			self.n):
										for j in range(0    ,			self.n):
											UpperCAmelCase_		:      Optional[int]       	=					min(self.dp[i][j]    ,			self.dp[i][k] + self.dp[k][j])





							def 						_snake_case							(			self    ,			_snake_case    ,			_snake_case)							->				str:
								return self.dp[u][v]


if __name__ == "__main__":
						lowerCAmelCase__										= Graph(5)
						graph.add_edge(0, 2, 9)
						graph.add_edge(0, 4, 10)
						graph.add_edge(1, 3, 5)
						graph.add_edge(2, 3, 7)
						graph.add_edge(3, 0, 10)
						graph.add_edge(3, 1, 2)
						graph.add_edge(3, 2, 1)
						graph.add_edge(3, 4, 6)
						graph.add_edge(4, 1, 3)
						graph.add_edge(4, 2, 4)
						graph.add_edge(4, 3, 9)
						graph.floyd_warshall()
						graph.show_min(1, 4)
						graph.show_min(0, 3)






