





'''simple docstring'''


import timeit

import numpy as np

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


def 						__a(SCREAMING_SNAKE_CASE_	:       Union[str, Any]     ):



    '''simple docstring'''





    def wrapper(*SCREAMING_SNAKE_CASE_	:       Dict		,							**SCREAMING_SNAKE_CASE_	:       Tuple     ):
        _lowerCAmelCase						      =   timeit.default_timer()
        _lowerCAmelCase						      =   func(*SCREAMING_SNAKE_CASE_		,							**SCREAMING_SNAKE_CASE_     )
        _lowerCAmelCase						      =   timeit.default_timer() - starttime
        return delta

    _lowerCAmelCase						      =   func.__name__

    return wrapper


def 						__a(SCREAMING_SNAKE_CASE_	:       dict		,							SCREAMING_SNAKE_CASE_	:       List[Any]=100		,							SCREAMING_SNAKE_CASE_	:       Optional[int]=None     ):



    '''simple docstring'''





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

        dummy_data.append((i, example)     )

    return dummy_data





def 						__a(SCREAMING_SNAKE_CASE_	:       Optional[int]		,							SCREAMING_SNAKE_CASE_	:       Optional[Any]		,							SCREAMING_SNAKE_CASE_	:       Dict=100		,							SCREAMING_SNAKE_CASE_	:       int=None     ):



    '''simple docstring'''





    _lowerCAmelCase						      =   generate_examples(SCREAMING_SNAKE_CASE_		,							num_examples=SCREAMING_SNAKE_CASE_		,							seq_shapes=SCREAMING_SNAKE_CASE_     )

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

        _lowerCAmelCase      ,      _lowerCAmelCase						      =   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}.'''     )

    _lowerCAmelCase						      =   datasets.Dataset.from_file(filename=SCREAMING_SNAKE_CASE_		,							info=datasets.DatasetInfo(features=SCREAMING_SNAKE_CASE_     )     )

    return dataset









'''simple docstring'''


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


_SCREAMING_SNAKE_CASE									=				logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE									=				{
    "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json",
    "tiiuae/falcon-7b": "https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json",
}

class  lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase    :				Any								=       "falcon"
 __lowerCamelCase    :				List[str]								=       ["past_key_values"]




 def __init__(						self      ,  _lowerCAmelCase=65024      ,  _lowerCAmelCase=4544      ,  _lowerCAmelCase=32      ,  _lowerCAmelCase=71      ,  _lowerCAmelCase=1E-5      ,  _lowerCAmelCase=0.02      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=0.0      ,  _lowerCAmelCase=0.0      ,  _lowerCAmelCase=None      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=11      ,  _lowerCAmelCase=11      ,  **_lowerCAmelCase      ,  )     ->				Union[str, Any]:
     _lowerCAmelCase						      =   vocab_size
     # Backward compatibility with n_embed kwarg
     _lowerCAmelCase						      =   kwargs.pop("n_embed"      ,  _lowerCAmelCase		)
     _lowerCAmelCase						      =   hidden_size if n_embed is None else n_embed
     _lowerCAmelCase						      =   num_hidden_layers
     _lowerCAmelCase						      =   num_attention_heads
     _lowerCAmelCase						      =   layer_norm_epsilon
     _lowerCAmelCase						      =   initializer_range
     _lowerCAmelCase						      =   use_cache
     _lowerCAmelCase						      =   hidden_dropout
     _lowerCAmelCase						      =   attention_dropout

     _lowerCAmelCase						      =   bos_token_id
     _lowerCAmelCase						      =   eos_token_id
     _lowerCAmelCase						      =   num_attention_heads if num_kv_heads is None else num_kv_heads
     _lowerCAmelCase						      =   alibi
     _lowerCAmelCase						      =   new_decoder_architecture
     _lowerCAmelCase						      =   multi_query  # Ignored when new_decoder_architecture is True
     _lowerCAmelCase						      =   parallel_attn
     _lowerCAmelCase						      =   bias

     super().__init__(bos_token_id=_lowerCAmelCase      ,  eos_token_id=_lowerCAmelCase      ,  **_lowerCAmelCase		)




 @property
 def 				_snake_case (						self		)     ->				Optional[Any]:
     return self.hidden_size // self.num_attention_heads





 @property
 def 				_snake_case (						self		)     ->				Optional[Any]:
     return not self.alibi


