
'''simple docstring'''





import json
import os
import tempfile

import transformers

import datasets
from utils import generate_example_dataset, get_duration


UpperCAmelCase    					=   500_000

UpperCAmelCase					,	UpperCAmelCase    					=   os.path.split(__file__)
UpperCAmelCase    					=   os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))

@get_duration
def      A (       A_							:					datasets.Dataset    ,							**A_							:					Any       ):
						snake_case       :     Optional[Any] =    dataset.map(**A_       )

@get_duration
def      A (       A_							:					datasets.Dataset    ,							**A_							:					Optional[int]       ):
						snake_case       :     int =    dataset.filter(**A_       )

def      A (       ):
						snake_case       :     Union[str, Any] =    {'''num examples''': SPEED_TEST_N_EXAMPLES}
						with tempfile.TemporaryDirectory() as tmp_dir:
												snake_case       :     int =    datasets.Features({'''text''': datasets.Value('''string'''       ), '''numbers''': datasets.Value('''float32'''       )}       )
												snake_case       :     Optional[int] =    generate_example_dataset(
												    os.path.join(A_    ,							'''dataset.arrow'''       )    ,							A_    ,							num_examples=A_       )

												snake_case       :     str =    transformers.AutoTokenizer.from_pretrained('''bert-base-cased'''    ,							use_fast=A_       )

												def tokenize(A_							:					Tuple       ):
																		return tokenizer(examples['''text''']       )

												snake_case       :     Tuple =    map(A_       )

												snake_case       :     str =    map(A_    ,							batched=A_       )

												snake_case       :     Optional[int] =    map(A_    ,							function=lambda A_       : None    ,							batched=A_       )

												with dataset.formatted_as(type='''numpy'''       ):
																		snake_case       :     Union[str, Any] =    map(A_    ,							function=lambda A_       : None    ,							batched=A_       )

												with dataset.formatted_as(type='''pandas'''       ):
																		snake_case       :     Union[str, Any] =    map(A_    ,							function=lambda A_       : None    ,							batched=A_       )

												with dataset.formatted_as(type='''torch'''    ,							columns='''numbers'''       ):
																		snake_case       :     Dict =    map(A_    ,							function=lambda A_       : None    ,							batched=A_       )

												with dataset.formatted_as(type='''tensorflow'''    ,							columns='''numbers'''       ):
																		snake_case       :     Dict =    map(A_    ,							function=lambda A_       : None    ,							batched=A_       )

												snake_case       :     int =    map(A_    ,							function=A_    ,							batched=A_       )

												snake_case       :     List[Any] =    filter(A_       )

												# Activate later when tokenizer support batched inputs
												# with dataset.formatted_as(type='numpy'):
												#     times[func.__name__ + " fast-tokenizer batched numpy"] = func(dataset, function=tokenize, batched=True)

						with open(A_    ,							'''wb'''       ) as f:
												f.write(json.dumps(A_       ).encode('''utf-8'''       )       )


if __name__ == "__main__":  # useful to run the profiler
						benchmark_map_filter()



'''simple docstring'''





from __future__ import annotations

import math

def      A (       A_							:					int       ):

						if num <= 0:
												snake_case       :     List[Any] =    F"""{num}: Invalid input, please enter a positive integer."""
												raise ValueError(A_       )

						snake_case       :     Optional[Any] =    [True] * (num + 1)
						snake_case       :     List[str] =    []
						snake_case       :     List[Any] =    2
						snake_case       :     str =    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:
																														snake_case       :     int =    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())))

