





'''simple docstring'''


import json
import os
import tempfile

import transformers

import datasets
from utils import generate_example_dataset, get_duration


_SCREAMING_SNAKE_CASE	 =							50_00_00

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


@get_duration
def 	__a(SCREAMING_SNAKE_CASE_  :					datasets.Dataset		,       **SCREAMING_SNAKE_CASE_  :					Dict    ):



    '''simple docstring'''





    _lowerCAmelCase				=      dataset.map(**SCREAMING_SNAKE_CASE_    )


@get_duration
def 	__a(SCREAMING_SNAKE_CASE_  :					datasets.Dataset		,       **SCREAMING_SNAKE_CASE_  :					Dict    ):



    '''simple docstring'''





    _lowerCAmelCase				=      dataset.filter(**SCREAMING_SNAKE_CASE_    )


def 	__a():



    '''simple docstring'''





    _lowerCAmelCase				=      {"num examples": SPEED_TEST_N_EXAMPLES}
    with tempfile.TemporaryDirectory() as tmp_dir:
        _lowerCAmelCase				=      datasets.Features({"text": datasets.Value("string"    ), "numbers": datasets.Value("float32"    )}    )
        _lowerCAmelCase				=      generate_example_dataset(
            os.path.join(SCREAMING_SNAKE_CASE_		,       "dataset.arrow"    )		,       SCREAMING_SNAKE_CASE_		,       num_examples=SCREAMING_SNAKE_CASE_    )

        _lowerCAmelCase				=      transformers.AutoTokenizer.from_pretrained("bert-base-cased"		,       use_fast=SCREAMING_SNAKE_CASE_    )

        def tokenize(SCREAMING_SNAKE_CASE_  :					int    ):
            return tokenizer(examples["text"]    )

        _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_    )

        _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       batched=SCREAMING_SNAKE_CASE_    )

        _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=lambda SCREAMING_SNAKE_CASE_    : None		,       batched=SCREAMING_SNAKE_CASE_    )

        with dataset.formatted_as(type="numpy"    ):
            _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=lambda SCREAMING_SNAKE_CASE_    : None		,       batched=SCREAMING_SNAKE_CASE_    )

        with dataset.formatted_as(type="pandas"    ):
            _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=lambda SCREAMING_SNAKE_CASE_    : None		,       batched=SCREAMING_SNAKE_CASE_    )

        with dataset.formatted_as(type="torch"		,       columns="numbers"    ):
            _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=lambda SCREAMING_SNAKE_CASE_    : None		,       batched=SCREAMING_SNAKE_CASE_    )

        with dataset.formatted_as(type="tensorflow"		,       columns="numbers"    ):
            _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=lambda SCREAMING_SNAKE_CASE_    : None		,       batched=SCREAMING_SNAKE_CASE_    )

        _lowerCAmelCase				=      map(SCREAMING_SNAKE_CASE_		,       function=SCREAMING_SNAKE_CASE_		,       batched=SCREAMING_SNAKE_CASE_    )

        _lowerCAmelCase				=      filter(SCREAMING_SNAKE_CASE_    )

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


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









'''simple docstring'''


from __future__ import annotations


def 	__a(SCREAMING_SNAKE_CASE_  :					list[float]		,       SCREAMING_SNAKE_CASE_  :					list[float]    ):



    '''simple docstring'''





    _lowerCAmelCase				=      sorted(numsa + numsa    )
    _lowerCAmelCase			,			_lowerCAmelCase				=      divmod(len(SCREAMING_SNAKE_CASE_    )		,       2    )
    if mod == 1:
        return all_numbers[div]
    else:
        return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       _SCREAMING_SNAKE_CASE	 =							[float(x) for x in input("Enter the elements of first array: ").split()]
       _SCREAMING_SNAKE_CASE	 =							[float(x) for x in input("Enter the elements of second array: ").split()]
       print(f'''The median of two arrays is: {median_of_two_arrays(array_a, array_a)}''')


