




"""simple docstring"""

import copy
import fnmatch
import json
import os
import pickle as pkl
import shutil
import sys
import tarfile
import tempfile
from collections import OrderedDict
from contextlib import contextmanager
from functools import partial
from hashlib import shaaaa
from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
from zipfile import ZipFile, is_zipfile

import cva
import numpy as np
import requests
import wget
from filelock import FileLock
from PIL import Image
from tqdm.auto import tqdm
from yaml import Loader, dump, load


try:
		import torch

		UpperCamelCase__ :    int 					=							True
except ImportError:
		UpperCamelCase__ :    Optional[Any] 					=							False


try:
		from torch.hub import _get_torch_home

		UpperCamelCase__ :    Optional[int] 					=							_get_torch_home()
except ImportError:
		UpperCamelCase__ :    List[str] 					=							os.path.expanduser(
		    os.getenv("TORCH_HOME", os.path.join(os.getenv("XDG_CACHE_HOME", "~/.cache"), "torch"))
		)

UpperCamelCase__ :    Optional[Any] 					=							os.path.join(torch_cache_home, "transformers")

UpperCamelCase__ :    int 					=							"https://cdn.huggingface.co"
UpperCamelCase__ :    Optional[Any] 					=							"https://s3.amazonaws.com/models.huggingface.co/bert"
UpperCamelCase__ :    Tuple 					=							"/".join(str(Path(__file__).resolve()).split("/")[:-1])
UpperCamelCase__ :    List[Any] 					=							os.path.join(PATH, "config.yaml")
UpperCamelCase__ :    List[Any] 					=							os.path.join(PATH, "attributes.txt")
UpperCamelCase__ :    Union[str, Any] 					=							os.path.join(PATH, "objects.txt")
UpperCamelCase__ :    List[str] 					=							os.getenv("PYTORCH_PRETRAINED_BERT_CACHE", default_cache_path)
UpperCamelCase__ :    Any 					=							os.getenv("PYTORCH_TRANSFORMERS_CACHE", PYTORCH_PRETRAINED_BERT_CACHE)
UpperCamelCase__ :    int 					=							os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE)
UpperCamelCase__ :    Tuple 					=							"pytorch_model.bin"
UpperCamelCase__ :    str 					=							"config.yaml"




def       snake_case__	(       lowerCAmelCase   :		str=OBJECTS				,					lowerCAmelCase   :		Dict=ATTRIBUTES		):
					__snake_case          =	[]
					with open(lowerCAmelCase		) as f:
										for object in f.readlines():
															vg_classes.append(object.split(""","""		)[0].lower().strip()		)

					__snake_case          =	[]
					with open(lowerCAmelCase		) as f:
										for object in f.readlines():
															vg_attrs.append(object.split(""","""		)[0].lower().strip()		)
					return vg_classes, vg_attrs




def       snake_case__	(       lowerCAmelCase   :		Optional[int]		):
					__snake_case          =	OrderedDict()
					with open(lowerCAmelCase				,					"""rb"""		) as f:
										__snake_case          =	pkl.load(lowerCAmelCase		)["""model"""]
					for k in copy.deepcopy(list(ckp.keys()		)		):
										__snake_case          =	ckp.pop(lowerCAmelCase		)
										if isinstance(lowerCAmelCase				,					np.ndarray		):
															__snake_case          =	torch.tensor(lowerCAmelCase		)
										else:
															assert isinstance(lowerCAmelCase				,					torch.tensor		), type(lowerCAmelCase		)
										__snake_case          =	v
					return r
class     A__      :
	A_							:				str						     =      {}




	def __init__(   self  :	int      ,    lowercase  :	dict      ,    lowercase  :	str = "root"      ,    lowercase  :	Dict=0	)					-> Dict:
						__snake_case          =	name
						__snake_case          =	level
						__snake_case          =	{}
						for k, v in dictionary.items():
											if v is None:
																raise ValueError()
											__snake_case          =	copy.deepcopy(lowercase	)
											__snake_case          =	copy.deepcopy(lowercase	)
											if isinstance(lowercase      ,    lowercase	):
																__snake_case          =	Config(lowercase      ,    name=lowercase      ,    level=level + 1	)
											__snake_case          =	v
											setattr(self      ,    lowercase      ,    lowercase	)

						__snake_case          =	d




	def __repr__(   self  :	Dict	)					-> List[str]:
						return str(list((self._pointer.keys())	)	)




	def __setattr__(   self  :	str      ,    lowercase  :	Dict      ,    lowercase  :	str	)					-> int:
						__snake_case          =	val
						__snake_case          =	val
						__snake_case          =	key.split("""."""	)
						__snake_case          =	len(lowercase	) - 1
						__snake_case          =	self._pointer
						if len(lowercase	) > 1:
											for i, l in enumerate(lowercase	):
																if hasattr(self      ,    lowercase	) and isinstance(getattr(self      ,    lowercase	)      ,    lowercase	):
																					setattr(getattr(self      ,    lowercase	)      ,    """.""".join(levels[i:]	)      ,    lowercase	)
																if l == last_level:
																					__snake_case          =	val
																else:
																					__snake_case          =	pointer[l]




	def 							a_		(   self  :	List[Any]	)					-> List[Any]:
						return self._pointer




	def 							a_		(   self  :	Any      ,    lowercase  :	Dict      ,    lowercase  :	Optional[Any]	)					-> Tuple:
						with open(f'''{file_name}'''      ,    """w"""	) as stream:
											dump(lowercase      ,    lowercase	)




	def 							a_		(   self  :	Optional[int]      ,    lowercase  :	List[str]      ,    lowercase  :	List[Any]	)					-> List[Any]:
						with open(f'''{file_name}'''      ,    """w"""	) as stream:
											json.dump(lowercase      ,    lowercase	)




	@staticmethod
	def 							a_		(   lowercase  :	Dict	)					-> Optional[int]:
						with open(lowercase	) as stream:
											__snake_case          =	load(lowercase      ,    Loader=lowercase	)
						return data




	def __str__(   self  :	Union[str, Any]	)					-> Dict:
						__snake_case          =	"""    """
						if self._name != "root":
											__snake_case          =	f'''{t * (self._level-1)}{self._name}:\n'''
						else:
											__snake_case          =	""""""
						__snake_case          =	self._level
						for i, (k, v) in enumerate(self._pointer.items()	):
											if isinstance(lowercase      ,    lowercase	):
																r += f'''{t * (self._level)}{v}\n'''
																self._level += 1
											else:
																r += f'''{t * (self._level)}{k}: {v} ({type(lowercase	).__name__})\n'''
											__snake_case          =	level
						return r[:-1]




	@classmethod
	def 							a_		(   cls  :	int      ,    lowercase  :	str      ,    **lowercase  :	List[Any]	)					-> List[Any]:
						__snake_case      ,      __snake_case          =	cls.get_config_dict(lowercase      ,    **lowercase	)
						return cls(lowercase	)




	@classmethod
	def 							a_		(   cls  :	Union[str, Any]      ,    lowercase  :	str      ,    **lowercase  :	str	)					-> Optional[Any]:
						__snake_case          =	kwargs.pop("""cache_dir"""      ,    lowercase	)
						__snake_case          =	kwargs.pop("""force_download"""      ,    lowercase	)
						__snake_case          =	kwargs.pop("""resume_download"""      ,    lowercase	)
						__snake_case          =	kwargs.pop("""proxies"""      ,    lowercase	)
						__snake_case          =	kwargs.pop("""local_files_only"""      ,    lowercase	)

						if os.path.isdir(lowercase	):
											__snake_case          =	os.path.join(lowercase      ,    lowercase	)
						elif os.path.isfile(lowercase	) or is_remote_url(lowercase	):
											__snake_case          =	pretrained_model_name_or_path
						else:
											__snake_case          =	hf_bucket_url(lowercase      ,    filename=lowercase      ,    use_cdn=lowercase	)

						try:
											# Load from URL or cache if already cached
											__snake_case          =	cached_path(
											    lowercase      ,    cache_dir=lowercase      ,    force_download=lowercase      ,    proxies=lowercase      ,    resume_download=lowercase      ,    local_files_only=lowercase      ,    )
											# Load config dict
											if resolved_config_file is None:
																raise EnvironmentError

											__snake_case          =	Config.load_yaml(lowercase	)

						except EnvironmentError:
											__snake_case          =	"""Can't load config for"""
											raise EnvironmentError(lowercase	)

						if resolved_config_file == config_file:
											print("""loading configuration file from path"""	)
						else:
											print("""loading configuration file cache"""	)

						return Config.load_yaml(lowercase	), kwargs




def       snake_case__	(       lowerCAmelCase   :		Union[str, Any]		):
					__snake_case          =	torch.load("""dump.pt"""				,					map_location=in_tensor.device		)
					__snake_case          =	in_tensor.numpy()
					__snake_case          =	out_tensor.numpy()[0]
					print(na.shape				,					na[0, 0, :5]		)
					print(na.shape				,					na[0, 0, :5]		)
					assert np.allclose(lowerCAmelCase				,					lowerCAmelCase				,					rtol=0.0_1				,					atol=0.1		), (
					    F'''{sum([1 for x in np.isclose(lowerCAmelCase				,					lowerCAmelCase				,					rtol=0.0_1				,					atol=0.1		).flatten() if x is False]		)/len(na.flatten()		)*100:.4f} %'''
					    " element-wise mismatch"
					)
					raise Exception("""tensors are all good"""		)

					# Hugging face functions below




def       snake_case__	(       lowerCAmelCase   :		Dict		):
					__snake_case          =	urlparse(lowerCAmelCase		)
					return parsed.scheme in ("http", "https")




def       snake_case__	(       lowerCAmelCase   :		str				,					lowerCAmelCase   :		str				,					lowerCAmelCase   :		List[Any]=True		):
					__snake_case          =	CLOUDFRONT_DISTRIB_PREFIX if use_cdn else S3_BUCKET_PREFIX
					__snake_case          =	"""/""" not in model_id
					if legacy_format:
										return F'''{endpoint}/{model_id}-{filename}'''
					else:
										return F'''{endpoint}/{model_id}/{filename}'''




def       snake_case__	(       lowerCAmelCase   :		Optional[int]				,					lowerCAmelCase   :		Any				,					lowerCAmelCase   :		Optional[Any]=None				,					lowerCAmelCase   :		int=0				,					lowerCAmelCase   :		Optional[Any]=None				,					):
					__snake_case          =	"""python/{}""".format(sys.version.split()[0]		)
					if _torch_available:
										ua += "; torch/{}".format(torch.__version__		)
					if isinstance(lowerCAmelCase				,					lowerCAmelCase		):
										ua += "; " + "; ".join("""{}/{}""".format(lowerCAmelCase				,					lowerCAmelCase		) for k, v in user_agent.items()		)
					elif isinstance(lowerCAmelCase				,					lowerCAmelCase		):
										ua += "; " + user_agent
					__snake_case          =	{"""user-agent""": ua}
					if resume_size > 0:
										__snake_case          =	"""bytes=%d-""" % (resume_size,)
					__snake_case          =	requests.get(lowerCAmelCase				,					stream=lowerCAmelCase				,					proxies=lowerCAmelCase				,					headers=lowerCAmelCase		)
					if response.status_code == 416:  # Range not satisfiable
										return
					__snake_case          =	response.headers.get("""Content-Length"""		)
					__snake_case          =	resume_size + int(lowerCAmelCase		) if content_length is not None else None
					__snake_case          =	tqdm(
					    unit="""B"""				,					unit_scale=lowerCAmelCase				,					total=lowerCAmelCase				,					initial=lowerCAmelCase				,					desc="""Downloading"""				,					)
					for chunk in response.iter_content(chunk_size=1_024		):
										if chunk:  # filter out keep-alive new chunks
															progress.update(len(lowerCAmelCase		)		)
															temp_file.write(lowerCAmelCase		)
					progress.close()




def       snake_case__	(       lowerCAmelCase   :		Any				,					lowerCAmelCase   :		Any=None				,					lowerCAmelCase   :		Tuple=False				,					lowerCAmelCase   :		Union[str, Any]=None				,					lowerCAmelCase   :		Union[str, Any]=10				,					lowerCAmelCase   :		Any=False				,					lowerCAmelCase   :		Optional[Any]=None				,					lowerCAmelCase   :		List[str]=False				,					):
					if cache_dir is None:
										__snake_case          =	TRANSFORMERS_CACHE
					if isinstance(lowerCAmelCase				,					lowerCAmelCase		):
										__snake_case          =	str(lowerCAmelCase		)

					os.makedirs(lowerCAmelCase				,					exist_ok=lowerCAmelCase		)

					__snake_case          =	None
					if not local_files_only:
										try:
															__snake_case          =	requests.head(lowerCAmelCase				,					allow_redirects=lowerCAmelCase				,					proxies=lowerCAmelCase				,					timeout=lowerCAmelCase		)
															if response.status_code == 200:
																				__snake_case          =	response.headers.get("""ETag"""		)
										except (EnvironmentError, requests.exceptions.Timeout):
															# etag is already None
															pass

					__snake_case          =	url_to_filename(lowerCAmelCase				,					lowerCAmelCase		)

					# get cache path to put the file
					__snake_case          =	os.path.join(lowerCAmelCase				,					lowerCAmelCase		)

					# etag is None = we don't have a connection, or url doesn't exist, or is otherwise inaccessible.
					# try to get the last downloaded one
					if etag is None:
										if os.path.exists(lowerCAmelCase		):
															return cache_path
										else:
															__snake_case          =	[
															    file
															    for file in fnmatch.filter(os.listdir(lowerCAmelCase		)				,					filename + """.*"""		)
															    if not file.endswith(""".json"""		) and not file.endswith(""".lock"""		)
															]
															if len(lowerCAmelCase		) > 0:
																				return os.path.join(lowerCAmelCase				,					matching_files[-1]		)
															else:
																				# If files cannot be found and local_files_only=True,
																				# the models might've been found if local_files_only=False
																				# Notify the user about that
																				if local_files_only:
																									raise ValueError(
																									    """Cannot find the requested files in the cached path and outgoing traffic has been"""
																									    """ disabled. To enable model look-ups and downloads online, set 'local_files_only'"""
																									    """ to False."""		)
																				return None

    # From now on, etag is not None.
					if os.path.exists(lowerCAmelCase		) and not force_download:
										return cache_path

					# Prevent parallel downloads of the same file with a lock.
					__snake_case          =	cache_path + """.lock"""
					with FileLock(lowerCAmelCase		):
										# If the download just completed while the lock was activated.
										if os.path.exists(lowerCAmelCase		) and not force_download:
															# Even if returning early like here, the lock will be released.
															return cache_path

										if resume_download:
															__snake_case          =	cache_path + """.incomplete"""

															@contextmanager
															def _resumable_file_manager():
																				with open(lowerCAmelCase				,					"""a+b"""		) as f:
																									yield f

															__snake_case          =	_resumable_file_manager
															if os.path.exists(lowerCAmelCase		):
																				__snake_case          =	os.stat(lowerCAmelCase		).st_size
															else:
																				__snake_case          =	0
										else:
															__snake_case          =	partial(tempfile.NamedTemporaryFile				,					dir=lowerCAmelCase				,					delete=lowerCAmelCase		)
															__snake_case          =	0

										# Download to temporary file, then copy to cache dir once finished.
										# Otherwise you get corrupt cache entries if the download gets interrupted.
										with temp_file_manager() as temp_file:
															print(
															    """%s not found in cache or force_download set to True, downloading to %s"""				,					lowerCAmelCase				,					temp_file.name				,					)

															http_get(
															    lowerCAmelCase				,					lowerCAmelCase				,					proxies=lowerCAmelCase				,					resume_size=lowerCAmelCase				,					user_agent=lowerCAmelCase				,					)

										os.replace(temp_file.name				,					lowerCAmelCase		)

										__snake_case          =	{"""url""": url, """etag""": etag}
										__snake_case          =	cache_path + """.json"""
										with open(lowerCAmelCase				,					"""w"""		) as meta_file:
															json.dump(lowerCAmelCase				,					lowerCAmelCase		)

					return cache_path




def       snake_case__	(       lowerCAmelCase   :		Dict				,					lowerCAmelCase   :		Union[str, Any]=None		):
					__snake_case          =	url.encode("""utf-8"""		)
					__snake_case          =	shaaaa(lowerCAmelCase		)
					__snake_case          =	url_hash.hexdigest()

					if etag:
										__snake_case          =	etag.encode("""utf-8"""		)
										__snake_case          =	shaaaa(lowerCAmelCase		)
										filename += "." + etag_hash.hexdigest()

					if url.endswith(""".h5"""		):
										filename += ".h5"

					return filename




def       snake_case__	(       lowerCAmelCase   :		List[Any]				,					lowerCAmelCase   :		List[str]=None				,					lowerCAmelCase   :		Union[str, Any]=False				,					lowerCAmelCase   :		Optional[int]=None				,					lowerCAmelCase   :		Union[str, Any]=False				,					lowerCAmelCase   :		Dict=None				,					lowerCAmelCase   :		Union[str, Any]=False				,					lowerCAmelCase   :		Dict=False				,					lowerCAmelCase   :		Dict=False				,					):
					if cache_dir is None:
										__snake_case          =	TRANSFORMERS_CACHE
					if isinstance(lowerCAmelCase				,					lowerCAmelCase		):
										__snake_case          =	str(lowerCAmelCase		)
					if isinstance(lowerCAmelCase				,					lowerCAmelCase		):
										__snake_case          =	str(lowerCAmelCase		)

					if is_remote_url(lowerCAmelCase		):
										# URL, so get it from the cache (downloading if necessary)
										__snake_case          =	get_from_cache(
										    lowerCAmelCase				,					cache_dir=lowerCAmelCase				,					force_download=lowerCAmelCase				,					proxies=lowerCAmelCase				,					resume_download=lowerCAmelCase				,					user_agent=lowerCAmelCase				,					local_files_only=lowerCAmelCase				,					)
					elif os.path.exists(lowerCAmelCase		):
										# File, and it exists.
										__snake_case          =	url_or_filename
					elif urlparse(lowerCAmelCase		).scheme == "":
										# File, but it doesn't exist.
										raise EnvironmentError("""file {} not found""".format(lowerCAmelCase		)		)
					else:
										# Something unknown
										raise ValueError("""unable to parse {} as a URL or as a local path""".format(lowerCAmelCase		)		)

					if extract_compressed_file:
										if not is_zipfile(lowerCAmelCase		) and not tarfile.is_tarfile(lowerCAmelCase		):
															return output_path

										# Path where we extract compressed archives
										# We avoid '.' in dir name and add "-extracted" at the end: "./model.zip" => "./model-zip-extracted/"
										__snake_case      ,      __snake_case          =	os.path.split(lowerCAmelCase		)
										__snake_case          =	output_file.replace("""."""				,					"""-"""		) + """-extracted"""
										__snake_case          =	os.path.join(lowerCAmelCase				,					lowerCAmelCase		)

										if os.path.isdir(lowerCAmelCase		) and os.listdir(lowerCAmelCase		) and not force_extract:
															return output_path_extracted

										# Prevent parallel extractions
										__snake_case          =	output_path + """.lock"""
										with FileLock(lowerCAmelCase		):
															shutil.rmtree(lowerCAmelCase				,					ignore_errors=lowerCAmelCase		)
															os.makedirs(lowerCAmelCase		)
															if is_zipfile(lowerCAmelCase		):
																				with ZipFile(lowerCAmelCase				,					"""r"""		) as zip_file:
																									zip_file.extractall(lowerCAmelCase		)
																									zip_file.close()
															elif tarfile.is_tarfile(lowerCAmelCase		):
																				__snake_case          =	tarfile.open(lowerCAmelCase		)
																				tar_file.extractall(lowerCAmelCase		)
																				tar_file.close()
															else:
																				raise EnvironmentError("""Archive format of {} could not be identified""".format(lowerCAmelCase		)		)

										return output_path_extracted

					return output_path




def       snake_case__	(       lowerCAmelCase   :		int				,					lowerCAmelCase   :		List[str]=","		):
					assert isinstance(lowerCAmelCase				,					lowerCAmelCase		)
					if os.path.isfile(lowerCAmelCase		):
										with open(lowerCAmelCase		) as f:
															__snake_case          =	eval(f.read()		)
					else:
										__snake_case          =	requests.get(lowerCAmelCase		)
										try:
															__snake_case          =	requests.json()
										except Exception:
															__snake_case          =	req.content.decode()
															assert data is not None, "could not connect"
															try:
																				__snake_case          =	eval(lowerCAmelCase		)
															except Exception:
																				__snake_case          =	data.split("""\n"""		)
										req.close()
					return data




def       snake_case__	(       lowerCAmelCase   :		str		):
					__snake_case          =	requests.get(lowerCAmelCase		)
					__snake_case          =	np.array(Image.open(BytesIO(response.content		)		)		)
					return img




def       snake_case__	(       lowerCAmelCase   :		int		):
					__snake_case          =	url.split("""/"""		)[-1]
					if fn not in os.listdir(os.getcwd()		):
										wget.download(lowerCAmelCase		)
					with open(lowerCAmelCase				,					"""rb"""		) as stream:
										__snake_case          =	pkl.load(lowerCAmelCase		)
					__snake_case          =	weights.pop("""model"""		)
					__snake_case          =	{}
					for k, v in model.items():
										__snake_case          =	torch.from_numpy(lowerCAmelCase		)
										if "running_var" in k:
															__snake_case          =	torch.tensor([0]		)
															__snake_case          =	k.replace("""running_var"""				,					"""num_batches_tracked"""		)
															__snake_case          =	zero
					return new




def       snake_case__	(       ):
					print(F'''{os.path.abspath(os.path.join(lowerCAmelCase				,					os.pardir		)		)}/demo.ipynb'''		)




def       snake_case__	(       lowerCAmelCase   :		int				,					lowerCAmelCase   :		int="RGB"		):
					assert isinstance(lowerCAmelCase				,					lowerCAmelCase		)
					if os.path.isfile(lowerCAmelCase		):
										__snake_case          =	cva.imread(lowerCAmelCase		)
					else:
										__snake_case          =	get_image_from_url(lowerCAmelCase		)
										assert img is not None, F'''could not connect to: {im}'''
					__snake_case          =	cva.cvtColor(lowerCAmelCase				,					cva.COLOR_BGR2RGB		)
					if input_format == "RGB":
										__snake_case          =	img[:, :, ::-1]
					return img




def       snake_case__	(       lowerCAmelCase   :		Optional[Any]				,					lowerCAmelCase   :		str=1		):
					return (images[i : i + batch] for i in range(0				,					len(lowerCAmelCase		)				,					lowerCAmelCase		))








"""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


UpperCamelCase__ :    Optional[int] 					=							10_00_00_00_00_00
UpperCamelCase__ :    int 					=							1_00_00

UpperCamelCase__					,					UpperCamelCase__ :    List[str] 					=							os.path.split(__file__)
UpperCamelCase__ :    Any 					=							os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))




def       snake_case__	(       lowerCAmelCase   :		int				,					lowerCAmelCase   :		int		):
					__snake_case          =	pa.Table.from_pydict({"""col""": [0] * chunk_size}		)
					__snake_case          =	pa.concat_tables([table] * (num_examples // chunk_size)		)
					return datasets.Dataset(lowerCAmelCase				,					fingerprint="""table_100B"""		)
@dataclass
class     A__      :
	A_							:				int
	A_							:				int
	A_							:				int
	A_							:				int




	def 							a_		(   self  :	Optional[Any]	)					-> Any:
						__snake_case          =	np.random.default_rng(self.seed	)
						__snake_case          =	rng.integers(low=self.low      ,    high=self.high      ,    size=self.size	).tolist()




	def __iter__(   self  :	str	)					-> int:
						return iter(self._sampled_values	)




	def __len__(   self  :	Union[str, Any]	)					-> Any:
						return self.size




@get_duration
def       snake_case__	(       lowerCAmelCase   :		datasets.Dataset		):
					__snake_case          =	dataset[0]




@get_duration
def       snake_case__	(       lowerCAmelCase   :		datasets.Dataset		):
					__snake_case          =	dataset[-1]




@get_duration
def       snake_case__	(       lowerCAmelCase   :		datasets.Dataset		):
					__snake_case          =	dataset[range(len(lowerCAmelCase		) // 2				,					len(lowerCAmelCase		) // 2 + 1_024		)]




@get_duration
def       snake_case__	(       lowerCAmelCase   :		datasets.Dataset		):
					__snake_case          =	dataset[RandIter(0				,					len(lowerCAmelCase		)				,					1_024				,					seed=42		)]




def       snake_case__	(       ):
					__snake_case          =	{"""num examples""": SPEED_TEST_N_EXAMPLES}
					__snake_case          =	(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
					print("""generating dataset"""		)
					__snake_case          =	generate_100B_dataset(num_examples=lowerCAmelCase				,					chunk_size=lowerCAmelCase		)
					print("""Functions"""		)
					for func in functions:
										print(func.__name__		)
										__snake_case          =	func(lowerCAmelCase		)

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


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


