


"""simple docstring"""
import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


SCREAMING_SNAKE_CASE					:       Any							   =							1000_0000_0000
SCREAMING_SNAKE_CASE					:       List[Any]							   =							1_0000

SCREAMING_SNAKE_CASE   ,    SCREAMING_SNAKE_CASE					:       Dict							   =							os.path.split(__file__)
SCREAMING_SNAKE_CASE					:       str							   =							os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))






def 						lowercase				(	_snake_case		: int	,  _snake_case		: int	)	->datasets.Dataset:
	"""simple docstring"""





	__snake_case      :		Optional[Any]         =							pa.Table.from_pydict({'''col''': [0] * chunk_size}	)
	__snake_case      :		str         =							pa.concat_tables([table] * (num_examples // chunk_size)	)
	return datasets.Dataset(_snake_case	,  fingerprint='''table_100B'''	)



@dataclass
class      _UpperCAmelCase					:






		'''simple docstring'''

		lowerCamelCase__           =42
		lowerCamelCase__           =42
		lowerCamelCase__           =42
		lowerCamelCase__           =42



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Any         =							np.random.default_rng(self.seed   )
			__snake_case      :		Dict         =							rng.integers(low=self.low							,			high=self.high							,			size=self.size   ).tolist()



		def __iter__(self   ):





			'''simple docstring'''

			return iter(self._sampled_values   )



		def __len__(self   ):





			'''simple docstring'''

			return self.size






@get_duration
def 						lowercase				(	_snake_case		: datasets.Dataset	)	->Union[str, Any]:
	"""simple docstring"""





	__snake_case      :		Optional[Any]         =							dataset[0]






@get_duration
def 						lowercase				(	_snake_case		: datasets.Dataset	)	->Dict:
	"""simple docstring"""





	__snake_case      :		Union[str, Any]         =							dataset[-1]






@get_duration
def 						lowercase				(	_snake_case		: datasets.Dataset	)	->Any:
	"""simple docstring"""





	__snake_case      :		List[Any]         =							dataset[range(len(_snake_case	) // 2	,  len(_snake_case	) // 2 + 1_024	)]






@get_duration
def 						lowercase				(	_snake_case		: datasets.Dataset	)	->Optional[Any]:
	"""simple docstring"""





	__snake_case      :		Any         =							dataset[RandIter(0	,  len(_snake_case	)	,  1_024	,  seed=42	)]






def 						lowercase				(	)	->Optional[int]:
	"""simple docstring"""





	__snake_case      :		Dict         =							{'''num examples''': SPEED_TEST_N_EXAMPLES}
	__snake_case      :		Tuple         =							(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
	print('''generating dataset'''	)
	__snake_case      :		Tuple         =							generate_100B_dataset(num_examples=_snake_case	,  chunk_size=_snake_case	)
	print('''Functions'''	)
	for func in functions:
		print(func.__name__	)
		__snake_case      :		Optional[Any]         =							func(_snake_case	)

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


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









"""simple docstring"""
import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput



@dataclass
class      _UpperCAmelCase					(				__snake_case							):






		'''simple docstring'''

		lowerCamelCase__           =42
		lowerCamelCase__           =None
		lowerCamelCase__           =None



class      _UpperCAmelCase					(				unittest.TestCase							):






		'''simple docstring'''

		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Union[str, Any]         =							ModelOutputTest(a=30   )
			self.assertEqual(x.a							,			30   )
			self.assertIsNone(x.b   )
			self.assertIsNone(x.c   )
			with self.assertRaises(a_   ):
				__snake_case      :		str         =							x.d



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Union[str, Any]         =							ModelOutputTest(a=30							,			b=10   )
			self.assertEqual(x[0]							,			30   )
			self.assertEqual(x[1]							,			10   )
			self.assertEqual(x[:2]							,			(30, 10)   )
			self.assertEqual(x[:]							,			(30, 10)   )

			__snake_case      :		List[Any]         =							ModelOutputTest(a=30							,			c=10   )
			self.assertEqual(x[0]							,			30   )
			self.assertEqual(x[1]							,			10   )
			self.assertEqual(x[:2]							,			(30, 10)   )
			self.assertEqual(x[:]							,			(30, 10)   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Optional[int]         =							ModelOutputTest(a=30							,			b=10   )
			self.assertEqual(x['''a''']							,			30   )
			self.assertEqual(x['''b''']							,			10   )
			with self.assertRaises(a_   ):
				__snake_case      :		Optional[int]         =							x['''c''']

			__snake_case      :		Any         =							ModelOutputTest(a=30							,			c=10   )
			self.assertEqual(x['''a''']							,			30   )
			self.assertEqual(x['''c''']							,			10   )
			with self.assertRaises(a_   ):
				__snake_case      :		Optional[int]         =							x['''b''']



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Optional[int]         =							ModelOutputTest(a=30   )
			self.assertEqual(list(x.keys()   )							,			['''a''']   )
			self.assertEqual(list(x.values()   )							,			[30]   )
			self.assertEqual(list(x.items()   )							,			[('''a''', 30)]   )
			self.assertEqual(list(a_   )							,			['''a''']   )

			__snake_case      :		Optional[int]         =							ModelOutputTest(a=30							,			b=10   )
			self.assertEqual(list(x.keys()   )							,			['''a''', '''b''']   )
			self.assertEqual(list(x.values()   )							,			[30, 10]   )
			self.assertEqual(list(x.items()   )							,			[('''a''', 30), ('''b''', 10)]   )
			self.assertEqual(list(a_   )							,			['''a''', '''b''']   )

			__snake_case      :		Optional[Any]         =							ModelOutputTest(a=30							,			c=10   )
			self.assertEqual(list(x.keys()   )							,			['''a''', '''c''']   )
			self.assertEqual(list(x.values()   )							,			[30, 10]   )
			self.assertEqual(list(x.items()   )							,			[('''a''', 30), ('''c''', 10)]   )
			self.assertEqual(list(a_   )							,			['''a''', '''c''']   )

			with self.assertRaises(a_   ):
				__snake_case      :		Optional[int]         =							x.update({'''d''': 20}   )
			with self.assertRaises(a_   ):
				del x["a"]
			with self.assertRaises(a_   ):
				__snake_case      :		Union[str, Any]         =							x.pop('''a'''   )
			with self.assertRaises(a_   ):
				__snake_case      :		Optional[Any]         =							x.setdefault('''d'''							,			32   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		List[str]         =							ModelOutputTest(a=30   )
			__snake_case      :		Tuple         =							10
			self.assertEqual(x.a							,			10   )
			self.assertEqual(x['''a''']							,			10   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		List[str]         =							ModelOutputTest(a=30   )
			__snake_case      :		Any         =							10
			self.assertEqual(x.a							,			10   )
			self.assertEqual(x['''a''']							,			10   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		int         =							ModelOutputTest({'''a''': 30, '''b''': 10}   )
			self.assertEqual(list(x.keys()   )							,			['''a''', '''b''']   )
			self.assertEqual(x.a							,			30   )
			self.assertEqual(x.b							,			10   )



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Any         =							ModelOutputTest([('''a''', 30), ('''b''', 10)]   )
			self.assertEqual(list(x.keys()   )							,			['''a''', '''b''']   )
			self.assertEqual(x.a							,			30   )
			self.assertEqual(x.b							,			10   )

			with self.assertRaises(a_   ):
				__snake_case      :		List[Any]         =							ModelOutputTest([('''a''', 30), (10, 10)]   )

			__snake_case      :		Union[str, Any]         =							ModelOutputTest(a=(30, 30)   )
			self.assertEqual(list(x.keys()   )							,			['''a''']   )
			self.assertEqual(x.a							,			(30, 30)   )





