


"""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 snake_case      (  unittest.TestCase):







		@slow
		def  a_ (					self      :       List[Any]		)       ->						str:





						'''simple docstring'''







						_A					  =			AutoImageProcessor.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"		)
						_A					  =			AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"		)
						model.to(a__		)

						from datasets import load_dataset

						_A					  =			load_dataset("nielsr/rvlcdip-demo"		)

						_A					  =			dataset["train"][0]["image"].convert("RGB"		)

						_A					  =			image_processor(a__    ,   return_tensors="pt"		).to(a__		)

						# forward pass
						with torch.no_grad():
										_A					  =			model(**a__		)
										_A					  =			outputs.logits

						_A					  =			torch.Size((1, 16)		)
						self.assertEqual(logits.shape    ,   a__		)

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



"""simple docstring"""


def      a__ (				__lowercase     ,			__lowercase     ,			__lowercase     ,			__lowercase   )	->	str:
				# Return True if there is node that has not iterated.
				_A					  =			[False] * len(__lowercase   )
				_A					  =			[]
				queue.append(__lowercase   )
				_A					  =			True

				while queue:
								_A					  =			queue.pop(0   )
								for ind in range(len(graph[u]   )   ):
												if visited[ind] is False and graph[u][ind] > 0:
																queue.append(__lowercase   )
																_A					  =			True
																_A					  =			u

				return visited[t]






def      a__ (				__lowercase     ,			__lowercase     ,			__lowercase   )	->	int:
				# This array is filled by BFS and to store path
				_A					  =			[-1] * (len(__lowercase   ))
				_A					  =			0
				while bfs(__lowercase     ,			__lowercase     ,			__lowercase     ,			__lowercase   ):
								_A					  =			float("Inf"   )
								_A					  =			sink

								while s != source:
												# Find the minimum value in select path
												_A					  =			min(__lowercase     ,			graph[parent[s]][s]   )
												_A					  =			parent[s]

								max_flow += path_flow
								_A					  =			sink

								while v != source:
												_A					  =			parent[v]
												graph[u][v] -= path_flow
												graph[v][u] += path_flow
												_A					  =			parent[v]
				return max_flow


a_       							=    [
    [0, 16, 13, 0, 0, 0],
    [0, 0, 10, 12, 0, 0],
    [0, 4, 0, 0, 14, 0],
    [0, 0, 9, 0, 0, 20],
    [0, 0, 0, 7, 0, 4],
    [0, 0, 0, 0, 0, 0],
]

a_							,     a_       							=    0, 5




print(ford_fulkerson(graph, source, sink))