


'''simple docstring'''






import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
 import torch

 from transformers import AutoModelForImageClassification

if is_vision_available():
 from transformers import AutoImageProcessor




@require_torch
@require_vision
class  a     (     unittest.TestCase       ):
 @slow
 def 							__UpperCAmelCase		( self						)					->							str:
      _a			      =							AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'						)
      _a			      =							AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'						)
      model.to(__magic_name__						)

      from datasets import load_dataset

      _a			      =							load_dataset('nielsr/rvlcdip-demo'						)

      _a			      =							dataset['train'][0]['image'].convert('RGB'						)

      _a			      =							image_processor(__magic_name__      ,				return_tensors='pt'						).to(__magic_name__						)

      # forward pass
      with torch.no_grad():
           _a			      =							model(**__magic_name__						)
           _a			      =							outputs.logits

      _a			      =							torch.Size((1, 16)						)
      self.assertEqual(logits.shape      ,				__magic_name__						)

      _a			      =							torch.tensor(
          [-0.4_1_5_8, -0.4_0_9_2, -0.4_3_4_7]      ,				device=__magic_name__      ,				dtype=torch.float      ,				)
      self.assertTrue(torch.allclose(logits[0, :3]      ,				__magic_name__      ,				atol=1e-4						)						)





'''simple docstring'''






def 	_A				(lowerCAmelCase__  :List[str]				,						lowerCAmelCase__  :Optional[Any]		)   ->  Optional[int]:




     '''simple docstring'''



     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 	_A				(lowerCAmelCase__  :Dict				,						lowerCAmelCase__  :List[str]		)   ->  List[str]:




     '''simple docstring'''



     _a			      =							[[float('inf'		) for _ in range(lowerCAmelCase__		)] for _ in range(lowerCAmelCase__		)]

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

     _print_dist(lowerCAmelCase__				,						lowerCAmelCase__		)
     return dist, v


if __name__ == "__main__":
 a_					:    Optional[Any]          =    int(input("Enter number of vertices: "))
 a_					:    List[Any]          =    int(input("Enter number of edges: "))

 a_					:    Dict          =    [[float("inf") for i in range(v)] for j in range(v)]

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

