






import math
import unittest




def 					lowercase__				(					__snake_case   :							int  ):


					'''simple docstring'''


					assert isinstance(__snake_case					,	__snake_case  ) and (
					    number >= 0
					), "'number' must been an int and positive"

					if 1 < number < 4:
										# 2 and 3 are primes
										return True
					elif number < 2 or number % 2 == 0 or number % 3 == 0:
										# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
										return False

					# All primes number are in format of 6k +/- 1
					for i in range(5					,	int(math.sqrt(__snake_case  ) + 1  )					,	6  ):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True



class   lowerCamelCase				(unittest.TestCase      ):







		'''simple docstring'''



		def  __UpperCAmelCase      (							self       )     ->							Tuple:
							self.assertTrue(is_prime(2       )       )
							self.assertTrue(is_prime(3       )       )
							self.assertTrue(is_prime(5       )       )
							self.assertTrue(is_prime(7       )       )
							self.assertTrue(is_prime(1_1       )       )
							self.assertTrue(is_prime(1_3       )       )
							self.assertTrue(is_prime(1_7       )       )
							self.assertTrue(is_prime(1_9       )       )
							self.assertTrue(is_prime(2_3       )       )
							self.assertTrue(is_prime(2_9       )       )



		def  __UpperCAmelCase      (							self       )     ->							Tuple:
							with self.assertRaises(_UpperCamelCase       ):
												is_prime(-1_9       )
							self.assertFalse(
							    is_prime(0       )    ,		'Zero doesn\'t have any positive factors, primes must have exactly two.'    ,		)
							self.assertFalse(
							    is_prime(1       )    ,		'One only has 1 positive factor, primes must have exactly two.'    ,		)
							self.assertFalse(is_prime(2 * 2       )       )
							self.assertFalse(is_prime(2 * 3       )       )
							self.assertFalse(is_prime(3 * 3       )       )
							self.assertFalse(is_prime(3 * 5       )       )
							self.assertFalse(is_prime(3 * 5 * 7       )       )


if __name__ == "__main__":
		unittest.main()














import argparse

import torch

from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert
from transformers.utils import logging


logging.set_verbosity_info()




def 					lowercase__				(					__snake_case   :							Optional[Any]					,	__snake_case   :							Any					,	__snake_case   :							int  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Union[str, Any]						=						RemBertConfig.from_json_file(__snake_case  )
					print('Building PyTorch model from configuration: {}'.format(str(__snake_case  )  )  )
					UpperCAmelCase_   :				Dict						=						RemBertModel(__snake_case  )

					# Load weights from tf checkpoint
					load_tf_weights_in_rembert(__snake_case					,	__snake_case					,	__snake_case  )

					# Save pytorch-model
					print('Save PyTorch model to {}'.format(__snake_case  )  )
					torch.save(model.state_dict()					,	__snake_case  )


if __name__ == "__main__":
		__UpperCAmelCase     							=						argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
		)
		parser.add_argument(
		    '--rembert_config_file',
		    default=None,
		    type=str,
		    required=True,
		    help=(
		        'The config json file corresponding to the pre-trained RemBERT model. \n'
		        'This specifies the model architecture.'
		    ),
		)
		parser.add_argument(
		    '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
		)
		__UpperCAmelCase     							=						parser.parse_args()
		convert_rembert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.rembert_config_file, args.pytorch_dump_path)






