
"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


snake_case    =		{
    'configuration_esm': ['ESM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EsmConfig'],
    'tokenization_esm': ['EsmTokenizer'],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case    =		[
	    'ESM_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'EsmForMaskedLM',
	    'EsmForSequenceClassification',
	    'EsmForTokenClassification',
	    'EsmModel',
	    'EsmPreTrainedModel',
	]
	snake_case    =		['EsmForProteinFolding', 'EsmFoldPreTrainedModel']

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case    =		[
	    'TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'TFEsmForMaskedLM',
	    'TFEsmForSequenceClassification',
	    'TFEsmForTokenClassification',
	    'TFEsmModel',
	    'TFEsmPreTrainedModel',
	]

if TYPE_CHECKING:
	from .configuration_esm import ESM_PRETRAINED_CONFIG_ARCHIVE_MAP, EsmConfig
	from .tokenization_esm import EsmTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_esm import (
		    ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    EsmForMaskedLM,
		    EsmForSequenceClassification,
		    EsmForTokenClassification,
		    EsmModel,
		    EsmPreTrainedModel,
		)
		from .modeling_esmfold import EsmFoldPreTrainedModel, EsmForProteinFolding

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_esm import (
		    TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFEsmForMaskedLM,
		    TFEsmForSequenceClassification,
		    TFEsmForTokenClassification,
		    TFEsmModel,
		    TFEsmPreTrainedModel,
		)


else:
	import sys

	snake_case    =		_LazyModule(__name__, globals()['__file__'], _import_structure)


"""simple docstring"""




import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


snake_case    =		1_0_0_0_0_0_0_0_0_0_0_0
snake_case    =		1_0_0_0_0

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

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	pa.Table.from_pydict({'col': [0] * chunk_size}			)
					SCREAMING_SNAKE_CASE				=	pa.concat_tables([table] * (num_examples // chunk_size)			)
					return datasets.Dataset(SCREAMING_SNAKE_CASE_,     fingerprint='table_100B'			)




@dataclass
class      UpperCamelCase	:

				"""simple docstring"""



				UpperCAmelCase_				:      int
				UpperCAmelCase_				:      int
				UpperCAmelCase_				:      int
				UpperCAmelCase_				:      int


				def 							A					(				self			)    ->    Optional[Any]:
									"""simple docstring"""







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


				def __iter__(				self			)    ->    Union[str, Any]:
									"""simple docstring"""







									return iter(self._sampled_values			)




				def __len__(				self			)    ->    Optional[Any]:
									"""simple docstring"""







									return self.size






@get_duration
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	dataset[0]

@get_duration
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	dataset[-1]

@get_duration
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	dataset[range(len(SCREAMING_SNAKE_CASE_			) // 2,     len(SCREAMING_SNAKE_CASE_			) // 2 + 1_0_2_4			)]

@get_duration
def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					SCREAMING_SNAKE_CASE				=	dataset[RandIter(0,     len(SCREAMING_SNAKE_CASE_			),     1_0_2_4,     seed=4_2			)]

def   UpperCamelCase_  (		):
					SCREAMING_SNAKE_CASE				=	{'num examples': SPEED_TEST_N_EXAMPLES}
					SCREAMING_SNAKE_CASE				=	(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
					print('generating dataset'			)
					SCREAMING_SNAKE_CASE				=	generate_100B_dataset(num_examples=SCREAMING_SNAKE_CASE_,     chunk_size=SCREAMING_SNAKE_CASE_			)
					print('Functions'			)
					for func in functions:
										print(func.__name__			)
										SCREAMING_SNAKE_CASE				=	func(SCREAMING_SNAKE_CASE_			)

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


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