



import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__A             =1_0_0_0_0_0_0_0_0_0_0_0
__A             =1_0_0_0_0

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

def 	a						(				_UpperCAmelCase							: int			,       _UpperCAmelCase							: int						):







		'''simple docstring'''





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

@dataclass
class 		UpperCAmelCase__      :




			'''simple docstring'''






			UpperCamelCase      						=	42
			UpperCamelCase      						=	42
			UpperCamelCase      						=	42
			UpperCamelCase      						=	42




			def 			snake_case__					(       self							:			Optional[int]			):
					'''simple docstring'''





					__UpperCAmelCase   :					Tuple													=     np.random.default_rng(self.seed			)
					__UpperCAmelCase   :					Tuple													=     rng.integers(low=self.low	,	high=self.high	,	size=self.size			).tolist()




			def __iter__(       self							:			Optional[int]			):
					'''simple docstring'''





					return iter(self._sampled_values			)




			def __len__(       self							:			Any			):
					'''simple docstring'''





					return self.size

@get_duration
def 	a						(				_UpperCAmelCase							: datasets.Dataset						):







		'''simple docstring'''





		__UpperCAmelCase   :					Any													=     dataset[0]

@get_duration
def 	a						(				_UpperCAmelCase							: datasets.Dataset						):







		'''simple docstring'''





		__UpperCAmelCase   :					int													=     dataset[-1]

@get_duration
def 	a						(				_UpperCAmelCase							: datasets.Dataset						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[int]													=     dataset[range(len(_UpperCAmelCase						) // 2			,       len(_UpperCAmelCase						) // 2 + 10_24						)]

@get_duration
def 	a						(				_UpperCAmelCase							: datasets.Dataset						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[int]													=     dataset[RandIter(0			,       len(_UpperCAmelCase						)			,       10_24			,       seed=42						)]

def 	a						(				):







		'''simple docstring'''





		__UpperCAmelCase   :					Union[str, Any]													=     {'''num examples''': SPEED_TEST_N_EXAMPLES}
		__UpperCAmelCase   :					str													=     (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
		print('''generating dataset'''						)
		__UpperCAmelCase   :					Optional[Any]													=     generate_100B_dataset(num_examples=_UpperCAmelCase			,       chunk_size=_UpperCAmelCase						)
		print('''Functions'''						)
		for func in functions:
				print(func.__name__						)
				__UpperCAmelCase   :					str													=     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_table_100B()










from ...configuration_utils import PretrainedConfig
from ...utils import logging


__A             =logging.get_logger(__name__)

__A             ={
    "tau/splinter-base": "https://huggingface.co/tau/splinter-base/resolve/main/config.json",
    "tau/splinter-base-qass": "https://huggingface.co/tau/splinter-base-qass/resolve/main/config.json",
    "tau/splinter-large": "https://huggingface.co/tau/splinter-large/resolve/main/config.json",
    "tau/splinter-large-qass": "https://huggingface.co/tau/splinter-large-qass/resolve/main/config.json",
    # See all Splinter models at https://huggingface.co/models?filter=splinter
}

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			UpperCamelCase      						=	"""splinter"""




			def __init__(       self							:			Any	,	a_							:			Optional[int]=3_05_22	,	a_							:			Union[str, Any]=7_68	,	a_							:			int=12	,	a_							:			int=12	,	a_							:			List[Any]=30_72	,	a_							:			Union[str, Any]="gelu"	,	a_							:			Any=0.1	,	a_							:			Union[str, Any]=0.1	,	a_							:			Any=5_12	,	a_							:			str=2	,	a_							:			Dict=0.0_2	,	a_							:			int=1e-12	,	a_							:			str=True	,	a_							:			Tuple=0	,	a_							:			List[Any]=1_04	,	**a_							:			str	,	):
					'''simple docstring'''





					super().__init__(pad_token_id=a_	,	**a_			)

					__UpperCAmelCase   :					Union[str, Any]													=     vocab_size
					__UpperCAmelCase   :					List[Any]													=     max_position_embeddings
					__UpperCAmelCase   :					str													=     hidden_size
					__UpperCAmelCase   :					Union[str, Any]													=     num_hidden_layers
					__UpperCAmelCase   :					Any													=     num_attention_heads
					__UpperCAmelCase   :					Any													=     intermediate_size
					__UpperCAmelCase   :					Tuple													=     hidden_act
					__UpperCAmelCase   :					str													=     hidden_dropout_prob
					__UpperCAmelCase   :					Any													=     attention_probs_dropout_prob
					__UpperCAmelCase   :					Optional[int]													=     initializer_range
					__UpperCAmelCase   :					Any													=     type_vocab_size
					__UpperCAmelCase   :					int													=     layer_norm_eps
					__UpperCAmelCase   :					List[Any]													=     use_cache
					__UpperCAmelCase   :					Optional[int]													=     question_token_id





