





from ..utils import DummyObject, requires_backends



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   Union[str, Any]       , *UpperCAmelCase_				:   Optional[Any]       , **UpperCAmelCase_				:   Dict)       ->Dict:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Optional[Any]       , *UpperCAmelCase_				:   Optional[int]       , **UpperCAmelCase_				:   str)       ->Any:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   List[Any]       , *UpperCAmelCase_				:   Optional[Any]       , **UpperCAmelCase_				:   Optional[Any])       ->Union[str, Any]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   List[str]       , *UpperCAmelCase_				:   Union[str, Any]       , **UpperCAmelCase_				:   Optional[int])       ->Any:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Tuple       , *UpperCAmelCase_				:   Optional[Any]       , **UpperCAmelCase_				:   Any)       ->List[str]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Union[str, Any]       , *UpperCAmelCase_				:   int       , **UpperCAmelCase_				:   int)       ->Optional[Any]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   Optional[Any]       , *UpperCAmelCase_				:   Any       , **UpperCAmelCase_				:   int)       ->int:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Dict       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   List[Any])       ->Union[str, Any]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Tuple       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   List[Any])       ->str:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   Dict       , *UpperCAmelCase_				:   Dict       , **UpperCAmelCase_				:   Optional[int])       ->Union[str, Any]:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Optional[Any]       , *UpperCAmelCase_				:   Tuple       , **UpperCAmelCase_				:   List[str])       ->int:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Dict       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   str)       ->List[str]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   int       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   Optional[int])       ->Dict:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   str       , *UpperCAmelCase_				:   int       , **UpperCAmelCase_				:   Optional[int])       ->List[str]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Optional[Any]       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   Dict)       ->Union[str, Any]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



class    _SCREAMING_SNAKE_CASE						(	metaclass=__SCREAMING_SNAKE_CASE    ):







 '''simple docstring'''
 lowercase_		=			["torch", "transformers", "onnx"]

 def __init__(self				:   Dict       , *UpperCAmelCase_				:   Tuple       , **UpperCAmelCase_				:   Tuple)       ->Dict:



   '''simple docstring'''



   requires_backends(self       , ["torch", "transformers", "onnx"])

 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   Dict       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   Tuple)       ->Union[str, Any]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])







 @classmethod
 def 							SCREAMING_SNAKE_CASE_					(cls				:   str       , *UpperCAmelCase_				:   str       , **UpperCAmelCase_				:   int)       ->Optional[int]:



   '''simple docstring'''



   requires_backends(cls       , ["torch", "transformers", "onnx"])



import json
import os
import tempfile

import transformers

import datasets
from utils import generate_example_dataset, get_duration


_lowerCamelCase					   =5_0_0_0_0_0

_lowerCamelCase   ,  _lowerCamelCase					   =os.path.split(__file__)
_lowerCamelCase					   =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))





@get_duration
def     _a					(						lowerCamelCase,	**lowerCamelCase							):
 lowerCamelCase		:	Optional[Any]							=      dataset.map(**lowerCamelCase							)





@get_duration
def     _a					(						lowerCamelCase,	**lowerCamelCase							):
 lowerCamelCase		:	Optional[Any]							=      dataset.filter(**lowerCamelCase							)





def     _a					(						):
 lowerCamelCase		:	Optional[Any]							=      {"""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		:	Tuple							=      generate_example_dataset(
      os.path.join(lowerCamelCase,	"""dataset.arrow"""							),	lowerCamelCase,	num_examples=lowerCamelCase							)

  lowerCamelCase		:	Tuple							=      transformers.AutoTokenizer.from_pretrained("""bert-base-cased""",	use_fast=lowerCamelCase							)

  def tokenize(lowerCamelCase							):
   return tokenizer(examples["""text"""]							)

  lowerCamelCase		:	List[str]							=      map(lowerCamelCase							)

  lowerCamelCase		:	int							=      map(lowerCamelCase,	batched=lowerCamelCase							)

  lowerCamelCase		:	int							=      map(lowerCamelCase,	function=lambda lowerCamelCase							: None,	batched=lowerCamelCase							)

  with dataset.formatted_as(type="""numpy"""							):
   lowerCamelCase		:	Optional[int]							=      map(lowerCamelCase,	function=lambda lowerCamelCase							: None,	batched=lowerCamelCase							)

  with dataset.formatted_as(type="""pandas"""							):
   lowerCamelCase		:	List[str]							=      map(lowerCamelCase,	function=lambda lowerCamelCase							: None,	batched=lowerCamelCase							)

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

  with dataset.formatted_as(type="""tensorflow""",	columns="""numbers"""							):
   lowerCamelCase		:	Optional[int]							=      map(lowerCamelCase,	function=lambda lowerCamelCase							: None,	batched=lowerCamelCase							)

  lowerCamelCase		:	int							=      map(lowerCamelCase,	function=lowerCamelCase,	batched=lowerCamelCase							)

  lowerCamelCase		:	Union[str, Any]							=      filter(lowerCamelCase							)

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


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




