






import json
import os
import tempfile

import transformers

import datasets
from utils import generate_example_dataset, get_duration


A__			:    Dict         =				50_00_00

A__			:    str         =				os.path.split(__file__)
A__			:    Optional[Any]         =				os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json'))






@get_duration
def 						a    (		lowerCamelCase_	,     **lowerCamelCase_       ):






				'''simple docstring'''
				lowercase__     				=    dataset.map(**lowerCamelCase_       )






@get_duration
def 						a    (		lowerCamelCase_	,     **lowerCamelCase_       ):






				'''simple docstring'''
				lowercase__     				=    dataset.filter(**lowerCamelCase_       )






def 						a    (		):






				'''simple docstring'''
				lowercase__     				=    {'''num examples''': SPEED_TEST_N_EXAMPLES}
				with tempfile.TemporaryDirectory() as tmp_dir:
								lowercase__     				=    datasets.Features({'''text''': datasets.Value('''string'''       ), '''numbers''': datasets.Value('''float32'''       )}       )
								lowercase__     				=    generate_example_dataset(
								    os.path.join(lowerCamelCase_	,     '''dataset.arrow'''       )	,     lowerCamelCase_	,     num_examples=lowerCamelCase_       )

								lowercase__     				=    transformers.AutoTokenizer.from_pretrained('''bert-base-cased'''	,     use_fast=lowerCamelCase_       )

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

								lowercase__     				=    map(lowerCamelCase_       )

								lowercase__     				=    map(lowerCamelCase_	,     batched=lowerCamelCase_       )

								lowercase__     				=    map(lowerCamelCase_	,     function=lambda lowerCamelCase_       : None	,     batched=lowerCamelCase_       )

								with dataset.formatted_as(type='''numpy'''       ):
												lowercase__     				=    map(lowerCamelCase_	,     function=lambda lowerCamelCase_       : None	,     batched=lowerCamelCase_       )

								with dataset.formatted_as(type='''pandas'''       ):
												lowercase__     				=    map(lowerCamelCase_	,     function=lambda lowerCamelCase_       : None	,     batched=lowerCamelCase_       )

								with dataset.formatted_as(type='''torch'''	,     columns='''numbers'''       ):
												lowercase__     				=    map(lowerCamelCase_	,     function=lambda lowerCamelCase_       : None	,     batched=lowerCamelCase_       )

								with dataset.formatted_as(type='''tensorflow'''	,     columns='''numbers'''       ):
												lowercase__     				=    map(lowerCamelCase_	,     function=lambda lowerCamelCase_       : None	,     batched=lowerCamelCase_       )

								lowercase__     				=    map(lowerCamelCase_	,     function=lowerCamelCase_	,     batched=lowerCamelCase_       )

								lowercase__     				=    filter(lowerCamelCase_       )

								# 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(lowerCamelCase_	,     '''wb'''       ) as f:
								f.write(json.dumps(lowerCamelCase_       ).encode('''utf-8'''       )       )


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












from collections import defaultdict
from math import gcd






def 						a    (		lowerCamelCase_ = 150_0000       ):






				'''simple docstring'''
				lowercase__     				=    defaultdict(lowerCamelCase_       )
				lowercase__     				=    2
				while 2 * euclid_m * (euclid_m + 1) <= limit:
								for euclid_n in range((euclid_m % 2) + 1	,     lowerCamelCase_	,     2       ):
												if gcd(lowerCamelCase_	,     lowerCamelCase_       ) > 1:
																continue
												lowercase__     				=    2 * euclid_m * (euclid_m + euclid_n)
												for perimeter in range(lowerCamelCase_	,     limit + 1	,     lowerCamelCase_       ):
																frequencies[perimeter] += 1
								euclid_m += 1
				return sum(1 for frequency in frequencies.values() if frequency == 1       )


if __name__ == "__main__":
							print(F"{solution() = }")




