



from __future__ import annotations

from typing import Generic, TypeVar

__UpperCAmelCase						  =     TypeVar('''T''')


class 	lowerCamelCase__ (		Generic[T]   ):


						def __init__( self						:  int      ,       _a						:  T			):
													a__:       int											=data  # Assign data
													a__:       Node[T] | None											=None  # Initialize next as null
													a__:       Node[T] | None											=None  # Initialize prev as null


class 	lowerCamelCase__ (		Generic[T]   ):


						def __init__( self						:  Optional[Any]			):
													a__:       Node[T] | None											=None


						def   _lowerCamelCase			( self						:  List[Any]      ,       _a						:  T			):
													if self.head is None:
																				a__:       Dict											=Node(_a			)
													else:
																				a__:       int											=Node(_a			)
																				a__:       Optional[Any]											=new_node
																				a__:       int											=self.head
																				a__:       int											=None
																				a__:       Any											=new_node


						def   _lowerCamelCase			( self						:  Tuple			):
													if self.head is None:
																				return None
													else:
																				assert self.head is not None
																				a__:       Optional[int]											=self.head.data
																				a__:       Union[str, Any]											=self.head.next
																				if self.head is not None:
																											a__:       str											=None
																				return temp


						def   _lowerCamelCase			( self						:  int			):
													return self.head.data if self.head is not None else None


						def __len__( self						:  Union[str, Any]			):
													a__:       Tuple											=self.head
													a__:       int											=0
													while temp is not None:
																				count += 1
																				a__:       List[str]											=temp.next
													return count


						def   _lowerCamelCase			( self						:  int			):
													return self.head is None







						def   _lowerCamelCase			( self						:  Union[str, Any]			):
													print("stack elements are:"			)
													a__:       Optional[int]											=self.head
													while temp is not None:
																				print(temp.data      ,       end="->"			)
																				a__:       Union[str, Any]											=temp.next


# Code execution starts here
if __name__ == "__main__":
		# Start with the empty stack
		__UpperCAmelCase						  =     Stack()

		# Insert 4 at the beginning. So stack becomes 4->None
		print('''Stack operations using Doubly LinkedList''')
		stack.push(4)

		# Insert 5 at the beginning. So stack becomes 4->5->None
		stack.push(5)

		# Insert 6 at the beginning. So stack becomes 4->5->6->None
		stack.push(6)

		# Insert 7 at the beginning. So stack becomes 4->5->6->7->None
		stack.push(7)

		# Print the stack
		stack.print_stack()

		# Print the top element
		print('''\nTop element is ''', stack.top())

		# Print the stack size
		print('''Size of the stack is ''', len(stack))

		# pop the top element
		stack.pop()

		# pop the top element
		stack.pop()

		# two elements have now been popped off
		stack.print_stack()

		# Print True if the stack is empty else False
		print('''\nstack is empty:''', stack.is_empty())










import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__UpperCAmelCase						  =     10_00_00_00_00_00
__UpperCAmelCase						  =     1_00_00

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





def 						__lowerCamelCase       (      __magic_name__	:  int     , __magic_name__	:  int						):
							a__:       Any											=pa.Table.from_pydict({"col": [0] * chunk_size}						)
							a__:       Optional[Any]											=pa.concat_tables([table] * (num_examples // chunk_size)						)
							return datasets.Dataset(__magic_name__     , fingerprint="table_100B"						)


@dataclass
class 	lowerCamelCase__ :
						_lowerCAmelCase								= 42
						_lowerCAmelCase								= 42
						_lowerCAmelCase								= 42
						_lowerCAmelCase								= 42


						def   _lowerCamelCase			( self						:  Union[str, Any]			):
													a__:       Tuple											=np.random.default_rng(self.seed			)
													a__:       Tuple											=rng.integers(low=self.low      ,       high=self.high      ,       size=self.size			).tolist()


						def __iter__( self						:  Any			):
													return iter(self._sampled_values			)







						def __len__( self						:  Any			):
													return self.size





@get_duration
def 						__lowerCamelCase       (      __magic_name__	:  datasets.Dataset						):
							a__:       Union[str, Any]											=dataset[0]





@get_duration
def 						__lowerCamelCase       (      __magic_name__	:  datasets.Dataset						):
							a__:       Optional[Any]											=dataset[-1]





@get_duration
def 						__lowerCamelCase       (      __magic_name__	:  datasets.Dataset						):
							a__:       List[str]											=dataset[range(len(__magic_name__						) // 2     , len(__magic_name__						) // 2 + 1_024						)]





@get_duration
def 						__lowerCamelCase       (      __magic_name__	:  datasets.Dataset						):
							a__:       Optional[int]											=dataset[RandIter(0     , len(__magic_name__						)     , 1_024     , seed=42						)]





def 						__lowerCamelCase       (      ):
							a__:       Dict											={"num examples": SPEED_TEST_N_EXAMPLES}
							a__:       Union[str, Any]											=(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
							print("generating dataset"						)
							a__:       Dict											=generate_100B_dataset(num_examples=__magic_name__     , chunk_size=__magic_name__						)
							print("Functions"						)
							for func in functions:
														print(func.__name__						)
														a__:       Dict											=func(__magic_name__						)

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


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





