


import copy
import tempfile
import unittest

from transformers import MaMaaaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from transformers.utils import cached_property

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import MaMaaaForConditionalGeneration, MaMaaaModel, MaMaaaTokenizer
		from transformers.models.mam_aaa.modeling_mam_aaa import MaMaaaDecoder, MaMaaaEncoder


def     lowercase	(    a     , a     , a     , a=None     , a=None     , a=None     , a=None     , a=None     , ):



		'''simple docstring'''




		if attention_mask is None:
				SCREAMING_SNAKE_CASE_				:Dict				     =						input_ids.ne(config.pad_token_id )
		if decoder_attention_mask is None:
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						decoder_input_ids.ne(config.pad_token_id )
		if head_mask is None:
				SCREAMING_SNAKE_CASE_				:Any				     =						torch.ones(config.encoder_layers     , config.encoder_attention_heads     , device=a )
		if decoder_head_mask is None:
				SCREAMING_SNAKE_CASE_				:Any				     =						torch.ones(config.decoder_layers     , config.decoder_attention_heads     , device=a )
		if cross_attn_head_mask is None:
				SCREAMING_SNAKE_CASE_				:Tuple				     =						torch.ones(config.decoder_layers     , config.decoder_attention_heads     , device=a )
		return {
		    "input_ids": input_ids,
		    "decoder_input_ids": decoder_input_ids,
		    "attention_mask": attention_mask,
		    "decoder_attention_mask": attention_mask,
		    "head_mask": head_mask,
		    "decoder_head_mask": decoder_head_mask,
		    "cross_attn_head_mask": cross_attn_head_mask,
		}



class 						_UpperCAmelCase      :






		def __init__(						self				:     Dict   ,  UpperCAmelCase				:     Optional[int]   ,  UpperCAmelCase				:     Dict=13   ,  UpperCAmelCase				:     Optional[Any]=7   ,  UpperCAmelCase				:     Union[str, Any]=True   ,  UpperCAmelCase				:     List[str]=False   ,  UpperCAmelCase				:     Union[str, Any]=99   ,  UpperCAmelCase				:     str=16   ,  UpperCAmelCase				:     Union[str, Any]=2   ,  UpperCAmelCase				:     str=4   ,  UpperCAmelCase				:     str=4   ,  UpperCAmelCase				:     Optional[int]="relu"   ,  UpperCAmelCase				:     Dict=0.1   ,  UpperCAmelCase				:     Optional[Any]=0.1   ,  UpperCAmelCase				:     Dict=0.0   ,  UpperCAmelCase				:     Union[str, Any]=0.0   ,  UpperCAmelCase				:     List[str]=20   ,  UpperCAmelCase				:     Any=2   ,  UpperCAmelCase				:     Dict=1   ,  UpperCAmelCase				:     str=0   ,  ):
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						parent
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						batch_size
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						seq_length
				SCREAMING_SNAKE_CASE_				:Any				     =						is_training
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						use_labels
				SCREAMING_SNAKE_CASE_				:int				     =						vocab_size
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						hidden_size
				SCREAMING_SNAKE_CASE_				:Dict				     =						num_hidden_layers
				SCREAMING_SNAKE_CASE_				:Dict				     =						num_attention_heads
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						intermediate_size
				SCREAMING_SNAKE_CASE_				:int				     =						hidden_act
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						hidden_dropout_prob
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						attention_probs_dropout_prob
				SCREAMING_SNAKE_CASE_				:Dict				     =						encoder_layerdrop
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						decoder_layerdrop
				SCREAMING_SNAKE_CASE_				:List[str]				     =						max_position_embeddings
				SCREAMING_SNAKE_CASE_				:Tuple				     =						eos_token_id
				SCREAMING_SNAKE_CASE_				:int				     =						pad_token_id
				SCREAMING_SNAKE_CASE_				:List[str]				     =						bos_token_id






		def _snake_case		(						self				:     Tuple):
				SCREAMING_SNAKE_CASE_				:List[str]				     =						ids_tensor([self.batch_size, self.seq_length]   ,  self.vocab_size)
				SCREAMING_SNAKE_CASE_				:Any				     =						self.eos_token_id  # Eos Token
				SCREAMING_SNAKE_CASE_				:int				     =						ids_tensor([self.batch_size, self.seq_length]   ,  self.vocab_size)

				# we need to clamp the input ids here to avoid having pad token in between
				# this is because for M2M100 the position_ids are prepared such that
				# all pad tokens have pos id = 2 and rest are between 2..seq_length
				# and the seq_length here is seq_length - num_pad_tokens
				# but when using past, there is no way of knowing if the past input ids had
				# pad tokens in them, which results in incorrect seq_lenth and which in turn results in
				# position_ids being off by num_pad_tokens in past input
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						input_ids.clamp(self.pad_token_id + 1)
				SCREAMING_SNAKE_CASE_				:Any				     =						decoder_input_ids.clamp(self.pad_token_id + 1)

				SCREAMING_SNAKE_CASE_				:List[str]				     =						self.get_config()
				SCREAMING_SNAKE_CASE_				:Any				     =						prepare_mam_aaa_inputs_dict(UpperCAmelCase   ,  UpperCAmelCase   ,  UpperCAmelCase)
				return config, inputs_dict






		def _snake_case		(						self				:     str):
				return MaMaaaConfig(
				    vocab_size=self.vocab_size   ,  d_model=self.hidden_size   ,  encoder_layers=self.num_hidden_layers   ,  decoder_layers=self.num_hidden_layers   ,  encoder_attention_heads=self.num_attention_heads   ,  decoder_attention_heads=self.num_attention_heads   ,  encoder_ffn_dim=self.intermediate_size   ,  decoder_ffn_dim=self.intermediate_size   ,  dropout=self.hidden_dropout_prob   ,  attention_dropout=self.attention_probs_dropout_prob   ,  encoder_layerdrop=self.encoder_layerdrop   ,  decoder_layerdrop=self.decoder_layerdrop   ,  max_position_embeddings=self.max_position_embeddings   ,  eos_token_id=self.eos_token_id   ,  bos_token_id=self.bos_token_id   ,  pad_token_id=self.pad_token_id   ,  )






		def _snake_case		(						self				:     Tuple):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:int				     =						self.prepare_config_and_inputs()
				return config, inputs_dict






		def _snake_case		(						self				:     str   ,  UpperCAmelCase				:     Optional[int]   ,  UpperCAmelCase				:     Tuple):
				SCREAMING_SNAKE_CASE_				:List[str]				     =						MaMaaaModel(config=UpperCAmelCase).get_decoder().to(UpperCAmelCase).eval()
				SCREAMING_SNAKE_CASE_				:List[str]				     =						inputs_dict["input_ids"]
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						inputs_dict["attention_mask"]
				SCREAMING_SNAKE_CASE_				:Any				     =						inputs_dict["head_mask"]

				# first forward pass
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						model(UpperCAmelCase   ,  attention_mask=UpperCAmelCase   ,  head_mask=UpperCAmelCase   ,  use_cache=UpperCAmelCase)

				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:Tuple				     =						outputs.to_tuple()

				# create hypothetical multiple next token and extent to next_input_ids
				SCREAMING_SNAKE_CASE_				:List[str]				     =						ids_tensor((self.batch_size, 3)   ,  config.vocab_size)
				SCREAMING_SNAKE_CASE_				:int				     =						ids_tensor((self.batch_size, 3)   ,  2)

				# append to next input_ids and
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						torch.cat([input_ids, next_tokens]   ,  dim=-1)
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						torch.cat([attention_mask, next_attn_mask]   ,  dim=-1)

				SCREAMING_SNAKE_CASE_				:List[Any]				     =						model(UpperCAmelCase   ,  attention_mask=UpperCAmelCase)["last_hidden_state"]
				SCREAMING_SNAKE_CASE_				:List[str]				     =						model(UpperCAmelCase   ,  attention_mask=UpperCAmelCase   ,  past_key_values=UpperCAmelCase)[
				    "last_hidden_state"
				]

				# select random slice
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						ids_tensor((1,)   ,  output_from_past.shape[-1]).item()
				SCREAMING_SNAKE_CASE_				:Tuple				     =						output_from_no_past[:, -3:, random_slice_idx].detach()
				SCREAMING_SNAKE_CASE_				:str				     =						output_from_past[:, :, random_slice_idx].detach()

				self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1])

				# test that outputs are equal for slice
				self.parent.assertTrue(torch.allclose(UpperCAmelCase   ,  UpperCAmelCase   ,  atol=1E-2))







		def _snake_case		(						self				:     int   ,  UpperCAmelCase				:     Dict   ,  UpperCAmelCase				:     Tuple):
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						MaMaaaModel(config=UpperCAmelCase).to(UpperCAmelCase).eval()
				SCREAMING_SNAKE_CASE_				:int				     =						model(**UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						outputs.encoder_last_hidden_state
				SCREAMING_SNAKE_CASE_				:Tuple				     =						outputs.last_hidden_state

				with tempfile.TemporaryDirectory() as tmpdirname:
						SCREAMING_SNAKE_CASE_				:Dict				     =						model.get_encoder()
						encoder.save_pretrained(UpperCAmelCase)
						SCREAMING_SNAKE_CASE_				:List[str]				     =						MaMaaaEncoder.from_pretrained(UpperCAmelCase).to(UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:List[Any]				     =						encoder(inputs_dict["input_ids"]   ,  attention_mask=inputs_dict["attention_mask"])[
				    0
				]

				self.parent.assertTrue((encoder_last_hidden_state_a - encoder_last_hidden_state).abs().max().item() < 1E-3)

				with tempfile.TemporaryDirectory() as tmpdirname:
						SCREAMING_SNAKE_CASE_				:int				     =						model.get_decoder()
						decoder.save_pretrained(UpperCAmelCase)
						SCREAMING_SNAKE_CASE_				:Dict				     =						MaMaaaDecoder.from_pretrained(UpperCAmelCase).to(UpperCAmelCase)

				SCREAMING_SNAKE_CASE_				:str				     =						decoder(
				    input_ids=inputs_dict["decoder_input_ids"]   ,  attention_mask=inputs_dict["decoder_attention_mask"]   ,  encoder_hidden_states=UpperCAmelCase   ,  encoder_attention_mask=inputs_dict["attention_mask"]   ,  )[0]

				self.parent.assertTrue((last_hidden_state_a - last_hidden_state).abs().max().item() < 1E-3)




@require_torch
class 						_UpperCAmelCase      (     lowercase		,		lowercase		,		lowercase		,		unittest.TestCase							):
		lowerCamelCase_	:			Any       			=  (
		    (
		        MaMaaaModel,
		        MaMaaaForConditionalGeneration,
		    )
		    if is_torch_available()
		    else ()
		)
		lowerCamelCase_	:			int       			=  (MaMaaaForConditionalGeneration,) if is_torch_available() else ()
		lowerCamelCase_	:			int       			=  (
		    {
		        """conversational""": MaMaaaForConditionalGeneration,
		        """feature-extraction""": MaMaaaModel,
		        """summarization""": MaMaaaForConditionalGeneration,
		        """text2text-generation""": MaMaaaForConditionalGeneration,
		        """translation""": MaMaaaForConditionalGeneration,
		    }
		    if is_torch_available()
		    else {}
		)
		lowerCamelCase_	:			List[Any]       			=  True
		lowerCamelCase_	:			Dict       			=  True
		lowerCamelCase_	:			Tuple       			=  False
		lowerCamelCase_	:			Optional[Any]       			=  False






		def _snake_case		(						self				:     Dict   ,  UpperCAmelCase				:     Optional[Any]   ,  UpperCAmelCase				:     Optional[Any]   ,  UpperCAmelCase				:     List[str]   ,  UpperCAmelCase				:     int   ,  UpperCAmelCase				:     Dict):
				if pipeline_test_casse_name == "TranslationPipelineTests":
						# Get `ValueError: Translation requires a `src_lang` and a `tgt_lang` for this model`.
						# `M2M100Config` was never used in pipeline tests: cannot create a simple tokenizer.
						return True

				return False






		def _snake_case		(						self				:     str):
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						MaMaaaModelTester(self)
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						ConfigTester(self   ,  config_class=UpperCAmelCase)






		def _snake_case		(						self				:     Optional[int]):
				self.config_tester.run_common_tests()






		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:Any				     =						self.model_tester.prepare_config_and_inputs()
				for model_class in self.all_model_classes:
						SCREAMING_SNAKE_CASE_				:str				     =						model_class(UpperCAmelCase)

						with tempfile.TemporaryDirectory() as tmpdirname:
								model.save_pretrained(UpperCAmelCase)
								SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:List[str]				     =						model_class.from_pretrained(UpperCAmelCase   ,  output_loading_info=UpperCAmelCase)
						self.assertEqual(info["missing_keys"]   ,  [])






		def _snake_case		(						self				:     Optional[int]):
				SCREAMING_SNAKE_CASE_				:Dict				     =						self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_decoder_model_past_large_inputs(*UpperCAmelCase)






		def _snake_case		(						self				:     Optional[Any]):
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						self.model_tester.prepare_config_and_inputs_for_common()
				self.model_tester.check_encoder_decoder_model_standalone(*UpperCAmelCase)






		def _snake_case		(						self				:     int):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:Tuple				     =						self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in (MaMaaaModel, MaMaaaForConditionalGeneration):
						SCREAMING_SNAKE_CASE_				:Tuple				     =						model_class(UpperCAmelCase)
						model.to(UpperCAmelCase)
						model.eval()

						SCREAMING_SNAKE_CASE_				:Dict				     =						copy.deepcopy(self._prepare_for_class(UpperCAmelCase   ,  UpperCAmelCase))

						if not self.is_encoder_decoder:
								SCREAMING_SNAKE_CASE_				:Optional[int]				     =						inputs["input_ids"]
								del inputs["input_ids"]
						else:
								SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						inputs["input_ids"]
								SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						inputs.get("decoder_input_ids"   ,  UpperCAmelCase)
								del inputs["input_ids"]
								inputs.pop("decoder_input_ids"   ,  UpperCAmelCase)

						SCREAMING_SNAKE_CASE_				:Any				     =						model.get_input_embeddings()
						if not self.is_encoder_decoder:
								SCREAMING_SNAKE_CASE_				:List[Any]				     =						wte(UpperCAmelCase)
						else:
								SCREAMING_SNAKE_CASE_				:Any				     =						wte(UpperCAmelCase)
								SCREAMING_SNAKE_CASE_				:List[Any]				     =						wte(UpperCAmelCase)

						with torch.no_grad():
								model(**UpperCAmelCase)[0]







		def _snake_case		(						self				:     str):
				SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:List[str]				     =						self.model_tester.prepare_config_and_inputs()
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						input_dict["input_ids"]
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						input_ids.ne(1).to(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:str				     =						MaMaaaForConditionalGeneration(UpperCAmelCase).eval().to(UpperCAmelCase)
				if torch_device == "cuda":
						model.half()
				model.generate(UpperCAmelCase   ,  attention_mask=UpperCAmelCase)
				model.generate(num_beams=4   ,  do_sample=UpperCAmelCase   ,  early_stopping=UpperCAmelCase   ,  num_return_sequences=3)




def     lowercase	(    a ):



		'''simple docstring'''




		return torch.tensor(a     , dtype=torch.long     , device=a )


SCREAMING_SNAKE_CASE__     					=			1e-4



@require_torch
@require_sentencepiece
@require_tokenizers
@slow
class 						_UpperCAmelCase      (     unittest.TestCase							):






		@cached_property
		def _snake_case		(						self				:     Optional[int]):
				return MaMaaaTokenizer.from_pretrained("facebook/m2m100_418M")






		def _snake_case		(						self				:     Tuple):
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						MaMaaaModel.from_pretrained("facebook/m2m100_418M").to(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:Tuple				     =						_long_tensor([[12_80_28, 98, 12, 3_05_27, 27_32, 1_59, 77_55, 6_19_04, 3_91_44, 38, 2]])
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						_long_tensor([[2, 12_80_28, 98, 12, 3_05_27, 27_32, 1_59, 77_55, 6_19_04, 3_91_44, 38]])
				SCREAMING_SNAKE_CASE_				:Dict				     =						prepare_mam_aaa_inputs_dict(model.config   ,  UpperCAmelCase   ,  UpperCAmelCase)
				with torch.no_grad():
						SCREAMING_SNAKE_CASE_				:Optional[int]				     =						model(**UpperCAmelCase)[0]
				SCREAMING_SNAKE_CASE_				:List[str]				     =						torch.Size((1, 11, 10_24))
				self.assertEqual(output.shape   ,  UpperCAmelCase)
				# change to expected output here
				SCREAMING_SNAKE_CASE_				:Dict				     =						torch.tensor(
				    [[-0.7780, -0.1676, 0.1038], [-6.7556, -1.3992, 0.0567], [-7.5383, -0.5920, -0.2779]]   ,  device=UpperCAmelCase)
				self.assertTrue(torch.allclose(output[:, :3, :3]   ,  UpperCAmelCase   ,  atol=UpperCAmelCase))






		def _snake_case		(						self				:     List[Any]):
				SCREAMING_SNAKE_CASE_				:Any				     =						MaMaaaForConditionalGeneration.from_pretrained("facebook/m2m100_418M").to(UpperCAmelCase)

				# change to intended input
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						_long_tensor([[12_80_28, 98, 12, 3_05_27, 27_32, 1_59, 77_55, 6_19_04, 3_91_44, 38, 2]])
				SCREAMING_SNAKE_CASE_				:str				     =						_long_tensor([[2, 12_80_28, 98, 12, 3_05_27, 27_32, 1_59, 77_55, 6_19_04, 3_91_44, 38]])
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						prepare_mam_aaa_inputs_dict(model.config   ,  UpperCAmelCase   ,  UpperCAmelCase)
				with torch.no_grad():
						SCREAMING_SNAKE_CASE_				:Tuple				     =						model(**UpperCAmelCase)[0]
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						torch.Size((1, 11, model.config.vocab_size))
				self.assertEqual(output.shape   ,  UpperCAmelCase)
				# change to expected output here
				SCREAMING_SNAKE_CASE_				:Dict				     =						torch.tensor(
				    [[-1.0448, -1.0411, 3.7992], [-3.2191, -3.2386, -1.3451], [-3.6210, -3.5993, 0.4925]]   ,  device=UpperCAmelCase)
				self.assertTrue(torch.allclose(output[:, :3, :3]   ,  UpperCAmelCase   ,  atol=UpperCAmelCase))







		def _snake_case		(						self				:     int):
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						MaMaaaForConditionalGeneration.from_pretrained("facebook/m2m100_418M").to(UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:List[Any]				     =						MaMaaaTokenizer.from_pretrained("facebook/m2m100_418M"   ,  src_lang="fr"   ,  tgt_lang="en")

				SCREAMING_SNAKE_CASE_				:List[Any]				     =						[
				    "L'affaire NSA souligne l'absence totale de débat sur le renseignement",
				    "Selon moi, il y a deux niveaux de réponse de la part du gouvernement français.",
				    "Lorsque François Hollande téléphone à Barack Obama ou quand le ministre des affaires étrangères Laurent"
				    " Fabius convoque l'ambassadeur des Etats-Unis, ils réagissent à une vraie découverte, qui est celle de"
				    " l'ampleur de la surveillance américaine sur l'ensemble des communications en France.",
				]

				# The below article tests that we don't add any hypotheses outside of the top n_beams
				SCREAMING_SNAKE_CASE_				:Tuple				     =						tokenizer(UpperCAmelCase   ,  padding=UpperCAmelCase   ,  return_tensors="pt")

				SCREAMING_SNAKE_CASE_				:List[str]				     =						model.generate(
				    input_ids=dct["input_ids"].to(UpperCAmelCase)   ,  attention_mask=dct["attention_mask"].to(UpperCAmelCase)   ,  num_beams=5   ,  forced_bos_token_id=tokenizer.get_lang_id("en")   ,  )

				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						[
				    "The NSA case highlights the total absence of intelligence debate",
				    "I think there are two levels of response from the French government.",
				    "When François Hollande calls Barack Obama or when Foreign Minister Laurent Fabius calls the U.S."
				    " Ambassador, they respond to a real discovery, which is that of the scale of U.S. surveillance on all"
				    " communications in France.",
				]

				SCREAMING_SNAKE_CASE_				:int				     =						tokenizer.batch_decode(
				    hypotheses_batch.tolist()   ,  clean_up_tokenization_spaces=UpperCAmelCase   ,  skip_special_tokens=UpperCAmelCase)
				assert generated == expected_en










from timeit import timeit


def     lowercase	(    a ):



		'''simple docstring'''




		if number < 0:
				raise ValueError("the value of input must not be negative" )
		SCREAMING_SNAKE_CASE_				:Optional[int]				     =						0
		while number:
				number &= number - 1
				result += 1
		return result


def     lowercase	(    a ):



		'''simple docstring'''




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


def     lowercase	(    ):



		'''simple docstring'''




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

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


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		benchmark()






