

import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


_UpperCamelCase			       =			1000_0000_0000
_UpperCamelCase			       =			1_0000

_UpperCamelCase       ,				_UpperCamelCase			       =			os.path.split(__file__)
_UpperCamelCase			       =			os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))
def 						UpperCamelCase_(			snake_case__:  int  ,    snake_case__:  int   )       -> datasets.Dataset:
 UpperCAmelCase__							=				pa.Table.from_pydict({'col': [0] * chunk_size}   )
 UpperCAmelCase__							=				pa.concat_tables([table] * (num_examples // chunk_size)   )
 return datasets.Dataset(snake_case__  ,    fingerprint='table_100B'   )



@dataclass
class     lowercase						:



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE												=				42
 __SCREAMING_SNAKE_CASE												=				42
 __SCREAMING_SNAKE_CASE												=				42
 __SCREAMING_SNAKE_CASE												=				42




 def   UpperCamelCase__							(self ) ->					Any:






  """simple docstring"""





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




 def __iter__(self ) ->					int:






  """simple docstring"""





  return iter(self._sampled_values )




 def __len__(self ) ->					Optional[int]:






  """simple docstring"""





  return self.size







@get_duration
def 						UpperCamelCase_(			snake_case__:  datasets.Dataset   )       -> List[str]:
 UpperCAmelCase__							=				dataset[0]
@get_duration
def 						UpperCamelCase_(			snake_case__:  datasets.Dataset   )       -> str:
 UpperCAmelCase__							=				dataset[-1]
@get_duration
def 						UpperCamelCase_(			snake_case__:  datasets.Dataset   )       -> str:
 UpperCAmelCase__							=				dataset[range(len(snake_case__   ) // 2  ,    len(snake_case__   ) // 2 + 10_24   )]
@get_duration
def 						UpperCamelCase_(			snake_case__:  datasets.Dataset   )       -> List[Any]:
 UpperCAmelCase__							=				dataset[RandIter(0  ,    len(snake_case__   )  ,    10_24  ,    seed=42   )]
def 						UpperCamelCase_(			)       -> Tuple:
 UpperCAmelCase__							=				{'num examples': SPEED_TEST_N_EXAMPLES}
 UpperCAmelCase__							=				(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
 print('generating dataset'   )
 UpperCAmelCase__							=				generate_100B_dataset(num_examples=snake_case__  ,    chunk_size=snake_case__   )
 print('Functions'   )
 for func in functions:
  print(func.__name__   )
  UpperCAmelCase__							=				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 collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_UpperCamelCase			       =			logging.get_logger(__name__)

_UpperCamelCase			       =			{
    '''google/rembert''': '''https://huggingface.co/google/rembert/resolve/main/config.json''',
    # See all RemBERT models at https://huggingface.co/models?filter=rembert
}



class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 __SCREAMING_SNAKE_CASE												=				"""rembert"""




 def __init__(self       ,       __a=250300       ,       __a=1152       ,       __a=32       ,       __a=18       ,       __a=256       ,       __a=1664       ,       __a=4608       ,       __a="gelu"       ,       __a=0.0       ,       __a=0.0       ,       __a=0.1       ,       __a=512       ,       __a=2       ,       __a=0.02       ,       __a=1E-1_2       ,       __a=True       ,       __a=0       ,       __a=312       ,       __a=313       ,       **__a       ,       ) ->					str:






  """simple docstring"""





  super().__init__(pad_token_id=__a       ,       bos_token_id=__a       ,       eos_token_id=__a       ,       **__a )

  UpperCAmelCase__							=				vocab_size
  UpperCAmelCase__							=				input_embedding_size
  UpperCAmelCase__							=				output_embedding_size
  UpperCAmelCase__							=				max_position_embeddings
  UpperCAmelCase__							=				hidden_size
  UpperCAmelCase__							=				num_hidden_layers
  UpperCAmelCase__							=				num_attention_heads
  UpperCAmelCase__							=				intermediate_size
  UpperCAmelCase__							=				hidden_act
  UpperCAmelCase__							=				hidden_dropout_prob
  UpperCAmelCase__							=				attention_probs_dropout_prob
  UpperCAmelCase__							=				classifier_dropout_prob
  UpperCAmelCase__							=				initializer_range
  UpperCAmelCase__							=				type_vocab_size
  UpperCAmelCase__							=				layer_norm_eps
  UpperCAmelCase__							=				use_cache
  UpperCAmelCase__							=				False







class     lowercase						(       _UpperCamelCase					):



 '''simple docstring'''


 @property
 def   UpperCamelCase__							(self ) ->					Mapping[str, Mapping[int, str]]:






  """simple docstring"""





  if self.task == "multiple-choice":
   UpperCAmelCase__							=				{0: 'batch', 1: 'choice', 2: 'sequence'}
  else:
   UpperCAmelCase__							=				{0: 'batch', 1: 'sequence'}
  return OrderedDict(
      [
          ('input_ids', dynamic_axis),
          ('attention_mask', dynamic_axis),
          ('token_type_ids', dynamic_axis),
      ] )




 @property
 def   UpperCamelCase__							(self ) ->					float:






  """simple docstring"""





  return 1E-4



