






import asyncio
import os
import re
import sys
import tempfile
import unittest
from contextlib import contextmanager
from copy import deepcopy
from distutils.util import strtobool
from enum import Enum
from importlib.util import find_spec
from pathlib import Path
from unittest.mock import patch

import pyarrow as pa
import pytest
import requests
from packaging import version

from datasets import config


if config.PY_VERSION < version.parse('3.8'):
				import importlib_metadata
else:
				import importlib.metadata as importlib_metadata






def 					lowerCamelCase__					(_UpperCAmelCase				,							_UpperCAmelCase=False):
			try:
						SCREAMING_SNAKE_CASE							=			os.environ[key]
			except KeyError:
						# KEY isn't set, default to `default`.
						SCREAMING_SNAKE_CASE							=			default
			else:
						# KEY is set, convert it to True or False.
						try:
									SCREAMING_SNAKE_CASE							=			strtobool(_UpperCAmelCase)
						except ValueError:
									# More values are supported, but let's keep the message simple.
									raise ValueError(F'''If set, {key} must be yes or no.''')
			return _value


a_		:    Optional[Any]   							=     parse_flag_from_env('RUN_SLOW', default=False)
a_		:    int   							=     parse_flag_from_env('RUN_REMOTE', default=False)
a_		:    List[str]   							=     parse_flag_from_env('RUN_LOCAL', default=True)
a_		:    Dict   							=     parse_flag_from_env('RUN_PACKAGED', default=True)

# Compression
a_		:    Tuple   							=     pytest.mark.skipif(not config.LZ4_AVAILABLE, reason='test requires lz4')
a_		:    Dict   							=     pytest.mark.skipif(not config.PY7ZR_AVAILABLE, reason='test requires py7zr')
a_		:    Optional[int]   							=     pytest.mark.skipif(not config.ZSTANDARD_AVAILABLE, reason='test requires zstandard')

# Audio
a_		:    List[Any]   							=     pytest.mark.skipif(
    # On Windows and OS X, soundfile installs sndfile
    find_spec('soundfile') is None or version.parse(importlib_metadata.version('soundfile')) < version.parse('0.12.0'),
    reason='test requires sndfile>=0.12.1: \'pip install \"soundfile>=0.12.1\"\'; ',
)

# Beam
a_		:    int   							=     pytest.mark.skipif(
    not config.BEAM_AVAILABLE or config.DILL_VERSION >= version.parse('0.3.2'),
    reason='test requires apache-beam and a compatible dill version',
)

# Dill-cloudpickle compatibility
a_		:    Dict   							=     pytest.mark.skipif(
    config.DILL_VERSION <= version.parse('0.3.2'),
    reason='test requires dill>0.3.2 for cloudpickle compatibility',
)

# Windows
a_		:    Optional[int]   							=     pytest.mark.skipif(
    sys.platform == 'win32',
    reason='test should not be run on Windows',
)






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import faiss  # noqa
			except ImportError:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires faiss')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import regex  # noqa
			except ImportError:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires regex')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import elasticsearch  # noqa
			except ImportError:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires elasticsearch')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import sqlalchemy  # noqa
			except ImportError:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires sqlalchemy')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not config.TORCH_AVAILABLE:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires PyTorch')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not config.TF_AVAILABLE:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires TensorFlow')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not config.JAX_AVAILABLE:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires JAX')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not config.PIL_AVAILABLE:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires Pillow')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import transformers  # noqa F401
			except ImportError:
						return unittest.skip('test requires transformers')(_UpperCAmelCase)
			else:
						return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import tiktoken  # noqa F401
			except ImportError:
						return unittest.skip('test requires tiktoken')(_UpperCAmelCase)
			else:
						return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import spacy  # noqa F401
			except ImportError:
						return unittest.skip('test requires spacy')(_UpperCAmelCase)
			else:
						return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):

			def _require_spacy_model(_UpperCAmelCase):
						try:
									import spacy  # noqa F401

									spacy.load(_UpperCAmelCase)
						except ImportError:
									return unittest.skip('test requires spacy')(_UpperCAmelCase)
						except OSError:
									return unittest.skip('test requires spacy model \'{}\''.format(_UpperCAmelCase))(_UpperCAmelCase)
						else:
									return test_case

			return _require_spacy_model






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import pyspark  # noqa F401
			except ImportError:
						return unittest.skip('test requires pyspark')(_UpperCAmelCase)
			else:
						return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			try:
						import joblibspark  # noqa F401
			except ImportError:
						return unittest.skip('test requires joblibspark')(_UpperCAmelCase)
			else:
						return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not _run_slow_tests or _run_slow_tests == 0:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test is slow')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not _run_local_tests or _run_local_tests == 0:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test is local')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not _run_packaged_tests or _run_packaged_tests == 0:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test is packaged')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(_UpperCAmelCase):
			if not _run_remote_tests or _run_remote_tests == 0:
						SCREAMING_SNAKE_CASE							=			unittest.skip('test requires remote')(_UpperCAmelCase)
			return test_case






def 					lowerCamelCase__					(*_UpperCAmelCase):
			def decorate(cls):
						for name, fn in cls.__dict__.items():
									if callable(_UpperCAmelCase) and name.startswith('test'):
												for decorator in decorators:
															SCREAMING_SNAKE_CASE							=			decorator(_UpperCAmelCase)
												setattr(cls				,							_UpperCAmelCase				,							_UpperCAmelCase)
						return cls

			return decorate

class 		_snake_case	(	A__       ):
			pass



class 		_snake_case	(	A__       ):
			_lowercase		:     Optional[Any]        =				0
			_lowercase		:     Optional[Any]        =				1
			_lowercase		:     Optional[int]        =				2






@contextmanager
def 					lowerCamelCase__					(_UpperCAmelCase=OfflineSimulationMode.CONNECTION_FAILS				,							_UpperCAmelCase=1e-16):
			SCREAMING_SNAKE_CASE							=			requests.Session().request

			def timeout_request(_UpperCAmelCase				,							_UpperCAmelCase				,							_UpperCAmelCase				,							**_UpperCAmelCase):
						# Change the url to an invalid url so that the connection hangs
						SCREAMING_SNAKE_CASE							=			'https://10.255.255.1'
						if kwargs.get('timeout') is None:
									raise RequestWouldHangIndefinitelyError(
									    F'''Tried a call to {url} in offline mode with no timeout set. Please set a timeout.''')
						SCREAMING_SNAKE_CASE							=			timeout
						try:
									return online_request(_UpperCAmelCase				,							_UpperCAmelCase				,							**_UpperCAmelCase)
						except Exception as e:
									# The following changes in the error are just here to make the offline timeout error prettier
									SCREAMING_SNAKE_CASE							=			url
									SCREAMING_SNAKE_CASE							=			e.args[0]
									SCREAMING_SNAKE_CASE							=			(max_retry_error.args[0].replace('10.255.255.1'				,							F'''OfflineMock[{url}]'''),)
									SCREAMING_SNAKE_CASE							=			(max_retry_error,)
									raise

			def raise_connection_error(_UpperCAmelCase				,							_UpperCAmelCase				,							**_UpperCAmelCase):
						raise requests.ConnectionError('Offline mode is enabled.'				,							request=_UpperCAmelCase)

			if mode is OfflineSimulationMode.CONNECTION_FAILS:
						with patch('requests.Session.send'				,							_UpperCAmelCase):
									yield
			elif mode is OfflineSimulationMode.CONNECTION_TIMES_OUT:
						# inspired from https://stackoverflow.com/a/904609
						with patch('requests.Session.request'				,							_UpperCAmelCase):
									yield
			elif mode is OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1:
						with patch('datasets.config.HF_DATASETS_OFFLINE'				,							_UpperCAmelCase):
									yield
			else:
						raise ValueError('Please use a value from the OfflineSimulationMode enum.')






@contextmanager
def 					lowerCamelCase__					(*_UpperCAmelCase				,							**_UpperCAmelCase):
			SCREAMING_SNAKE_CASE							=			str(Path().resolve())
			with tempfile.TemporaryDirectory(*_UpperCAmelCase				,							**_UpperCAmelCase) as tmp_dir:
						try:
									os.chdir(_UpperCAmelCase)
									yield
						finally:
									os.chdir(_UpperCAmelCase)






@contextmanager
def 					lowerCamelCase__					():
			import gc

			gc.collect()
			SCREAMING_SNAKE_CASE							=			pa.total_allocated_bytes()
			yield
			assert pa.total_allocated_bytes() - previous_allocated_memory > 0, "Arrow memory didn't increase."






@contextmanager
def 					lowerCamelCase__					():
			import gc

			gc.collect()
			SCREAMING_SNAKE_CASE							=			pa.total_allocated_bytes()
			yield
			assert pa.total_allocated_bytes() - previous_allocated_memory <= 0, "Arrow memory wasn't expected to increase."






def 					lowerCamelCase__					(_UpperCAmelCase				,							_UpperCAmelCase):
			return deepcopy(_UpperCAmelCase).integers(0				,							100				,							10).tolist() == deepcopy(_UpperCAmelCase).integers(0				,							100				,							10).tolist()






def 					lowerCamelCase__					(_UpperCAmelCase):
			import decorator
			from requests.exceptions import HTTPError

			def _wrapper(_UpperCAmelCase				,							*_UpperCAmelCase				,							**_UpperCAmelCase):
						try:
									return func(*_UpperCAmelCase				,							**_UpperCAmelCase)
						except HTTPError as err:
									if str(_UpperCAmelCase).startswith('500') or str(_UpperCAmelCase).startswith('502'):
												pytest.xfail(str(_UpperCAmelCase))
									raise err

			return decorator.decorator(_wrapper				,							_UpperCAmelCase)

class 		_snake_case	:






			def __init__(							self		,       a		,       a		,       a)   ->							List[str]:
						SCREAMING_SNAKE_CASE							=			returncode
						SCREAMING_SNAKE_CASE							=			stdout
						SCREAMING_SNAKE_CASE							=			stderr






async def 					lowerCamelCase__					(_UpperCAmelCase				,							_UpperCAmelCase):
			while True:
						SCREAMING_SNAKE_CASE							=			await stream.readline()
						if line:
									callback(_UpperCAmelCase)
						else:
									break






async def 					lowerCamelCase__					(_UpperCAmelCase				,							_UpperCAmelCase=None				,							_UpperCAmelCase=None				,							_UpperCAmelCase=None				,							_UpperCAmelCase=False				,							_UpperCAmelCase=False):
			if echo:
						print('\nRunning: '				,							' '.join(_UpperCAmelCase))

			SCREAMING_SNAKE_CASE							=			await asyncio.create_subprocess_exec(
			    cmd[0]				,							*cmd[1:]				,							stdin=_UpperCAmelCase				,							stdout=asyncio.subprocess.PIPE				,							stderr=asyncio.subprocess.PIPE				,							env=_UpperCAmelCase				,							)

			# note: there is a warning for a possible deadlock when using `wait` with huge amounts of data in the pipe
			# https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.asyncio.subprocess.Process.wait
			#
			# If it starts hanging, will need to switch to the following code. The problem is that no data
			# will be seen until it's done and if it hangs for example there will be no debug info.
			# out, err = await p.communicate()
			# return _RunOutput(p.returncode, out, err)

			SCREAMING_SNAKE_CASE							=			[]
			SCREAMING_SNAKE_CASE							=			[]

			def tee(_UpperCAmelCase				,							_UpperCAmelCase				,							_UpperCAmelCase				,							_UpperCAmelCase=""):
						SCREAMING_SNAKE_CASE							=			line.decode('utf-8').rstrip()
						sink.append(_UpperCAmelCase)
						if not quiet:
									print(_UpperCAmelCase				,							_UpperCAmelCase				,							file=_UpperCAmelCase)

    # XXX: the timeout doesn't seem to make any difference here
			await asyncio.wait(
			    [
			        _read_stream(p.stdout				,							lambda _UpperCAmelCase: tee(_UpperCAmelCase				,							_UpperCAmelCase				,							sys.stdout				,							label='stdout:')),
			        _read_stream(p.stderr				,							lambda _UpperCAmelCase: tee(_UpperCAmelCase				,							_UpperCAmelCase				,							sys.stderr				,							label='stderr:')),
			    ]				,							timeout=_UpperCAmelCase				,							)
			return _RunOutput(await p.wait()				,							_UpperCAmelCase				,							_UpperCAmelCase)






def 					lowerCamelCase__					(_UpperCAmelCase				,							_UpperCAmelCase=None				,							_UpperCAmelCase=None				,							_UpperCAmelCase=180				,							_UpperCAmelCase=False				,							_UpperCAmelCase=True):
			SCREAMING_SNAKE_CASE							=			asyncio.get_event_loop()
			SCREAMING_SNAKE_CASE							=			loop.run_until_complete(
			    _stream_subprocess(_UpperCAmelCase				,							env=_UpperCAmelCase				,							stdin=_UpperCAmelCase				,							timeout=_UpperCAmelCase				,							quiet=_UpperCAmelCase				,							echo=_UpperCAmelCase))

			SCREAMING_SNAKE_CASE							=			' '.join(_UpperCAmelCase)
			if result.returncode > 0:
						SCREAMING_SNAKE_CASE							=			'\n'.join(result.stderr)
						raise RuntimeError(
						    F'''\'{cmd_str}\' failed with returncode {result.returncode}\n\n'''
						    F'''The combined stderr from workers follows:\n{stderr}''')

			# check that the subprocess actually did run and produced some output, should the test rely on
			# the remote side to do the testing
			if not result.stdout and not result.stderr:
						raise RuntimeError(F'''\'{cmd_str}\' produced no output.''')

			return result






def 					lowerCamelCase__					():
			SCREAMING_SNAKE_CASE							=			os.environ.get('PYTEST_XDIST_WORKER'				,							'gw0')
			SCREAMING_SNAKE_CASE							=			re.sub(R'^gw'				,							''				,							_UpperCAmelCase				,							0				,							re.M)
			return int(_UpperCAmelCase)







def 					lowerCamelCase__					():
			SCREAMING_SNAKE_CASE							=			2_9500
			SCREAMING_SNAKE_CASE							=			pytest_xdist_worker_id()
			return port + uniq_delta







import os





def 	__a     (      ):
    SCREAMING_SNAKE_CASE										=   os.path.join(os.path.dirname(A__       )			,  "num.txt"       )
    with open(A__       ) as file_hand:
        return str(sum(int(A__       ) for line in file_hand       )       )[:10]


if __name__ == "__main__":
    print(solution())