






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       __magic_name__    (    self			)							->				Union[str, Any]:
							__magic_name__      :       Any       						= AutoImageProcessor.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""			)
							__magic_name__      :       str       						= AutoModelForImageClassification.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""			)
							model.to(lowerCAmelCase__			)

							from datasets import load_dataset

							__magic_name__      :       Any       						= load_dataset("""nielsr/rvlcdip-demo"""			)

							__magic_name__      :       int       						= dataset["""train"""][0]["""image"""].convert("""RGB"""			)

							__magic_name__      :       Optional[int]       						= image_processor(lowerCAmelCase__      ,       return_tensors="""pt"""			).to(lowerCAmelCase__			)

							# forward pass
							with torch.no_grad():
													__magic_name__      :       str       						= model(**lowerCAmelCase__			)
													__magic_name__      :       Optional[Any]       						= outputs.logits

							__magic_name__      :       List[str]       						= torch.Size((1, 16)			)
							self.assertEqual(logits.shape      ,       lowerCAmelCase__			)

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








def    UpperCamelCase						(	_A			):






						"""simple docstring"""







						if not isinstance(_A,   _A			) or number < 0:
												raise ValueError("""Input must be a non-negative integer"""			)

						__magic_name__      :       str       						= 0
						while number:
												# This way we arrive at next set bit (next 1) instead of looping
												# through each bit and checking for 1s hence the
												# loop won't run 32 times it will only run the number of `1` times
												number &= number - 1
												count += 1
						return count


if __name__ == "__main__":
		import doctest

		doctest.testmod()
