





import json
import os
import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import BertTokenizer, BertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_vision
from transformers.utils import IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
	from PIL import Image

	from transformers import AlignProcessor, EfficientNetImageProcessor



@require_vision
class 					__lowerCAmelCase       (			unittest.TestCase     ):






			def 			lowerCamelCase  (self    )     ->   List[str]:


							'''simple docstring'''



							snake_case_						:    Optional[int]				=  tempfile.mkdtemp()

							snake_case_						:    Union[str, Any]				=  [
							    '''[UNK]''',
							    '''[CLS]''',
							    '''[SEP]''',
							    '''[PAD]''',
							    '''[MASK]''',
							    '''want''',
							    '''##want''',
							    '''##ed''',
							    '''wa''',
							    '''un''',
							    '''runn''',
							    '''##ing''',
							    ''',''',
							    '''low''',
							    '''lowest''',
							]
							snake_case_						:    Dict				=  os.path.join(self.tmpdirname					,							VOCAB_FILES_NAMES['''vocab_file''']    )
							with open(self.vocab_file					,							'''w'''					,							encoding='''utf-8'''    ) as vocab_writer:
											vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]    )    )

							snake_case_						:    int				=  {
							    '''do_resize''': True,
							    '''size''': 20,
							    '''do_center_crop''': True,
							    '''crop_size''': 18,
							    '''do_normalize''': True,
							    '''image_mean''': [0.48_145_466, 0.4_578_275, 0.40_821_073],
							    '''image_std''': [0.26_862_954, 0.26_130_258, 0.27_577_711],
							}
							snake_case_						:    Dict				=  os.path.join(self.tmpdirname					,							__magic_name__    )
							with open(self.image_processor_file					,							'''w'''					,							encoding='''utf-8'''    ) as fp:
											json.dump(__magic_name__					,							__magic_name__    )






			def 			lowerCamelCase  (self					,							**__magic_name__    )     ->   Dict:


							'''simple docstring'''



							return BertTokenizer.from_pretrained(self.tmpdirname					,							**__magic_name__    )






			def 			lowerCamelCase  (self					,							**__magic_name__    )     ->   Optional[int]:


							'''simple docstring'''



							return BertTokenizerFast.from_pretrained(self.tmpdirname					,							**__magic_name__    )






			def 			lowerCamelCase  (self					,							**__magic_name__    )     ->   str:


							'''simple docstring'''



							return EfficientNetImageProcessor.from_pretrained(self.tmpdirname					,							**__magic_name__    )






			def 			lowerCamelCase  (self    )     ->   int:


							'''simple docstring'''



							shutil.rmtree(self.tmpdirname    )






			def 			lowerCamelCase  (self    )     ->   Dict:


							'''simple docstring'''



							snake_case_						:    int				=  [np.random.randint(255					,							size=(3, 30, 400)					,							dtype=np.uinta    )]
							snake_case_						:    Optional[int]				=  [Image.fromarray(np.moveaxis(__magic_name__					,							0					,							-1    )    ) for x in image_inputs]
							return image_inputs






			def 			lowerCamelCase  (self    )     ->   List[Any]:


							'''simple docstring'''



							snake_case_						:    Any				=  self.get_tokenizer()
							snake_case_						:    str				=  self.get_rust_tokenizer()
							snake_case_						:    int				=  self.get_image_processor()

							snake_case_						:    List[Any]				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )
							processor_slow.save_pretrained(self.tmpdirname    )
							snake_case_						:    str				=  AlignProcessor.from_pretrained(self.tmpdirname					,							use_fast=__magic_name__    )

							snake_case_						:    int				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )
							processor_fast.save_pretrained(self.tmpdirname    )
							snake_case_						:    Tuple				=  AlignProcessor.from_pretrained(self.tmpdirname    )

							self.assertEqual(processor_slow.tokenizer.get_vocab()					,							tokenizer_slow.get_vocab()    )
							self.assertEqual(processor_fast.tokenizer.get_vocab()					,							tokenizer_fast.get_vocab()    )
							self.assertEqual(tokenizer_slow.get_vocab()					,							tokenizer_fast.get_vocab()    )
							self.assertIsInstance(processor_slow.tokenizer					,							__magic_name__    )
							self.assertIsInstance(processor_fast.tokenizer					,							__magic_name__    )

							self.assertEqual(processor_slow.image_processor.to_json_string()					,							image_processor.to_json_string()    )
							self.assertEqual(processor_fast.image_processor.to_json_string()					,							image_processor.to_json_string()    )
							self.assertIsInstance(processor_slow.image_processor					,							__magic_name__    )
							self.assertIsInstance(processor_fast.image_processor					,							__magic_name__    )






			def 			lowerCamelCase  (self    )     ->   List[Any]:


							'''simple docstring'''



							snake_case_						:    Any				=  AlignProcessor(tokenizer=self.get_tokenizer()					,							image_processor=self.get_image_processor()    )
							processor.save_pretrained(self.tmpdirname    )

							snake_case_						:    Dict				=  self.get_tokenizer(bos_token='''(BOS)'''					,							eos_token='''(EOS)'''    )
							snake_case_						:    Dict				=  self.get_image_processor(do_normalize=__magic_name__					,							padding_value=1.0    )

							snake_case_						:    List[str]				=  AlignProcessor.from_pretrained(
							    self.tmpdirname					,							bos_token='''(BOS)'''					,							eos_token='''(EOS)'''					,							do_normalize=__magic_name__					,							padding_value=1.0    )

							self.assertEqual(processor.tokenizer.get_vocab()					,							tokenizer_add_kwargs.get_vocab()    )
							self.assertIsInstance(processor.tokenizer					,							__magic_name__    )

							self.assertEqual(processor.image_processor.to_json_string()					,							image_processor_add_kwargs.to_json_string()    )
							self.assertIsInstance(processor.image_processor					,							__magic_name__    )






			def 			lowerCamelCase  (self    )     ->   int:


							'''simple docstring'''



							snake_case_						:    Dict				=  self.get_image_processor()
							snake_case_						:    str				=  self.get_tokenizer()

							snake_case_						:    Dict				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )

							snake_case_						:    Optional[Any]				=  self.prepare_image_inputs()

							snake_case_						:    int				=  image_processor(__magic_name__					,							return_tensors='''np'''    )
							snake_case_						:    Any				=  processor(images=__magic_name__					,							return_tensors='''np'''    )

							for key in input_image_proc.keys():
											self.assertAlmostEqual(input_image_proc[key].sum()					,							input_processor[key].sum()					,							delta=1e-2    )






			def 			lowerCamelCase  (self    )     ->   Union[str, Any]:


							'''simple docstring'''



							snake_case_						:    Optional[Any]				=  self.get_image_processor()
							snake_case_						:    str				=  self.get_tokenizer()

							snake_case_						:    Any				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )

							snake_case_						:    List[Any]				=  '''lower newer'''

							snake_case_						:    str				=  processor(text=__magic_name__    )

							snake_case_						:    Optional[int]				=  tokenizer(__magic_name__					,							padding='''max_length'''					,							max_length=64    )

							for key in encoded_tok.keys():
											self.assertListEqual(encoded_tok[key]					,							encoded_processor[key]    )






			def 			lowerCamelCase  (self    )     ->   Dict:


							'''simple docstring'''



							snake_case_						:    Union[str, Any]				=  self.get_image_processor()
							snake_case_						:    str				=  self.get_tokenizer()

							snake_case_						:    str				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )

							snake_case_						:    Optional[int]				=  '''lower newer'''
							snake_case_						:    Any				=  self.prepare_image_inputs()

							snake_case_						:    List[str]				=  processor(text=__magic_name__					,							images=__magic_name__    )

							self.assertListEqual(list(inputs.keys()    )					,							['''input_ids''', '''token_type_ids''', '''attention_mask''', '''pixel_values''']    )

							# test if it raises when no input is passed
							with pytest.raises(__magic_name__    ):
											processor()






			def 			lowerCamelCase  (self    )     ->   Any:


							'''simple docstring'''



							snake_case_						:    Any				=  self.get_image_processor()
							snake_case_						:    Optional[Any]				=  self.get_tokenizer()

							snake_case_						:    str				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )

							snake_case_						:    Any				=  [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

							snake_case_						:    List[str]				=  processor.batch_decode(__magic_name__    )
							snake_case_						:    Union[str, Any]				=  tokenizer.batch_decode(__magic_name__    )

							self.assertListEqual(__magic_name__					,							__magic_name__    )






			def 			lowerCamelCase  (self    )     ->   Dict:


							'''simple docstring'''



							snake_case_						:    Dict				=  self.get_image_processor()
							snake_case_						:    Any				=  self.get_tokenizer()

							snake_case_						:    Union[str, Any]				=  AlignProcessor(tokenizer=__magic_name__					,							image_processor=__magic_name__    )

							snake_case_						:    Optional[int]				=  '''lower newer'''
							snake_case_						:    Any				=  self.prepare_image_inputs()

							snake_case_						:    int				=  processor(text=__magic_name__					,							images=__magic_name__    )

							self.assertListEqual(list(inputs.keys()    )					,							processor.model_input_names    )







def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						List[str]:






				"""simple docstring"""


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






def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						Union[str, Any]:






				"""simple docstring"""


				snake_case_						:    int				=  [[float('''inf''' ) for _ in range(_UpperCamelCase )] for _ in range(_UpperCamelCase )]

				for i in range(_UpperCamelCase ):
								for j in range(_UpperCamelCase ):
												snake_case_						:    Dict				=  graph[i][j]

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

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