



"""simple docstring"""






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


lowerCAmelCase__              =							logging.get_logger(__name__)

lowerCAmelCase__              =							{
    '''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 			__snake_case			(      _lowercase):
  snake_case__							:  List[Any]         =		"falcon"
  snake_case__							:  Any         =		["past_key_values"]




  def __init__(					self	:		Any		,   __lowerCAmelCase	:		Union[str, Any]=6_5_0_2_4		,   __lowerCAmelCase	:		Optional[Any]=4_5_4_4		,   __lowerCAmelCase	:		Optional[Any]=3_2		,   __lowerCAmelCase	:		List[Any]=7_1		,   __lowerCAmelCase	:		Any=1E-5		,   __lowerCAmelCase	:		Dict=0.02		,   __lowerCAmelCase	:		Tuple=True		,   __lowerCAmelCase	:		Optional[int]=0.0		,   __lowerCAmelCase	:		List[str]=0.0		,   __lowerCAmelCase	:		int=None		,   __lowerCAmelCase	:		Union[str, Any]=False		,   __lowerCAmelCase	:		Dict=False		,   __lowerCAmelCase	:		int=True		,   __lowerCAmelCase	:		str=True		,   __lowerCAmelCase	:		Optional[int]=False		,   __lowerCAmelCase	:		int=1_1		,   __lowerCAmelCase	:		Optional[Any]=1_1		,   **__lowerCAmelCase	:		Dict		,   ):






         """simple docstring"""






         _lowerCamelCase		:							Union[str, Any]            =					vocab_size
         # Backward compatibility with n_embed kwarg
         _lowerCamelCase		:							Any            =					kwargs.pop('''n_embed'''		,   __lowerCAmelCase						)
         _lowerCamelCase		:							Tuple            =					hidden_size if n_embed is None else n_embed
         _lowerCamelCase		:							Optional[int]            =					num_hidden_layers
         _lowerCamelCase		:							Any            =					num_attention_heads
         _lowerCamelCase		:							Dict            =					layer_norm_epsilon
         _lowerCamelCase		:							int            =					initializer_range
         _lowerCamelCase		:							List[Any]            =					use_cache
         _lowerCamelCase		:							Tuple            =					hidden_dropout
         _lowerCamelCase		:							List[str]            =					attention_dropout

         _lowerCamelCase		:							List[str]            =					bos_token_id
         _lowerCamelCase		:							Optional[Any]            =					eos_token_id
         _lowerCamelCase		:							Optional[int]            =					num_attention_heads if num_kv_heads is None else num_kv_heads
         _lowerCamelCase		:							Optional[Any]            =					alibi
         _lowerCamelCase		:							str            =					new_decoder_architecture
         _lowerCamelCase		:							Union[str, Any]            =					multi_query  # Ignored when new_decoder_architecture is True
         _lowerCamelCase		:							List[Any]            =					parallel_attn
         _lowerCamelCase		:							str            =					bias

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




  @property
  def 		SCREAMING_SNAKE_CASE							(					self	:		int						):






         """simple docstring"""






         return self.hidden_size // self.num_attention_heads




  @property
  def 		SCREAMING_SNAKE_CASE							(					self	:		List[str]						):






         """simple docstring"""






         return not self.alibi





import json
import os
import tempfile

import transformers

import datasets
from utils import generate_example_dataset, get_duration


lowercase_   							=  5_0_0_0_0_0

lowercase_							,		lowercase_   							=  os.path.split(__file__)
lowercase_   							=  os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json'))
@get_duration
def 	a (     A__      :  datasets.Dataset ,  **A__      :  List[str]	)       -> Optional[Any]:





      """simple docstring"""



      _lowercase      			=dataset.map(**A__	)
@get_duration
def 	a (     A__      :  datasets.Dataset ,  **A__      :  List[Any]	)       -> List[str]:





      """simple docstring"""



      _lowercase      			=dataset.filter(**A__	)
def 	a (     )       -> Union[str, Any]:





      """simple docstring"""



      _lowercase      			={'num examples': SPEED_TEST_N_EXAMPLES}
      with tempfile.TemporaryDirectory() as tmp_dir:
            _lowercase      			=datasets.Features({'text': datasets.Value('string'	), 'numbers': datasets.Value('float32'	)}	)
            _lowercase      			=generate_example_dataset(
                os.path.join(A__ ,  'dataset.arrow'	) ,  A__ ,  num_examples=A__	)

            _lowercase      			=transformers.AutoTokenizer.from_pretrained('bert-base-cased' ,  use_fast=A__	)

            def tokenize(A__      :  int	):
                  return tokenizer(examples['text']	)

            _lowercase      			=map(A__	)

            _lowercase      			=map(A__ ,  batched=A__	)

            _lowercase      			=map(A__ ,  function=lambda A__	: None ,  batched=A__	)

            with dataset.formatted_as(type='numpy'	):
                  _lowercase      			=map(A__ ,  function=lambda A__	: None ,  batched=A__	)

            with dataset.formatted_as(type='pandas'	):
                  _lowercase      			=map(A__ ,  function=lambda A__	: None ,  batched=A__	)

            with dataset.formatted_as(type='torch' ,  columns='numbers'	):
                  _lowercase      			=map(A__ ,  function=lambda A__	: None ,  batched=A__	)

            with dataset.formatted_as(type='tensorflow' ,  columns='numbers'	):
                  _lowercase      			=map(A__ ,  function=lambda A__	: None ,  batched=A__	)

            _lowercase      			=map(A__ ,  function=A__ ,  batched=A__	)

            _lowercase      			=filter(A__	)

            # Activate later when tokenizer support batched inputs
            # with dataset.formatted_as(type='numpy'):
            #     times[func.__name__ + " fast-tokenizer batched numpy"] = func(dataset, function=tokenize, batched=True)

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


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


