





class 					UpperCamelCase_    :


							def __init__(							self      :Optional[int]							,			__A      :Union[str, Any]						)				->				Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= data
									SCREAMING_SNAKE_CASE__								= None
									SCREAMING_SNAKE_CASE__								= None


							def __str__(							self      :Optional[int]						)				->				int:



									"""simple docstring"""



									return f'''{self.data}'''




class 					UpperCamelCase_    :


							def __init__(							self      :Union[str, Any]						)				->				int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= None
									SCREAMING_SNAKE_CASE__								= None


							def __iter__(							self      :Optional[Any]						)				->				Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= self.head
									while node:
											yield node.data
											SCREAMING_SNAKE_CASE__								= node.next


							def __str__(							self      :Dict						)				->				List[str]:



									"""simple docstring"""



									return "->".join([str(__A						) for item in self]						)


							def __len__(							self      :Any						)				->				str:



									"""simple docstring"""



									return sum(1 for _ in self						)


							def        _snake_case					(							self      :Dict							,			__A      :Optional[int]						)				->				Dict:



									"""simple docstring"""



									self.insert_at_nth(0							,			__A						)


							def        _snake_case					(							self      :List[Any]							,			__A      :int						)				->				List[Any]:



									"""simple docstring"""



									self.insert_at_nth(len(self						)							,			__A						)


							def        _snake_case					(							self      :int							,			__A      :int							,			__A      :Any						)				->				str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= len(self						)

									if not 0 <= index <= length:
											raise IndexError("""list index out of range"""						)
									SCREAMING_SNAKE_CASE__								= Node(__A						)
									if self.head is None:
											SCREAMING_SNAKE_CASE__								= SCREAMING_SNAKE_CASE__								= new_node
									elif index == 0:
											SCREAMING_SNAKE_CASE__								= new_node
											SCREAMING_SNAKE_CASE__								= self.head
											SCREAMING_SNAKE_CASE__								= new_node
									elif index == length:
											SCREAMING_SNAKE_CASE__								= new_node
											SCREAMING_SNAKE_CASE__								= self.tail
											SCREAMING_SNAKE_CASE__								= new_node
									else:
											SCREAMING_SNAKE_CASE__								= self.head
											for _ in range(0							,			__A						):
													SCREAMING_SNAKE_CASE__								= temp.next
											SCREAMING_SNAKE_CASE__								= new_node
											SCREAMING_SNAKE_CASE__								= temp.previous
											SCREAMING_SNAKE_CASE__								= temp
											SCREAMING_SNAKE_CASE__								= new_node


							def        _snake_case					(							self      :Optional[Any]						)				->				Tuple:



									"""simple docstring"""



									return self.delete_at_nth(0						)


							def        _snake_case					(							self      :Union[str, Any]						)				->				Optional[Any]:



									"""simple docstring"""



									return self.delete_at_nth(len(self						) - 1						)


							def        _snake_case					(							self      :Union[str, Any]							,			__A      :int						)				->				str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= len(self						)

									if not 0 <= index <= length - 1:
											raise IndexError("""list index out of range"""						)
									SCREAMING_SNAKE_CASE__								= self.head  # default first node
									if length == 1:
											SCREAMING_SNAKE_CASE__								= SCREAMING_SNAKE_CASE__								= None
									elif index == 0:
											SCREAMING_SNAKE_CASE__								= self.head.next
											SCREAMING_SNAKE_CASE__								= None
									elif index == length - 1:
											SCREAMING_SNAKE_CASE__								= self.tail
											SCREAMING_SNAKE_CASE__								= self.tail.previous
											SCREAMING_SNAKE_CASE__								= None
									else:
											SCREAMING_SNAKE_CASE__								= self.head
											for _ in range(0							,			__A						):
													SCREAMING_SNAKE_CASE__								= temp.next
											SCREAMING_SNAKE_CASE__								= temp
											SCREAMING_SNAKE_CASE__								= temp.previous
											SCREAMING_SNAKE_CASE__								= temp.next
									return delete_node.data


							def        _snake_case					(							self      :Optional[int]							,			__A      :Optional[int]						)				->				str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								= self.head

									while current.data != data:  # Find the position to delete
											if current.next:
													SCREAMING_SNAKE_CASE__								= current.next
											else:  # We have reached the end an no value matches
													raise ValueError("""No data matching given value"""						)

									if current == self.head:
											self.delete_head()

									elif current == self.tail:
											self.delete_tail()

									else:  # Before: 1 <--> 2(current) <--> 3
											SCREAMING_SNAKE_CASE__								= current.next  # 1 --> 3
											SCREAMING_SNAKE_CASE__								= current.previous  # 1 <--> 3
									return data


							def        _snake_case					(							self      :Tuple						)				->				str:



									"""simple docstring"""



									return len(self						) == 0






def 			SCREAMING_SNAKE_CASE__							(    ):
		SCREAMING_SNAKE_CASE__								= DoublyLinkedList()
		assert linked_list.is_empty() is True
		assert str(UpperCamelCase__      ) == ""

		try:
				linked_list.delete_head()
				raise AssertionError  # This should not happen.
		except IndexError:
				assert True  # This should happen.

		try:
				linked_list.delete_tail()
				raise AssertionError  # This should not happen.
		except IndexError:
				assert True  # This should happen.

		for i in range(10      ):
				assert len(UpperCamelCase__      ) == i
				linked_list.insert_at_nth(UpperCamelCase__   ,				i + 1      )
		assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(1   ,				11      )      )

		linked_list.insert_at_head(0      )
		linked_list.insert_at_tail(11      )
		assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(0   ,				12      )      )

		assert linked_list.delete_head() == 0
		assert linked_list.delete_at_nth(9      ) == 10
		assert linked_list.delete_tail() == 11
		assert len(UpperCamelCase__      ) == 9
		assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(1   ,				10      )      )


if __name__ == "__main__":
	from doctest import testmod

	testmod()






import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


_lowerCamelCase							=     500000

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






@get_duration
def 			SCREAMING_SNAKE_CASE__							(    UpperCamelCase__:							datasets.Dataset      ):
		SCREAMING_SNAKE_CASE__								= dataset.select(range(0   ,				len(UpperCamelCase__      )   ,				2      )      )






@get_duration
def 			SCREAMING_SNAKE_CASE__							(    UpperCamelCase__:							datasets.Dataset      ):
		SCREAMING_SNAKE_CASE__								= dataset.sort("""numbers"""      )






@get_duration
def 			SCREAMING_SNAKE_CASE__							(    UpperCamelCase__:							datasets.Dataset      ):
		SCREAMING_SNAKE_CASE__								= dataset.shuffle()






@get_duration
def 			SCREAMING_SNAKE_CASE__							(    UpperCamelCase__:							datasets.Dataset      ):
		SCREAMING_SNAKE_CASE__								= dataset.train_test_split(0.1      )






@get_duration
def 			SCREAMING_SNAKE_CASE__							(    UpperCamelCase__:							datasets.Dataset   ,				UpperCamelCase__:							Tuple=10      ):
		for shard_id in range(UpperCamelCase__      ):
				SCREAMING_SNAKE_CASE__								= dataset.shard(UpperCamelCase__   ,				UpperCamelCase__      )






def 			SCREAMING_SNAKE_CASE__							(    ):
		SCREAMING_SNAKE_CASE__								= {"""num examples""": SPEED_TEST_N_EXAMPLES}
		SCREAMING_SNAKE_CASE__								= (select, sort, shuffle, train_test_split, shard)
		with tempfile.TemporaryDirectory() as tmp_dir:
				print("""generating dataset"""      )
				SCREAMING_SNAKE_CASE__								= datasets.Features({"""text""": datasets.Value("""string"""      ), """numbers""": datasets.Value("""float32"""      )}      )
				SCREAMING_SNAKE_CASE__								= generate_example_dataset(
				    os.path.join(UpperCamelCase__   ,				"""dataset.arrow"""      )   ,				UpperCamelCase__   ,				num_examples=UpperCamelCase__      )
				print("""Functions"""      )
				for func in functions:
						print(func.__name__      )
						SCREAMING_SNAKE_CASE__								= func(UpperCamelCase__      )

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


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