


"""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__		:  Optional[int]     					=					100_000_000_000
snake_case__		:  str     					=					10_000

snake_case__					,  snake_case__		:  Tuple     					=					os.path.split(__file__)
snake_case__		:  Optional[int]     					=					os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))


def   _snake_case    (    _snake_case					:      Optional[Any]			, _snake_case					:      Any      ):
      lowerCAmelCase       :						int							= pa.Table.from_pydict({'''col''': [0] * chunk_size}      )
      lowerCAmelCase       :						Tuple							= pa.concat_tables([table] * (num_examples // chunk_size)      )
      return datasets.Dataset(_snake_case			, fingerprint='''table_100B'''      )



@dataclass
class 		snake_case_:
     __UpperCamelCase	=       42
     __UpperCamelCase	=       42
     __UpperCamelCase	=       42
     __UpperCamelCase	=       42






     def   lowerCamelCase__  (						self	:       str					):
           lowerCAmelCase       :						Dict							= np.random.default_rng(self.seed					)
           lowerCAmelCase       :						str							= rng.integers(low=self.low       ,					high=self.high       ,					size=self.size					).tolist()






     def __iter__(						self	:       Union[str, Any]					):
           return iter(self._sampled_values					)






     def __len__(						self	:       Dict					):
           return self.size



@get_duration
def   _snake_case    (    _snake_case					:      List[str]      ):
      lowerCAmelCase       :						int							= dataset[0]


@get_duration
def   _snake_case    (    _snake_case					:      str      ):
      lowerCAmelCase       :						List[Any]							= dataset[-1]


@get_duration
def   _snake_case    (    _snake_case					:      Any      ):
      lowerCAmelCase       :						str							= dataset[range(len(_snake_case      ) // 2			, len(_snake_case      ) // 2 + 1024      )]


@get_duration
def   _snake_case    (    _snake_case					:      int      ):
      lowerCAmelCase       :						Any							= dataset[RandIter(0			, len(_snake_case      )			, 1024			, seed=42      )]


def   _snake_case    (    ):
      lowerCAmelCase       :						Optional[int]							= {'num examples': SPEED_TEST_N_EXAMPLES}
      lowerCAmelCase       :						Optional[int]							= (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
      print('''generating dataset'''      )
      lowerCAmelCase       :						Tuple							= generate_100B_dataset(num_examples=_snake_case			, chunk_size=_snake_case      )
      print('''Functions'''      )
      for func in functions:
            print(func.__name__      )
            lowerCAmelCase       :						Optional[Any]							= func(_snake_case      )

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


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








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCamelCase__						=		{
    'configuration_prophetnet': ['PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ProphetNetConfig'],
    'tokenization_prophetnet': ['ProphetNetTokenizer'],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase__						=		[
							    'PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'ProphetNetDecoder',
							    'ProphetNetEncoder',
							    'ProphetNetForCausalLM',
							    'ProphetNetForConditionalGeneration',
							    'ProphetNetModel',
							    'ProphetNetPreTrainedModel',
							]


if TYPE_CHECKING:
							from .configuration_prophetnet import PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP, ProphetNetConfig
							from .tokenization_prophetnet import ProphetNetTokenizer

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_prophetnet import (
														    PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST,
														    ProphetNetDecoder,
														    ProphetNetEncoder,
														    ProphetNetForCausalLM,
														    ProphetNetForConditionalGeneration,
														    ProphetNetModel,
														    ProphetNetPreTrainedModel,
														)

else:
							import sys

							UpperCamelCase__						=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
