




'''simple docstring'''





import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD


def 	UpperCamelCase_(      snake_case				:			str	):

							'''simple docstring'''






							def wrapper(*snake_case				:			Tuple				,							**snake_case				:			Dict	):
														snake_case_         = timeit.default_timer()
														snake_case_         = func(*lowercase_				,							**lowercase_	)
														snake_case_         = timeit.default_timer() - starttime
														return delta

							snake_case_         = func.__name__

							return wrapper


def 	UpperCamelCase_(      snake_case				:			Any				,							snake_case				:			List[Any]=1_0_0				,							snake_case				:			List[str]=None	):

							'''simple docstring'''






							snake_case_         = []
							snake_case_         = seq_shapes or {}
							for i in range(lowercase_	):
														snake_case_         = {}
														for col_id, (k, v) in enumerate(features.items()	):
																					if isinstance(lowercase_				,							_ArrayXD	):
																												snake_case_         = np.random.rand(*v.shape	).astype(v.dtype	)
																					elif isinstance(lowercase_				,							datasets.Value	):
																												if v.dtype == "string":
																																			snake_case_         = "The small grey turtle was surprisingly fast when challenged."
																												else:
																																			snake_case_         = np.random.randint(1_0				,							size=1	).astype(v.dtype	).item()
																					elif isinstance(lowercase_				,							datasets.Sequence	):
																												while isinstance(lowercase_				,							datasets.Sequence	):
																																			snake_case_         = v.feature
																												snake_case_         = seq_shapes[k]
																												snake_case_         = np.random.rand(*lowercase_	).astype(v.dtype	)
																					snake_case_         = data

														dummy_data.append((i, example)	)

							return dummy_data




def 	UpperCamelCase_(      snake_case				:			Optional[Any]				,							snake_case				:			Union[str, Any]				,							snake_case				:			Optional[Any]=1_0_0				,							snake_case				:			Any=None	):

							'''simple docstring'''






							snake_case_         = generate_examples(lowercase_				,							num_examples=lowercase_				,							seq_shapes=lowercase_	)

							with ArrowWriter(features=lowercase_				,							path=lowercase_	) as writer:
														for key, record in dummy_data:
																					snake_case_         = features.encode_example(lowercase_	)
																					writer.write(lowercase_	)

														snake_case_   , snake_case_         = writer.finalize()

							if not num_final_examples == num_examples:
														raise ValueError(
														    f'Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}.'	)

							snake_case_         = datasets.Dataset.from_file(filename=lowercase_				,							info=datasets.DatasetInfo(features=lowercase_	)	)

							return dataset










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


_lowerCamelCase      :						str							=  logging.get_logger(__name__)

_lowerCamelCase      :						List[str]							=  {"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""}


class 							UpperCamelCase_       (					UpperCAmelCase__	):

    '''simple docstring'''






    UpperCAmelCase__				    = '''openai-gpt'''
    UpperCAmelCase__				    = {
        '''max_position_embeddings''': '''n_positions''',
        '''hidden_size''': '''n_embd''',
        '''num_attention_heads''': '''n_head''',
        '''num_hidden_layers''': '''n_layer''',
    }


    def __init__(     self :      Union[str, Any]   ,					UpperCAmelCase__ :      Dict=40_478   ,					UpperCAmelCase__ :      str=512   ,					UpperCAmelCase__ :      Union[str, Any]=768   ,					UpperCAmelCase__ :      Optional[Any]=12   ,					UpperCAmelCase__ :      Any=12   ,					UpperCAmelCase__ :      Optional[Any]="gelu"   ,					UpperCAmelCase__ :      Any=0.1   ,					UpperCAmelCase__ :      List[str]=0.1   ,					UpperCAmelCase__ :      Tuple=0.1   ,					UpperCAmelCase__ :      List[str]=1e-5   ,					UpperCAmelCase__ :      int=0.02   ,					UpperCAmelCase__ :      Any="cls_index"   ,					UpperCAmelCase__ :      Optional[Any]=True   ,					UpperCAmelCase__ :      List[Any]=None   ,					UpperCAmelCase__ :      List[Any]=True   ,					UpperCAmelCase__ :      Optional[Any]=0.1   ,					**UpperCAmelCase__ :      Dict   ,					)		->Any:





           '''simple docstring'''

           A__ 					=       vocab_size
           A__ 					=       n_positions
           A__ 					=       n_embd
           A__ 					=       n_layer
           A__ 					=       n_head
           A__ 					=       afn
           A__ 					=       resid_pdrop
           A__ 					=       embd_pdrop
           A__ 					=       attn_pdrop
           A__ 					=       layer_norm_epsilon
           A__ 					=       initializer_range
           A__ 					=       summary_type
           A__ 					=       summary_use_proj
           A__ 					=       summary_activation
           A__ 					=       summary_first_dropout
           A__ 					=       summary_proj_to_labels
           super().__init__(**UpperCAmelCase__)


