'''simple docstring'''
def  __lowerCamelCase       (      _UpperCamelCase  :  Tuple							,    _UpperCamelCase  :  Dict					):


      '''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  :  Dict							,    _UpperCamelCase  :  Tuple					):


      '''simple docstring'''


      UpperCAmelCase_            =  [[float('''inf'''					) for _ in range(_UpperCamelCase					)] for _ in range(_UpperCamelCase					)]

      for i in range(_UpperCamelCase					):
            for j in range(_UpperCamelCase					):
                  UpperCAmelCase_            =  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]
                        ):
                              UpperCAmelCase_            =  dist[i][k] + dist[k][j]

      _print_dist(_UpperCamelCase							,    _UpperCamelCase					)
      return dist, v


if __name__ == "__main__":
      lowercase__  :      Optional[int]        =					int(input("Enter number of vertices: "))
      lowercase__  :      str        =					int(input("Enter number of edges: "))

      lowercase__  :      List[str]        =					[[float("inf") for i in range(v)] for j in range(v)]

      for i in range(v):
            lowercase__  :      Any        =					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)
            lowercase__  :      Tuple        =					int(input("Enter source:"))
            lowercase__  :      List[str]        =					int(input("Enter destination:"))
            lowercase__  :      str        =					float(input("Enter weight:"))
            lowercase__  :      Tuple        =					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 unittest
from typing import Dict, List, Optional, Union

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

if is_vision_available():
      from PIL import Image

      from transformers import BridgeTowerImageProcessor







class lowerCamelCase							(	unittest.TestCase					):




  '''simple docstring'''



  def __init__(      self			:       int  ,							UpperCAmelCase__			:       Dict  ,							UpperCAmelCase__			:       bool = True  ,							UpperCAmelCase__			:       Dict[str, int] = None  ,							UpperCAmelCase__			:       int = 32  ,							UpperCAmelCase__			:       bool = True  ,							UpperCAmelCase__			:       Union[int, float] = 1 / 255  ,							UpperCAmelCase__			:       bool = True  ,							UpperCAmelCase__			:       bool = True  ,							UpperCAmelCase__			:       Optional[Union[float, List[float]]] = [0.4814_5466, 0.457_8275, 0.4082_1073]  ,							UpperCAmelCase__			:       Optional[Union[float, List[float]]] = [0.2686_2954, 0.2613_0258, 0.2757_7711]  ,							UpperCAmelCase__			:       bool = True  ,							UpperCAmelCase__			:       Union[str, Any]=7  ,							UpperCAmelCase__			:       Optional[int]=30  ,							UpperCAmelCase__			:       Union[str, Any]=400  ,							UpperCAmelCase__			:       List[Any]=3  ,							)				->Dict:
        UpperCAmelCase_            =  parent
        UpperCAmelCase_            =  do_resize
        UpperCAmelCase_            =  size if size is not None else {'''shortest_edge''': 288}
        UpperCAmelCase_            =  size_divisor
        UpperCAmelCase_            =  do_rescale
        UpperCAmelCase_            =  rescale_factor
        UpperCAmelCase_            =  do_normalize
        UpperCAmelCase_            =  do_center_crop
        UpperCAmelCase_            =  image_mean
        UpperCAmelCase_            =  image_std
        UpperCAmelCase_            =  do_pad
        UpperCAmelCase_            =  batch_size
        UpperCAmelCase_            =  num_channels
        UpperCAmelCase_            =  min_resolution
        UpperCAmelCase_            =  max_resolution






  def  lowerCAmelCase__ (      self			:       Tuple  )				->List[Any]:
        return {
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_normalize": self.do_normalize,
            "do_resize": self.do_resize,
            "size": self.size,
            "size_divisor": self.size_divisor,
        }






  def  lowerCAmelCase__ (      self			:       Optional[int]  ,							UpperCAmelCase__			:       List[str]  ,							UpperCAmelCase__			:       Dict=False  )				->Any:
        if not batched:
              UpperCAmelCase_            =  self.size['''shortest_edge''']
              UpperCAmelCase_            =  image_inputs[0]
              if isinstance(UpperCAmelCase__  ,							Image.Image  ):
                    UpperCAmelCase_      ,		UpperCAmelCase_            =  image.size
              else:
                    UpperCAmelCase_      ,		UpperCAmelCase_            =  image.shape[1], image.shape[2]
              UpperCAmelCase_            =  size / min(UpperCAmelCase__  ,							UpperCAmelCase__  )
              if h < w:
                    UpperCAmelCase_      ,		UpperCAmelCase_            =  size, scale * w
              else:
                    UpperCAmelCase_      ,		UpperCAmelCase_            =  scale * h, size

              UpperCAmelCase_            =  int((1333 / 800) * size  )
              if max(UpperCAmelCase__  ,							UpperCAmelCase__  ) > max_size:
                    UpperCAmelCase_            =  max_size / max(UpperCAmelCase__  ,							UpperCAmelCase__  )
                    UpperCAmelCase_            =  newh * scale
                    UpperCAmelCase_            =  neww * scale

              UpperCAmelCase_      ,		UpperCAmelCase_            =  int(newh + 0.5  ), int(neww + 0.5  )
              UpperCAmelCase_      ,		UpperCAmelCase_            =  (
                  newh // self.size_divisor * self.size_divisor,
                  neww // self.size_divisor * self.size_divisor,
              )

        else:
              UpperCAmelCase_            =  []
              for image in image_inputs:
                    UpperCAmelCase_      ,		UpperCAmelCase_            =  self.get_expected_values([image]  )
                    expected_values.append((expected_height, expected_width)  )
              UpperCAmelCase_            =  max(UpperCAmelCase__  ,							key=lambda UpperCAmelCase__  : item[0]  )[0]
              UpperCAmelCase_            =  max(UpperCAmelCase__  ,							key=lambda UpperCAmelCase__  : item[1]  )[1]

        return expected_height, expected_width







@require_torch
@require_vision
class lowerCamelCase							(	lowerCamelCase     ,		unittest.TestCase					):




  '''simple docstring'''



  lowerCAmelCase__										=	BridgeTowerImageProcessor if is_vision_available() else None






  def  lowerCAmelCase__ (      self			:       Optional[int]  )				->str:
        UpperCAmelCase_            =  BridgeTowerImageProcessingTester(self  )






  @property
  def  lowerCAmelCase__ (      self			:       List[str]  )				->Dict:
        return self.image_processor_tester.prepare_image_processor_dict()






  def  lowerCAmelCase__ (      self			:       Optional[int]  )				->int:
        UpperCAmelCase_            =  self.image_processing_class(**self.image_processor_dict  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''image_mean'''  )  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''image_std'''  )  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''do_normalize'''  )  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''do_resize'''  )  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''size'''  )  )
        self.assertTrue(hasattr(UpperCAmelCase__  ,							'''size_divisor'''  )  )






  def  lowerCAmelCase__ (      self			:       Optional[int]  )				->Union[str, Any]:
        pass






  def  lowerCAmelCase__ (      self			:       List[str]  )				->Union[str, Any]:
        # Initialize image processor
        UpperCAmelCase_            =  self.image_processing_class(**self.image_processor_dict  )
        # create random PIL images
        UpperCAmelCase_            =  prepare_image_inputs(self.image_processor_tester  ,							equal_resolution=UpperCAmelCase__  )
        for image in image_inputs:
              self.assertIsInstance(UpperCAmelCase__  ,							Image.Image  )

        # Test not batched input
        UpperCAmelCase_            =  image_processing(image_inputs[0]  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(1, self.image_processor_tester.num_channels, expected_height, expected_width)  ,							)

        # Test batched
        UpperCAmelCase_            =  image_processing(UpperCAmelCase__  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  ,							batched=UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )  ,							)






  def  lowerCAmelCase__ (      self			:       Any  )				->Optional[int]:
        # Initialize image processor
        UpperCAmelCase_            =  self.image_processing_class(**self.image_processor_dict  )
        # create random numpy tensors
        UpperCAmelCase_            =  prepare_image_inputs(self.image_processor_tester  ,							equal_resolution=UpperCAmelCase__  ,							numpify=UpperCAmelCase__  )
        for image in image_inputs:
              self.assertIsInstance(UpperCAmelCase__  ,							np.ndarray  )

        # Test not batched input
        UpperCAmelCase_            =  image_processing(image_inputs[0]  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(1, self.image_processor_tester.num_channels, expected_height, expected_width)  ,							)

        # Test batched
        UpperCAmelCase_            =  image_processing(UpperCAmelCase__  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  ,							batched=UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )  ,							)






  def  lowerCAmelCase__ (      self			:       int  )				->List[str]:
        # Initialize image processor
        UpperCAmelCase_            =  self.image_processing_class(**self.image_processor_dict  )
        # create random PyTorch tensors
        UpperCAmelCase_            =  prepare_image_inputs(self.image_processor_tester  ,							equal_resolution=UpperCAmelCase__  ,							torchify=UpperCAmelCase__  )
        for image in image_inputs:
              self.assertIsInstance(UpperCAmelCase__  ,							torch.Tensor  )

        # Test not batched input
        UpperCAmelCase_            =  image_processing(image_inputs[0]  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(1, self.image_processor_tester.num_channels, expected_height, expected_width)  ,							)

        # Test batched
        UpperCAmelCase_            =  image_processing(UpperCAmelCase__  ,							return_tensors='''pt'''  ).pixel_values

        UpperCAmelCase_      ,		UpperCAmelCase_            =  self.image_processor_tester.get_expected_values(UpperCAmelCase__  ,							batched=UpperCAmelCase__  )
        self.assertEqual(
            encoded_images.shape  ,							(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )  ,							)





