
"""simple docstring"""




import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__lowerCAmelCase							:  Tuple 				=		500000

__lowerCAmelCase				,__lowerCAmelCase							:  int 				=		os.path.split(__file__)
__lowerCAmelCase							:  List[str] 				=		os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))

@get_duration
def __snake_case (      UpperCamelCase    )       ->    Optional[int]:


		"""simple docstring"""





		a__   		=     dataset.select(range(0						,					len(UpperCamelCase    )						,					2    )    )

@get_duration
def __snake_case (      UpperCamelCase    )       ->    List[str]:


		"""simple docstring"""





		a__   		=     dataset.sort('''numbers'''    )

@get_duration
def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		a__   		=     dataset.shuffle()

@get_duration
def __snake_case (      UpperCamelCase    )       ->    List[str]:


		"""simple docstring"""





		a__   		=     dataset.train_test_split(0.1    )

@get_duration
def __snake_case (      UpperCamelCase						,					UpperCamelCase=10    )       ->    List[str]:


		"""simple docstring"""





		for shard_id in range(UpperCamelCase    ):
				a__   		=     dataset.shard(UpperCamelCase						,					UpperCamelCase    )

def __snake_case (      )       ->    List[str]:


		"""simple docstring"""





		a__   		=     {'''num examples''': SPEED_TEST_N_EXAMPLES}
		a__   		=     (select, sort, shuffle, train_test_split, shard)
		with tempfile.TemporaryDirectory() as tmp_dir:
				print('''generating dataset'''    )
				a__   		=     datasets.Features({'''text''': datasets.Value('''string'''    ), '''numbers''': datasets.Value('''float32'''    )}    )
				a__   		=     generate_example_dataset(
				    os.path.join(UpperCamelCase						,					'''dataset.arrow'''    )						,					UpperCamelCase						,					num_examples=UpperCamelCase    )
				print('''Functions'''    )
				for func in functions:
						print(func.__name__    )
						a__   		=     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()






"""simple docstring"""




def __snake_case (      UpperCamelCase    )       ->    float:


		"""simple docstring"""





		return -num if num < 0 else num

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_min() arg is an empty sequence'''    )
		a__   		=     x[0]
		for i in x:
				if abs_val(UpperCamelCase    ) < abs_val(UpperCamelCase    ):
						a__   		=     i
		return j

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_max() arg is an empty sequence'''    )
		a__   		=     x[0]
		for i in x:
				if abs(UpperCamelCase    ) > abs(UpperCamelCase    ):
						a__   		=     i
		return j

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_max_sort() arg is an empty sequence'''    )
		return sorted(UpperCamelCase						,					key=UpperCamelCase    )[-1]

def __snake_case (      )       ->    Optional[int]:


		"""simple docstring"""





		assert abs_val(0    ) == 0
		assert abs_val(34    ) == 34
		assert abs_val(-100_000_000_000    ) == 100_000_000_000

		a__   		=     [-3, -1, 2, -11]
		assert abs_max(UpperCamelCase    ) == -11
		assert abs_max_sort(UpperCamelCase    ) == -11
		assert abs_min(UpperCamelCase    ) == -1


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					test_abs_val()
					print(abs_val(-34))  # --> 34




