


'''simple docstring'''






import os
import tempfile
from functools import partial
from unittest import TestCase
from unittest.mock import patch

import datasets
import datasets.config

from .utils import require_beam




class 		a__    (							datasets.BeamBasedBuilder  ):





							'''simple docstring'''






							def   __SCREAMING_SNAKE_CASE							(		self       )	->							str:
														return datasets.DatasetInfo(
														    features=datasets.Features({'''content''': datasets.Value('''string'''       )}       ) ,   supervised_keys=lowerCamelCase_ ,   )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							Union[str, Any]:
														return [datasets.SplitGenerator(name=datasets.Split.TRAIN ,   gen_kwargs={'''examples''': get_test_dummy_examples()}       )]







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							int:
														import apache_beam as beam

														return pipeline | "Load Examples" >> beam.Create(lowerCamelCase_       )




class 		a__    (							datasets.BeamBasedBuilder  ):





							'''simple docstring'''






							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Union[str, Any]:
														return datasets.DatasetInfo(
														    features=datasets.Features({'''a''': datasets.Sequence({'''b''': datasets.Value('''string'''       )}       )}       ) ,   supervised_keys=lowerCamelCase_ ,   )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							Dict:
														return [
														    datasets.SplitGenerator(name=datasets.Split.TRAIN ,   gen_kwargs={'''examples''': get_test_nested_examples()}       )
														]







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							Tuple:
														import apache_beam as beam

														return pipeline | "Load Examples" >> beam.Create(lowerCamelCase_       )


def  _snake_case       (					)						->   Tuple:
							return [(i, {"content": content}) for i, content in enumerate(['''foo''', '''bar''', '''foobar''']	)]


def  _snake_case       (					)						->   Any:
							return [(i, {"a": {"b": [content]}}) for i, content in enumerate(['''foo''', '''bar''', '''foobar''']	)]






class 		a__    (							a__  ):





							'''simple docstring'''






							@require_beam
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Tuple:
														lowerCAmelCase__	       =     len(get_test_dummy_examples()       )
														with tempfile.TemporaryDirectory() as tmp_cache_dir:
																					lowerCAmelCase__	       =     DummyBeamDataset(cache_dir=lowerCamelCase_ ,   beam_runner='''DirectRunner'''       )
																					builder.download_and_prepare()
																					self.assertTrue(
																					    os.path.exists(
																					        os.path.join(lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   F"""{builder.name}-train.arrow"""       )       )       )
																					self.assertDictEqual(builder.info.features ,   datasets.Features({'''content''': datasets.Value('''string'''       )}       )       )
																					lowerCAmelCase__	       =     builder.as_dataset()
																					self.assertEqual(dset['''train'''].num_rows ,   lowerCamelCase_       )
																					self.assertEqual(dset['''train'''].info.splits['''train'''].num_examples ,   lowerCamelCase_       )
																					self.assertDictEqual(dset['''train'''][0] ,   get_test_dummy_examples()[0][1]       )
																					self.assertDictEqual(
																					    dset['''train'''][expected_num_examples - 1] ,   get_test_dummy_examples()[expected_num_examples - 1][1]       )
																					self.assertTrue(
																					    os.path.exists(os.path.join(lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   '''dataset_info.json'''       )       )       )
																					del dset







							@require_beam
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							int:
														import apache_beam as beam

														lowerCAmelCase__	       =     beam.io.parquetio.WriteToParquet

														lowerCAmelCase__	       =     len(get_test_dummy_examples()       )
														with tempfile.TemporaryDirectory() as tmp_cache_dir:
																					lowerCAmelCase__	       =     DummyBeamDataset(cache_dir=lowerCamelCase_ ,   beam_runner='''DirectRunner'''       )
																					with patch('''apache_beam.io.parquetio.WriteToParquet'''       ) as write_parquet_mock:
																												lowerCAmelCase__	       =     partial(lowerCamelCase_ ,   num_shards=2       )
																												builder.download_and_prepare()
																					self.assertTrue(
																					    os.path.exists(
																					        os.path.join(
																					            lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   F"""{builder.name}-train-00000-of-00002.arrow"""       )       )       )
																					self.assertTrue(
																					    os.path.exists(
																					        os.path.join(
																					            lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   F"""{builder.name}-train-00000-of-00002.arrow"""       )       )       )
																					self.assertDictEqual(builder.info.features ,   datasets.Features({'''content''': datasets.Value('''string'''       )}       )       )
																					lowerCAmelCase__	       =     builder.as_dataset()
																					self.assertEqual(dset['''train'''].num_rows ,   lowerCamelCase_       )
																					self.assertEqual(dset['''train'''].info.splits['''train'''].num_examples ,   lowerCamelCase_       )
																					# Order is not preserved when sharding, so we just check that all the elements are there
																					self.assertListEqual(sorted(dset['''train''']['''content''']       ) ,   sorted(['''foo''', '''bar''', '''foobar''']       )       )
																					self.assertTrue(
																					    os.path.exists(os.path.join(lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   '''dataset_info.json'''       )       )       )
																					del dset







							@require_beam
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							str:
														with tempfile.TemporaryDirectory() as tmp_cache_dir:
																					lowerCAmelCase__	       =     DummyBeamDataset(cache_dir=lowerCamelCase_       )
																					self.assertRaises(datasets.builder.MissingBeamOptions ,   builder.download_and_prepare       )







							@require_beam
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Optional[int]:
														lowerCAmelCase__	       =     len(get_test_nested_examples()       )
														with tempfile.TemporaryDirectory() as tmp_cache_dir:
																					lowerCAmelCase__	       =     NestedBeamDataset(cache_dir=lowerCamelCase_ ,   beam_runner='''DirectRunner'''       )
																					builder.download_and_prepare()
																					self.assertTrue(
																					    os.path.exists(
																					        os.path.join(lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   F"""{builder.name}-train.arrow"""       )       )       )
																					self.assertDictEqual(
																					    builder.info.features ,   datasets.Features({'''a''': datasets.Sequence({'''b''': datasets.Value('''string'''       )}       )}       )       )
																					lowerCAmelCase__	       =     builder.as_dataset()
																					self.assertEqual(dset['''train'''].num_rows ,   lowerCamelCase_       )
																					self.assertEqual(dset['''train'''].info.splits['''train'''].num_examples ,   lowerCamelCase_       )
																					self.assertDictEqual(dset['''train'''][0] ,   get_test_nested_examples()[0][1]       )
																					self.assertDictEqual(
																					    dset['''train'''][expected_num_examples - 1] ,   get_test_nested_examples()[expected_num_examples - 1][1]       )
																					self.assertTrue(
																					    os.path.exists(os.path.join(lowerCamelCase_ ,   builder.name ,   '''default''' ,   '''0.0.0''' ,   '''dataset_info.json'''       )       )       )
																					del dset



'''simple docstring'''






from __future__ import annotations


def  _snake_case       (					A			,   A	)						->   float:
							lowerCAmelCase__	       =     sorted(numsa + numsa	)
							lowerCAmelCase__       , lowerCAmelCase__	       =     divmod(len(A	)			,   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()
		__UpperCAmelCase       =							[float(x) for x in input('''Enter the elements of first array: ''').split()]
		__UpperCAmelCase       =							[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)}""")