import json
import os
import pickle
import subprocess
from hashlib import mda
from pathlib import Path
from tempfile import gettempdir
from textwrap import dedent
from types import CodeType, FunctionType
from unittest import TestCase
from unittest.mock import patch

import pytest
from multiprocess import Pool
from packaging import version

import datasets
from datasets.fingerprint import Hasher, fingerprint_transform
from datasets.table import InMemoryTable

from .utils import (
    require_regex,
    require_spacy,
    require_spacy_model,
    require_tiktoken,
    require_torch,
    require_transformers,
)







class      SCREAMING_SNAKE_CASE__					:

       def __init__(							self					:     Union[str, Any]			,			_lowerCAmelCase					:     Union[str, Any]			):
           __snake_case       :				str 			=    foo





       def __call__(							self					:     Any			):
           return self.foo







class      SCREAMING_SNAKE_CASE__					(  datasets.Dataset    ):

       @fingerprint_transform(inplace=_lowerCAmelCase			)
       def 			snake_case__    (							self					:     Union[str, Any]			,			_lowerCAmelCase					:     Tuple			,			*_lowerCAmelCase					:     List[str]			,			**_lowerCAmelCase					:     Optional[int]			):
           return DatasetChild(self.data			,			fingerprint=_lowerCAmelCase			)





       @fingerprint_transform(inplace=_lowerCAmelCase			)
       def 			snake_case__    (							self					:     Tuple			,			_lowerCAmelCase					:     Any			,			*_lowerCAmelCase					:     List[str]			,			**_lowerCAmelCase					:     Dict			):
           return DatasetChild(self.data			,			fingerprint=_lowerCAmelCase			)







class      SCREAMING_SNAKE_CASE__					:

       def __init__(							self					:     Tuple			,			_lowerCAmelCase					:     Union[str, Any]			):
           __snake_case       :				Optional[Any] 			=    callable

       def __call__(							self					:     str			,			*_lowerCAmelCase					:     str			,			**_lowerCAmelCase					:     Optional[int]			):
           if self.callable is not None:
               return self.callable(*_lowerCAmelCase			,			**_lowerCAmelCase			)





       def __getstate__(							self					:     Optional[int]			):
           raise pickle.PicklingError()







class      SCREAMING_SNAKE_CASE__					(  __UpperCamelCase    ):

       @require_transformers
       @pytest.mark.integration
       def 			snake_case__    (							self					:     Tuple			):
           from transformers import AutoTokenizer

           def encode(_lowerCAmelCase					:     Tuple			):
               return tokenizer(_lowerCAmelCase			)

           # TODO: add hash consistency tests across sessions
           __snake_case       :				Optional[Any] 			=    AutoTokenizer.from_pretrained("""bert-base-uncased"""			)
           __snake_case       :				Any 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(lambda _lowerCAmelCase			: tokenizer(_lowerCAmelCase			)			)			).hexdigest()
           __snake_case       :				Tuple 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				str 			=    AutoTokenizer.from_pretrained("""bert-base-cased"""			)
           __snake_case       :				Tuple 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Tuple 			=    mda(datasets.utils.py_utils.dumps(lambda _lowerCAmelCase			: tokenizer(_lowerCAmelCase			)			)			).hexdigest()
           __snake_case       :				Dict 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				List[str] 			=    AutoTokenizer.from_pretrained("""bert-base-uncased"""			)
           __snake_case       :				List[str] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(lambda _lowerCAmelCase			: tokenizer(_lowerCAmelCase			)			)			).hexdigest()
           __snake_case       :				int 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       @require_transformers
       @pytest.mark.integration
       def 			snake_case__    (							self					:     List[str]			):
           from transformers import AutoTokenizer

           __snake_case       :				str 			=    AutoTokenizer.from_pretrained("""gpt2"""			)
           __snake_case       :				str 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           tokenizer("""Hello world !"""			)  # call once to change the tokenizer's cache
           __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)





       @require_regex
       def 			snake_case__    (							self					:     Tuple			):
           import regex

           __snake_case       :				Union[str, Any] 			=    regex.Regex("""foo"""			)
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				List[str] 			=    regex.Regex("""bar"""			)
           __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Dict 			=    regex.Regex("""foo"""			)
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)







class      SCREAMING_SNAKE_CASE__					(  __UpperCamelCase    ):

       def 			snake_case__    (							self					:     int			):
           def func():
               return foo

           __snake_case       :				List[str] 			=    [0]
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Tuple 			=    [1]
           __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Optional[Any] 			=    [0]
           __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     Dict			):
           def func():
               pass

           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()

           def func():
               pass

           __snake_case       :				Dict 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     Union[str, Any]			):
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(Foo([1]			)			)			).hexdigest()
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     List[Any]			):
           __snake_case       :				Dict 			=    mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
           __snake_case       :				Tuple 			=    mda(datasets.utils.py_utils.dumps(Foo([1]			).__call__			)			).hexdigest()
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     List[Any]			):
           __snake_case       :				Tuple 			=    (
               """co_argcount""",
               """co_kwonlyargcount""",
               """co_nlocals""",
               """co_stacksize""",
               """co_flags""",
               """co_code""",
               """co_consts""",
               """co_names""",
               """co_varnames""",
               """co_filename""",
               """co_name""",
               """co_firstlineno""",
               """co_lnotab""",
               """co_freevars""",
               """co_cellvars""",
           )

           def _create_code_pyaa(*_lowerCAmelCase					:     Union[str, Any]			):
               if hasattr(args[-3]			,			"""encode"""			):
                   __snake_case       :				Optional[int] 			=    list(_lowerCAmelCase			)
                   __snake_case       :				Optional[int] 			=    args[-3].encode()  # co_lnotab
                   __snake_case       :				Any 			=    args[-10].encode()  # co_code
               if hasattr(_lowerCAmelCase			,			"""co_posonlyargcount"""			):
                   if len(_lowerCAmelCase			) == 16:
                       return CodeType(*_lowerCAmelCase			)
                   elif len(_lowerCAmelCase			) == 15:
                       return CodeType(args[0]			,			0			,			*args[1:]			)
                   return CodeType(args[0]			,			0			,			0			,			*args[1:]			)
               elif hasattr(_lowerCAmelCase			,			"""co_kwonlyargcount"""			):
                   if len(_lowerCAmelCase			) == 16:
                       return CodeType(args[0]			,			*args[2:]			)
                   elif len(_lowerCAmelCase			) == 15:
                       return CodeType(*_lowerCAmelCase			)
                   return CodeType(args[0]			,			0			,			*args[1:]			)
               if len(_lowerCAmelCase			) == 16:
                   return CodeType(args[0]			,			*args[3:]			)
               elif len(_lowerCAmelCase			) == 15:
                   return CodeType(args[0]			,			*args[2:]			)
               return CodeType(*_lowerCAmelCase			)

           def create_ipython_func(_lowerCAmelCase					:     List[Any]			,			_lowerCAmelCase					:     str			):
               def func():
                   return returned_obj

               __snake_case       :				Optional[int] 			=    func.__code__
               # Use _create_code from dill in order to make it work for different python versions
               if datasets.config.PY_VERSION < version.parse("""3.8"""			):
                   __snake_case       :				int 			=    _create_code_pyaa(
                       *[getattr(_lowerCAmelCase			,			_lowerCAmelCase			) if k != """co_filename""" else co_filename for k in code_args_pyaa]			)
               else:
                   __snake_case       :				Dict 			=    code.replace(co_filename=_lowerCAmelCase			)
               return FunctionType(_lowerCAmelCase			,			func.__globals__			,			func.__name__			,			func.__defaults__			,			func.__closure__			)

           __snake_case			, __snake_case       :				int 			=    """<ipython-input-2-e0383a102aae>""", [0]
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           __snake_case			, __snake_case       :				str 			=    """<ipython-input-2-e0383a102aae>""", [1]
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           __snake_case			, __snake_case       :				Optional[int] 			=    """<ipython-input-5-713f6613acf3>""", [0]
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

           __snake_case			, __snake_case       :				Dict 			=    os.path.join(gettempdir()			,			"""ipykernel_12345"""			,			"""321456789.py"""			), [0]
           __snake_case       :				Optional[int] 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           __snake_case			, __snake_case       :				Dict 			=    os.path.join(gettempdir()			,			"""ipykernel_12345"""			,			"""321456789.py"""			), [1]
           __snake_case       :				Dict 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           __snake_case			, __snake_case       :				Optional[Any] 			=    os.path.join(gettempdir()			,			"""ipykernel_12345"""			,			"""654123987.py"""			), [0]
           __snake_case       :				List[str] 			=    mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowerCAmelCase			,			_lowerCAmelCase			)			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)





       def 			snake_case__    (							self					:     Any			):
           __snake_case			, __snake_case       :				List[Any] 			=    [0], [1]

           def func():
               return foo, bar

           __snake_case       :				Any 			=    """__main__"""

           def globalvars_mocka_side_effect(_lowerCAmelCase					:     List[str]			,			*_lowerCAmelCase					:     Union[str, Any]			,			**_lowerCAmelCase					:     Optional[int]			):
               return {"foo": foo, "bar": bar}

           def globalvars_mocka_side_effect(_lowerCAmelCase					:     List[str]			,			*_lowerCAmelCase					:     Union[str, Any]			,			**_lowerCAmelCase					:     Dict			):
               return {"bar": bar, "foo": foo}

           with patch("""dill.detect.globalvars"""			,			side_effect=_lowerCAmelCase			) as globalvars_mocka:
               __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
               self.assertGreater(globalvars_mocka.call_count			,			0			)
           with patch("""dill.detect.globalvars"""			,			side_effect=_lowerCAmelCase			) as globalvars_mocka:
               __snake_case       :				str 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
               self.assertGreater(globalvars_mocka.call_count			,			0			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)







class      SCREAMING_SNAKE_CASE__					(  __UpperCamelCase    ):

       def 			snake_case__    (							self					:     int			):
           __snake_case       :				Dict 			=    Hasher.hash("""hello"""			)
           __snake_case       :				Tuple 			=    Hasher.hash("""hello"""			)
           __snake_case       :				Optional[Any] 			=    Hasher.hash("""there"""			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     int			):
           __snake_case       :				Optional[Any] 			=    Hasher.hash(Foo("""hello"""			)			)
           __snake_case       :				Union[str, Any] 			=    Hasher.hash(Foo("""hello"""			)			)
           __snake_case       :				Any 			=    Hasher.hash(Foo("""there"""			)			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     str			):
           __snake_case       :				Union[str, Any] 			=    Hasher()
           for x in ["hello", Foo("""hello"""			)]:
               hasher.update(_lowerCAmelCase			)
           __snake_case       :				int 			=    hasher.hexdigest()
           __snake_case       :				str 			=    Hasher()
           for x in ["hello", Foo("""hello"""			)]:
               hasher.update(_lowerCAmelCase			)
           __snake_case       :				Optional[Any] 			=    hasher.hexdigest()
           __snake_case       :				List[Any] 			=    Hasher()
           for x in ["there", Foo("""there"""			)]:
               hasher.update(_lowerCAmelCase			)
           __snake_case       :				Tuple 			=    hasher.hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       def 			snake_case__    (							self					:     List[Any]			):
           with self.assertRaises(pickle.PicklingError			):
               Hasher.hash(UnpicklableCallable(Foo("""hello"""			)			)			)

       def 			snake_case__    (							self					:     List[Any]			):
           __snake_case       :				Optional[int] 			=    """abc"""
           __snake_case       :				Union[str, Any] 			=    [string, string]  # two strings have the same ids
           __snake_case       :				List[str] 			=    [string, string]
           __snake_case       :				Tuple 			=    json.loads(f'''["{string}", "{string}"]'''			)  # two strings have different ids
           self.assertIs(obja[0]			,			_lowerCAmelCase			)
           self.assertIs(obja[0]			,			obja[1]			)
           self.assertIs(obja[0]			,			_lowerCAmelCase			)
           self.assertIs(obja[0]			,			obja[1]			)
           self.assertIsNot(obja[0]			,			_lowerCAmelCase			)
           self.assertIsNot(obja[0]			,			obja[1]			)
           __snake_case       :				Dict 			=    Hasher.hash(_lowerCAmelCase			)
           __snake_case       :				Dict 			=    Hasher.hash(_lowerCAmelCase			)
           __snake_case       :				Any 			=    Hasher.hash(_lowerCAmelCase			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       @require_tiktoken
       def 			snake_case__    (							self					:     Optional[Any]			):
           import tiktoken

           __snake_case       :				Optional[int] 			=    tiktoken.get_encoding("""gpt2"""			)
           __snake_case       :				Union[str, Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Optional[int] 			=    tiktoken.get_encoding("""r50k_base"""			)
           __snake_case       :				Any 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Union[str, Any] 			=    tiktoken.get_encoding("""gpt2"""			)
           __snake_case       :				Optional[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)

       @require_torch
       def 			snake_case__    (							self					:     Optional[Any]			):
           import torch

           __snake_case       :				int 			=    torch.tensor([1.0]			)
           __snake_case       :				List[str] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				List[Any] 			=    torch.tensor([2.0]			)
           __snake_case       :				int 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				List[str] 			=    torch.tensor([1.0]			)
           __snake_case       :				Tuple 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)





       @require_spacy
       @require_spacy_model("""en_core_web_sm"""			)
       @require_spacy_model("""fr_core_news_sm"""			)
       @pytest.mark.integration
       def 			snake_case__    (							self					:     List[Any]			):
           import spacy

           __snake_case       :				Dict 			=    spacy.load("""en_core_web_sm"""			)
           __snake_case       :				str 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				List[Any] 			=    spacy.load("""fr_core_news_sm"""			)
           __snake_case       :				List[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           __snake_case       :				Dict 			=    spacy.load("""en_core_web_sm"""			)
           __snake_case       :				Optional[Any] 			=    mda(datasets.utils.py_utils.dumps(_lowerCAmelCase			)			).hexdigest()
           self.assertEqual(_lowerCAmelCase			,			_lowerCAmelCase			)
           self.assertNotEqual(_lowerCAmelCase			,			_lowerCAmelCase			)







@pytest.mark.integration
def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					Path   ):







    '''simple docstring'''
    __snake_case       :				List[Any] 			=    tmp_path / """dir1"""
    __snake_case       :				Optional[Any] 			=    tmp_path / """dir2"""
    dira.mkdir()
    dira.mkdir()
    __snake_case       :				str 			=    """script.py"""
    __snake_case       :				Optional[int] 			=    dedent(
        """
    from datasets.fingerprint import Hasher
    def foo():
        pass
    print(Hasher.hash(foo))
    """   )
    __snake_case       :				List[str] 			=    dira / script_filename
    __snake_case       :				Any 			=    dira / script_filename
    with script_patha.open("""w"""   ) as f:
        f.write(__SCREAMING_SNAKE_CASE   )
    with script_patha.open("""w"""   ) as f:
        f.write(__SCREAMING_SNAKE_CASE   )
    __snake_case       :				Dict 			=    subprocess.check_output(["""python""", str(__SCREAMING_SNAKE_CASE   )]   )
    __snake_case       :				Any 			=    subprocess.check_output(["""python""", str(__SCREAMING_SNAKE_CASE   )]   )
    assert fingerprinta == fingerprinta







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    __snake_case       :				List[str] 			=    {"""a""": [0, 1, 2]}
    __snake_case       :				Dict 			=    DatasetChild(InMemoryTable.from_pydict(__SCREAMING_SNAKE_CASE   )   )
    __snake_case       :				Tuple 			=    dataset.funca()._fingerprint
    assert expected_fingerprint == dataset.funca()._fingerprint
    assert expected_fingerprint != dataset.funca()._fingerprint

    with Pool(2   ) as p:
        assert expected_fingerprint == p.apply_async(dataset.funca   ).get()._fingerprint
        assert expected_fingerprint != p.apply_async(dataset.funca   ).get()._fingerprint







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    __snake_case       :				List[Any] 			=    {"""a""": [0, 1, 2]}







    class      SCREAMING_SNAKE_CASE__					(  datasets.Dataset    ):

           @fingerprint_transform(inplace=_lowerCAmelCase			)
           def 			snake_case__    (							self					:     Union[str, Any]			,			_lowerCAmelCase					:     str			):
               return DummyDatasetChild(self.data			,			fingerprint=_lowerCAmelCase			)







    __snake_case       :				int 			=    DummyDatasetChild(InMemoryTable.from_pydict(__SCREAMING_SNAKE_CASE   )   ).func()







    class      SCREAMING_SNAKE_CASE__					(  datasets.Dataset    ):

           @fingerprint_transform(inplace=_lowerCAmelCase			,			version="""1.0.0"""			)
           def 			snake_case__    (							self					:     List[str]			,			_lowerCAmelCase					:     List[str]			):
               return DummyDatasetChild(self.data			,			fingerprint=_lowerCAmelCase			)







    __snake_case       :				int 			=    DummyDatasetChild(InMemoryTable.from_pydict(__SCREAMING_SNAKE_CASE   )   ).func()







    class      SCREAMING_SNAKE_CASE__					(  datasets.Dataset    ):

           @fingerprint_transform(inplace=_lowerCAmelCase			,			version="""2.0.0"""			)
           def 			snake_case__    (							self					:     List[Any]			,			_lowerCAmelCase					:     Tuple			):
               return DummyDatasetChild(self.data			,			fingerprint=_lowerCAmelCase			)







    __snake_case       :				str 			=    DummyDatasetChild(InMemoryTable.from_pydict(__SCREAMING_SNAKE_CASE   )   ).func()

    assert len({fingeprint_no_version, fingeprint_a, fingeprint_a}   ) == 3







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    # AttributeError: module 'dill._dill' has no attribute 'stack'
    __snake_case       :				Union[str, Any] 			=    Hasher()
    hasher.update(lambda __SCREAMING_SNAKE_CASE   : x   )




import math
from timeit import timeit







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    __snake_case       :				Optional[Any] 			=    0
    __snake_case       :				Union[str, Any] 			=    abs(__SCREAMING_SNAKE_CASE   )
    while True:
        __snake_case       :				List[str] 			=    n // 1_0
        digits += 1
        if n == 0:
            break
    return digits







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return 1 if n == 0 else math.floor(math.log(abs(__SCREAMING_SNAKE_CASE   )		,							1_0   ) + 1   )







def 					__lowerCAmelCase				(		__SCREAMING_SNAKE_CASE       :					int   ):







    '''simple docstring'''
    return len(str(abs(__SCREAMING_SNAKE_CASE   )   )   )







def 					__lowerCAmelCase				(		):







    '''simple docstring'''
    from collections.abc import Callable

    def benchmark_a_function(__SCREAMING_SNAKE_CASE       :					Callable		,							__SCREAMING_SNAKE_CASE       :					int   ) -> None:
        __snake_case       :				Tuple 			=    F'''{func.__name__}({value})'''
        __snake_case       :				Union[str, Any] 			=    timeit(F'''__main__.{call}'''		,							setup="""import __main__"""   )
        print(F'''{call}: {func(__SCREAMING_SNAKE_CASE   )} -- {timing} seconds'''   )

    for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
        for func in (num_digits, num_digits_fast, num_digits_faster):
            benchmark_a_function(__SCREAMING_SNAKE_CASE		,							__SCREAMING_SNAKE_CASE   )
        print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()



