"""simple docstring"""





from timeit import timeit





def 				a_     (      _lowerCAmelCase  : int     ):





       '''simple docstring'''

       if number < 0:
              raise ValueError('the value of input must not be negative'     )
       lowercase__			:		Any       =	0
       while number:
              number &= number - 1
              result += 1
       return result





def 				a_     (      _lowerCAmelCase  : int     ):





       '''simple docstring'''

       if number < 0:
              raise ValueError('the value of input must not be negative'     )
       lowercase__			:		List[str]       =	0
       while number:
              if number % 2 == 1:
                     result += 1
              number >>= 1
       return result





def 				a_     (      ):





       '''simple docstring'''

       def do_benchmark(_lowerCAmelCase  : int     ) -> None:
              lowercase__			:		List[str]       =	'import __main__ as z'
              print(f"""Benchmark when {number = }:"""     )
              print(f"""{get_set_bits_count_using_modulo_operator(_lowerCAmelCase     ) = }"""     )
              lowercase__			:		Tuple       =	timeit('z.get_set_bits_count_using_modulo_operator(25)'   , setup=_lowerCAmelCase     )
              print(f"""timeit() runs in {timing} seconds"""     )
              print(f"""{get_set_bits_count_using_brian_kernighans_algorithm(_lowerCAmelCase     ) = }"""     )
              lowercase__			:		List[Any]       =	timeit(
                  'z.get_set_bits_count_using_brian_kernighans_algorithm(25)'   , setup=_lowerCAmelCase   , )
              print(f"""timeit() runs in {timing} seconds"""     )

       for number in (25, 37, 58, 0):
              do_benchmark(_lowerCAmelCase     )
              print()


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       benchmark()







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   )   )




