
"""simple docstring"""




import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory

from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
    convert,
    ensure_valid_input,
    generate_identified_filename,
    infer_shapes,
    quantize,
)
from transformers.testing_utils import require_tf, require_tokenizers, require_torch, slow





class 			snake_case  :

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									return None







class 			snake_case  :

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									return None







class 			snake_case  (				unittest.TestCase ):
							UpperCAmelCase__      =   [
							    # (model_name, model_kwargs)
							    ('''bert-base-cased''', {}),
							    ('''gpt2''', {'''use_cache''': False}),  # We don't support exporting GPT2 past keys anymore
							]

							@require_tf
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
											self._test_export(SCREAMING_SNAKE_CASE_							,							'''tf'''							,							12							,							**SCREAMING_SNAKE_CASE_     )

							@require_torch
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
											self._test_export(SCREAMING_SNAKE_CASE_							,							'''pt'''							,							12							,							**SCREAMING_SNAKE_CASE_     )

							@require_torch
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									from transformers import BertModel

									SCREAMING_SNAKE_CASE_    			=			['''[UNK]''', '''[SEP]''', '''[CLS]''', '''[PAD]''', '''[MASK]''', '''some''', '''other''', '''words''']
									with NamedTemporaryFile(mode='''w+t'''     ) as vocab_file:
											vocab_file.write('''\n'''.join(SCREAMING_SNAKE_CASE_     )     )
											vocab_file.flush()
											SCREAMING_SNAKE_CASE_    			=			BertTokenizerFast(vocab_file.name     )

									with TemporaryDirectory() as bert_save_dir:
											SCREAMING_SNAKE_CASE_    			=			BertModel(BertConfig(vocab_size=len(SCREAMING_SNAKE_CASE_     )     )     )
											model.save_pretrained(SCREAMING_SNAKE_CASE_     )
											self._test_export(SCREAMING_SNAKE_CASE_							,							'''pt'''							,							12							,							SCREAMING_SNAKE_CASE_     )

							@require_tf
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
											SCREAMING_SNAKE_CASE_    			=			self._test_export(SCREAMING_SNAKE_CASE_							,							'''tf'''							,							12							,							**SCREAMING_SNAKE_CASE_     )
											SCREAMING_SNAKE_CASE_    			=			quantize(Path(SCREAMING_SNAKE_CASE_     )     )

											# Ensure the actual quantized model is not bigger than the original one
											if quantized_path.stat().st_size >= Path(SCREAMING_SNAKE_CASE_     ).stat().st_size:
													self.fail('''Quantized model is bigger than initial ONNX model'''     )

							@require_torch
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
											SCREAMING_SNAKE_CASE_    			=			self._test_export(SCREAMING_SNAKE_CASE_							,							'''pt'''							,							12							,							**SCREAMING_SNAKE_CASE_     )
											SCREAMING_SNAKE_CASE_    			=			quantize(SCREAMING_SNAKE_CASE_     )

											# Ensure the actual quantized model is not bigger than the original one
											if quantized_path.stat().st_size >= Path(SCREAMING_SNAKE_CASE_     ).stat().st_size:
													self.fail('''Quantized model is bigger than initial ONNX model'''     )

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_=None							,							**SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									try:
											# Compute path
											with TemporaryDirectory() as tempdir:
													SCREAMING_SNAKE_CASE_    			=			Path(SCREAMING_SNAKE_CASE_     ).joinpath('''model.onnx'''     )

											# Remove folder if exists
											if path.parent.exists():
													path.parent.rmdir()

											# Export
											convert(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							**SCREAMING_SNAKE_CASE_     )

											return path
									except Exception as e:
											self.fail(SCREAMING_SNAKE_CASE_     )

							@require_torch
							@require_tokenizers
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									from transformers import BertModel

									SCREAMING_SNAKE_CASE_    			=			BertModel(BertConfig.from_pretrained('''lysandre/tiny-bert-random'''     )     )
									SCREAMING_SNAKE_CASE_    			=			BertTokenizerFast.from_pretrained('''lysandre/tiny-bert-random'''     )
									self._test_infer_dynamic_axis(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							'''pt'''     )

							@require_tf
							@require_tokenizers
							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									from transformers import TFBertModel

									SCREAMING_SNAKE_CASE_    			=			TFBertModel(BertConfig.from_pretrained('''lysandre/tiny-bert-random'''     )     )
									SCREAMING_SNAKE_CASE_    			=			BertTokenizerFast.from_pretrained('''lysandre/tiny-bert-random'''     )
									self._test_infer_dynamic_axis(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							'''tf'''     )

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			FeatureExtractionPipeline(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     )

									SCREAMING_SNAKE_CASE_    			=			['''input_ids''', '''token_type_ids''', '''attention_mask''', '''output_0''', '''output_1''']
									SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_    			=			infer_shapes(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     )

									# Assert all variables are present
									self.assertEqual(len(SCREAMING_SNAKE_CASE_     )							,							len(SCREAMING_SNAKE_CASE_     )     )
									self.assertTrue(all(var_name in shapes for var_name in variable_names     )     )
									self.assertSequenceEqual(variable_names[:3]							,							SCREAMING_SNAKE_CASE_     )
									self.assertSequenceEqual(variable_names[3:]							,							SCREAMING_SNAKE_CASE_     )

									# Assert inputs are {0: batch, 1: sequence}
									for var_name in ["input_ids", "token_type_ids", "attention_mask"]:
											self.assertDictEqual(shapes[var_name]							,							{0: '''batch''', 1: '''sequence'''}     )

									# Assert outputs are {0: batch, 1: sequence} and {0: batch}
									self.assertDictEqual(shapes['''output_0''']							,							{0: '''batch''', 1: '''sequence'''}     )
									self.assertDictEqual(shapes['''output_1''']							,							{0: '''batch'''}     )

							def _lowercase       (self     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			['''input_ids''', '''attention_mask''', '''token_type_ids''']
									SCREAMING_SNAKE_CASE_    			=			{'''input_ids''': [1, 2, 3, 4], '''attention_mask''': [0, 0, 0, 0], '''token_type_ids''': [1, 1, 1, 1]}
									SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_    			=			ensure_valid_input(FuncContiguousArgs()							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     )

									# Should have exactly the same number of args (all are valid)
									self.assertEqual(len(SCREAMING_SNAKE_CASE_     )							,							3     )

									# Should have exactly the same input names
									self.assertEqual(set(SCREAMING_SNAKE_CASE_     )							,							set(SCREAMING_SNAKE_CASE_     )     )

									# Parameter should be reordered according to their respective place in the function:
									# (input_ids, token_type_ids, attention_mask)
									self.assertEqual(SCREAMING_SNAKE_CASE_							,							(tokens['''input_ids'''], tokens['''token_type_ids'''], tokens['''attention_mask'''])     )

									# Generated args are interleaved with another args (for instance parameter "past" in GPT2)
									SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_    			=			ensure_valid_input(FuncNonContiguousArgs()							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     )

									# Should have exactly the one arg (all before the one not provided "some_other_args")
									self.assertEqual(len(SCREAMING_SNAKE_CASE_     )							,							1     )
									self.assertEqual(len(SCREAMING_SNAKE_CASE_     )							,							1     )

									# Should have only "input_ids"
									self.assertEqual(inputs_args[0]							,							tokens['''input_ids''']     )
									self.assertEqual(ordered_input_names[0]							,							'''input_ids'''     )







							def _lowercase       (self     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			generate_identified_filename(Path('''/home/something/my_fake_model.onnx'''     )							,							'''-test'''     )
									self.assertEqual('''/home/something/my_fake_model-test.onnx'''							,							generated.as_posix()     )

"""simple docstring"""




from __future__ import annotations

import math



def 							_lowerCamelCase			(			__a     ):

		if num <= 0:
				SCREAMING_SNAKE_CASE_    			=			F'{num}: Invalid input, please enter a positive integer.'
				raise ValueError(__a     )

		SCREAMING_SNAKE_CASE_    			=			[True] * (num + 1)
		SCREAMING_SNAKE_CASE_    			=			[]
		SCREAMING_SNAKE_CASE_    			=			2
		SCREAMING_SNAKE_CASE_    			=			int(math.sqrt(__a     )     )

		while start <= end:
				# If start is a prime
				if sieve[start] is True:
						prime.append(__a     )

						# Set multiples of start be False
						for i in range(start * start,				num + 1,				__a     ):
								if sieve[i] is True:
										SCREAMING_SNAKE_CASE_    			=			False

				start += 1

		for j in range(end + 1,				num + 1     ):
				if sieve[j] is True:
						prime.append(__a     )

		return prime


if __name__ == "__main__":
						print(prime_sieve(int(input('Enter a positive integer: ').strip())))