
import math
import unittest


def 			UpperCamelCase					(    __lowerCamelCase     : int    ):
       assert isinstance(__lowerCamelCase				,					__lowerCamelCase    ) 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(__lowerCamelCase    ) + 1    )				,					6    ):
              if number % i == 0 or number % (i + 2) == 0:
                     return False
       return True






class   UpperCAmelCase		(						unittest.TestCase ):



   def 				_SCREAMING_SNAKE_CASE   (self		:					Optional[Any] )		->	Any:


          '''simple docstring'''


          self.assertTrue(is_prime(2 ) )
          self.assertTrue(is_prime(3 ) )
          self.assertTrue(is_prime(5 ) )
          self.assertTrue(is_prime(7 ) )
          self.assertTrue(is_prime(11 ) )
          self.assertTrue(is_prime(13 ) )
          self.assertTrue(is_prime(17 ) )
          self.assertTrue(is_prime(19 ) )
          self.assertTrue(is_prime(23 ) )
          self.assertTrue(is_prime(29 ) )



   def 				_SCREAMING_SNAKE_CASE   (self		:					int )		->	List[str]:


          '''simple docstring'''


          with self.assertRaises(snake_case__ ):
                 is_prime(-19 )
          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()













"""simple docstring"""






import argparse

import torch

from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()



def 					_A			(__a    ,				__a    ,				__a							) ->       Dict:
    """simple docstring"""






    if gpta_config_file == "":
        SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		GPTaConfig()
    else:
        SCREAMING_SNAKE_CASE_      :  Tuple    						=		GPTaConfig.from_json_file(__a							)
    SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		GPTaModel(__a							)

    # Load weights from numpy
    load_tf_weights_in_gpta(__a    ,				__a    ,				__a							)

    # Save pytorch-model
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		pytorch_dump_folder_path + '''/''' + WEIGHTS_NAME
    SCREAMING_SNAKE_CASE_      :  List[Any]    						=		pytorch_dump_folder_path + '''/''' + CONFIG_NAME
    print(f'Save PyTorch model to {pytorch_weights_dump_path}'							)
    torch.save(model.state_dict()    ,				__a							)
    print(f'Save configuration file to {pytorch_config_dump_path}'							)
    with open(__a    ,				'''w'''    ,				encoding='''utf-8'''							) as f:
        f.write(config.to_json_string()							)


if __name__ == "__main__":
  UpperCAmelCase_   : str   			= argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      """--gpt2_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
  )
  parser.add_argument(
      """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
  )
  parser.add_argument(
      """--gpt2_config_file""",
      default="""""",
      type=str,
      help=(
          """An optional config json file corresponding to the pre-trained OpenAI model. \n"""
          """This specifies the model architecture."""
      ),
  )
  UpperCAmelCase_   : Union[str, Any]   			= parser.parse_args()
  convert_gpta_checkpoint_to_pytorch(args.gpta_checkpoint_path, args.gpta_config_file, args.pytorch_dump_folder_path)


