


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


lowercase_	   =     logging.get_logger(__name__)

lowercase_	   =     {
    '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 	A_ (	__UpperCamelCase   ):




      '''simple docstring'''


      __snake_case 	=       """falcon"""
      __snake_case 	=       ["""past_key_values"""]




      def __init__(    self:	Dict						,				a:	List[Any]=6_5024						,				a:	Union[str, Any]=4544						,				a:	Union[str, Any]=32						,				a:	Tuple=71						,				a:	Optional[int]=1e-5						,				a:	Tuple=0.0_2						,				a:	Union[str, Any]=True						,				a:	Any=0.0						,				a:	str=0.0						,				a:	List[Any]=None						,				a:	Optional[int]=False						,				a:	str=False						,				a:	Dict=True						,				a:	Tuple=True						,				a:	Optional[Any]=False						,				a:	Any=11						,				a:	List[str]=11						,				**a:	List[Any]						,				):
       __lowerCamelCase		:							Any		 =						vocab_size
       # Backward compatibility with n_embed kwarg
       __lowerCamelCase		:							Optional[int]		 =						kwargs.pop('n_embed'						,				a    )
       __lowerCamelCase		:							int		 =						hidden_size if n_embed is None else n_embed
       __lowerCamelCase		:							Optional[Any]		 =						num_hidden_layers
       __lowerCamelCase		:							Optional[Any]		 =						num_attention_heads
       __lowerCamelCase		:							List[Any]		 =						layer_norm_epsilon
       __lowerCamelCase		:							Dict		 =						initializer_range
       __lowerCamelCase		:							Tuple		 =						use_cache
       __lowerCamelCase		:							Tuple		 =						hidden_dropout
       __lowerCamelCase		:							List[Any]		 =						attention_dropout

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

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




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




      @property
      def 					_snake_case     (    self:	int    ):
       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 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	**SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Optional[int]		 =						dataset.map(**SCREAMING_SNAKE_CASE__						)
@get_duration
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	**SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Tuple		 =						dataset.filter(**SCREAMING_SNAKE_CASE__						)
def 				UpperCamelCase__					(  ):
 __lowerCamelCase		:							str		 =						{'num examples': SPEED_TEST_N_EXAMPLES}
 with tempfile.TemporaryDirectory() as tmp_dir:
  __lowerCamelCase		:							Any		 =						datasets.Features({'text': datasets.Value('string'						), 'numbers': datasets.Value('float32'						)}						)
  __lowerCamelCase		:							Any		 =						generate_example_dataset(
      os.path.join(SCREAMING_SNAKE_CASE__      ,	'dataset.arrow'						)      ,	SCREAMING_SNAKE_CASE__      ,	num_examples=SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							List[Any]		 =						transformers.AutoTokenizer.from_pretrained('bert-base-cased'      ,	use_fast=SCREAMING_SNAKE_CASE__						)

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

  __lowerCamelCase		:							str		 =						map(SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							int		 =						map(SCREAMING_SNAKE_CASE__      ,	batched=SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							Optional[int]		 =						map(SCREAMING_SNAKE_CASE__      ,	function=lambda SCREAMING_SNAKE_CASE__						: None      ,	batched=SCREAMING_SNAKE_CASE__						)

  with dataset.formatted_as(type='numpy'						):
   __lowerCamelCase		:							Union[str, Any]		 =						map(SCREAMING_SNAKE_CASE__      ,	function=lambda SCREAMING_SNAKE_CASE__						: None      ,	batched=SCREAMING_SNAKE_CASE__						)

  with dataset.formatted_as(type='pandas'						):
   __lowerCamelCase		:							Any		 =						map(SCREAMING_SNAKE_CASE__      ,	function=lambda SCREAMING_SNAKE_CASE__						: None      ,	batched=SCREAMING_SNAKE_CASE__						)

  with dataset.formatted_as(type='torch'      ,	columns='numbers'						):
   __lowerCamelCase		:							List[str]		 =						map(SCREAMING_SNAKE_CASE__      ,	function=lambda SCREAMING_SNAKE_CASE__						: None      ,	batched=SCREAMING_SNAKE_CASE__						)

  with dataset.formatted_as(type='tensorflow'      ,	columns='numbers'						):
   __lowerCamelCase		:							List[Any]		 =						map(SCREAMING_SNAKE_CASE__      ,	function=lambda SCREAMING_SNAKE_CASE__						: None      ,	batched=SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							Optional[Any]		 =						map(SCREAMING_SNAKE_CASE__      ,	function=SCREAMING_SNAKE_CASE__      ,	batched=SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							Optional[int]		 =						filter(SCREAMING_SNAKE_CASE__						)

  # 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(SCREAMING_SNAKE_CASE__      ,	'wb'						) as f:
  f.write(json.dumps(SCREAMING_SNAKE_CASE__						).encode('utf-8'						)						)


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

