
"""simple docstring"""





class 						SCREAMING_SNAKE_CASE_ :




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = set_counts
				__SCREAMING_SNAKE_CASE            = max(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = len(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = [1] * num_sets
				__SCREAMING_SNAKE_CASE            = list(range(lowerCAmelCase__))




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.get_parent(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = self.get_parent(lowerCAmelCase__)

				if src_parent == dst_parent:
						return False

				if self.ranks[dst_parent] >= self.ranks[src_parent]:
						self.set_counts[dst_parent] += self.set_counts[src_parent]
						__SCREAMING_SNAKE_CASE            = 0
						__SCREAMING_SNAKE_CASE            = dst_parent
						if self.ranks[dst_parent] == self.ranks[src_parent]:
								self.ranks[dst_parent] += 1
						__SCREAMING_SNAKE_CASE            = self.set_counts[dst_parent]
				else:
						self.set_counts[src_parent] += self.set_counts[dst_parent]
						__SCREAMING_SNAKE_CASE            = 0
						__SCREAMING_SNAKE_CASE            = src_parent
						__SCREAMING_SNAKE_CASE            = self.set_counts[src_parent]

				__SCREAMING_SNAKE_CASE            = max(self.max_set							,  lowerCAmelCase__)
				return True




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if self.parents[disj_set] == disj_set:
						return disj_set
				__SCREAMING_SNAKE_CASE            = self.get_parent(self.parents[disj_set])
				return self.parents[disj_set]












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



	'''simple docstring'''




	@slow
	def 							_UpperCamelCase			(       self					)       ->    int:
								snake_case_				=							AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'					)
								snake_case_				=							AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'					)
								model.to(a					)

								from datasets import load_dataset

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

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

								snake_case_				=							image_processor(a       ,			return_tensors='pt'					).to(a					)

								# forward pass
								with torch.no_grad():
															snake_case_				=							model(**a					)
															snake_case_				=							outputs.logits

								snake_case_				=							torch.Size((1, 16)					)
								self.assertEqual(logits.shape       ,			a					)

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





