




def __UpperCamelCase			(       _A ,  _A ,  _A ,  _A  ):

						# 1. Validate that path exists between current and next vertices
						if graph[path[curr_ind - 1]][next_ver] == 0:
												return False

						# 2. Validate that next vertex is not already in path
						return not any(vertex == next_ver for vertex in path  )





def __UpperCamelCase			(       _A ,  _A ,  _A  ):

						# Base Case
						if curr_ind == len(_A  ):
												# return whether path exists between current and starting vertices
												return graph[path[curr_ind - 1]][path[0]] == 1

						# Recursive Step
						for next_ver in range(0 ,  len(_A  )  ):
												if valid_connection(_A ,  _A ,  _A ,  _A  ):
																		# Insert current vertex  into path as next transition
																		lowerCAmelCase_      			=  next_ver
																		# Validate created path
																		if util_hamilton_cycle(_A ,  _A ,  curr_ind + 1  ):
																								return True
																		# Backtrack
																		lowerCAmelCase_      			=  -1
						return False






def __UpperCamelCase			(       _A ,  _A = 0  ):
						lowerCAmelCase_      			=  [-1] * (len(_A  ) + 1)
						# initialize start and end of path with starting index
						lowerCAmelCase_      			=  lowerCAmelCase_      			=  start_index
						# evaluate and if we find answer return path either return empty array
						return path if util_hamilton_cycle(_A ,  _A ,  1  ) else []










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        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  AutoImageProcessor.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''   )
								lowerCAmelCase_      			=  AutoModelForImageClassification.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''   )
								model.to(UpperCamelCase__   )

								from datasets import load_dataset

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

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

								lowerCAmelCase_      			=  image_processor(UpperCamelCase__,	return_tensors='''pt'''   ).to(UpperCamelCase__   )

								# forward pass
								with torch.no_grad():
														lowerCAmelCase_      			=  model(**UpperCamelCase__   )
														lowerCAmelCase_      			=  outputs.logits

								lowerCAmelCase_      			=  torch.Size((1, 16)   )
								self.assertEqual(logits.shape,	UpperCamelCase__   )

								lowerCAmelCase_      			=  torch.tensor(
								    [-0.4_158, -0.4_092, -0.4_347],	device=UpperCamelCase__,	dtype=torch.float,	)
								self.assertTrue(torch.allclose(logits[0, :3],	UpperCamelCase__,	atol=1E-4   )   )




