



'''simple docstring'''
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 _A  :





		def __init__(     self ,       __UpperCAmelCase				)       ->     Any:

					'''simple docstring'''
					__UpperCAmelCase   :      Union[str, Any]										=     foo





		def __call__(     self				)       ->     Any:

					'''simple docstring'''
					return self.foo



class _A  (    datasets.Dataset    ):





		@fingerprint_transform(inplace=__UpperCAmelCase				)
		def 							__A       (     self ,       __UpperCAmelCase ,       *__UpperCAmelCase ,       **__UpperCAmelCase				)       ->     str:

					'''simple docstring'''
					return DatasetChild(self.data ,       fingerprint=__UpperCAmelCase				)





		@fingerprint_transform(inplace=__UpperCAmelCase				)
		def 							__A       (     self ,       __UpperCAmelCase ,       *__UpperCAmelCase ,       **__UpperCAmelCase				)       ->     Optional[Any]:

					'''simple docstring'''
					return DatasetChild(self.data ,       fingerprint=__UpperCAmelCase				)



class _A  :





		def __init__(     self ,       __UpperCAmelCase				)       ->     Dict:

					'''simple docstring'''
					__UpperCAmelCase   :      int										=     callable





		def __call__(     self ,       *__UpperCAmelCase ,       **__UpperCAmelCase				)       ->     int:

					'''simple docstring'''
					if self.callable is not None:
								return self.callable(*__UpperCAmelCase ,       **__UpperCAmelCase				)





		def __getstate__(     self				)       ->     List[Any]:

					'''simple docstring'''
					raise pickle.PicklingError()



class _A  (    __SCREAMING_SNAKE_CASE    ):





		@require_transformers
		@pytest.mark.integration
		def 							__A       (     self				)       ->     str:

					'''simple docstring'''
					from transformers import AutoTokenizer

					def encode(__UpperCAmelCase				):
								return tokenizer(__UpperCAmelCase				)

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





		@require_transformers
		@pytest.mark.integration
		def 							__A       (     self				)       ->     List[Any]:

					'''simple docstring'''
					from transformers import AutoTokenizer

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





		@require_regex
		def 							__A       (     self				)       ->     int:

					'''simple docstring'''
					import regex

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



class _A  (    __SCREAMING_SNAKE_CASE    ):





		def 							__A       (     self				)       ->     List[Any]:

					'''simple docstring'''
					def func():
								return foo

					__UpperCAmelCase   :      List[Any]										=     [0]
					__UpperCAmelCase   :      Any										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					__UpperCAmelCase   :      str										=     [1]
					__UpperCAmelCase   :      List[str]										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					__UpperCAmelCase   :      Optional[int]										=     [0]
					__UpperCAmelCase   :      List[Any]										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     Optional[Any]:

					'''simple docstring'''
					def func():
								pass

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

					def func():
								pass

					__UpperCAmelCase   :      Optional[int]										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     List[Any]:

					'''simple docstring'''
					__UpperCAmelCase   :      Any										=     mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
					__UpperCAmelCase   :      List[Any]										=     mda(datasets.utils.py_utils.dumps(Foo([1]				)				)				).hexdigest()
					__UpperCAmelCase   :      Union[str, Any]										=     mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     Union[str, Any]:

					'''simple docstring'''
					__UpperCAmelCase   :      Any										=     mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
					__UpperCAmelCase   :      Dict										=     mda(datasets.utils.py_utils.dumps(Foo([1]				).__call__				)				).hexdigest()
					__UpperCAmelCase   :      Dict										=     mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     List[str]:

					'''simple docstring'''
					__UpperCAmelCase   :      str										=     (
					    """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(*__UpperCAmelCase				):
								if hasattr(args[-3] ,       """encode"""				):
											__UpperCAmelCase   :      Optional[int]										=     list(__UpperCAmelCase				)
											__UpperCAmelCase   :      int										=     args[-3].encode()  # co_lnotab
											__UpperCAmelCase   :      List[Any]										=     args[-10].encode()  # co_code
								if hasattr(__UpperCAmelCase ,       """co_posonlyargcount"""				):
											if len(__UpperCAmelCase				) == 16:
														return CodeType(*__UpperCAmelCase				)
											elif len(__UpperCAmelCase				) == 15:
														return CodeType(args[0] ,       0 ,       *args[1:]				)
											return CodeType(args[0] ,       0 ,       0 ,       *args[1:]				)
								elif hasattr(__UpperCAmelCase ,       """co_kwonlyargcount"""				):
											if len(__UpperCAmelCase				) == 16:
														return CodeType(args[0] ,       *args[2:]				)
											elif len(__UpperCAmelCase				) == 15:
														return CodeType(*__UpperCAmelCase				)
											return CodeType(args[0] ,       0 ,       *args[1:]				)
								if len(__UpperCAmelCase				) == 16:
											return CodeType(args[0] ,       *args[3:]				)
								elif len(__UpperCAmelCase				) == 15:
											return CodeType(args[0] ,       *args[2:]				)
								return CodeType(*__UpperCAmelCase				)

					def create_ipython_func(__UpperCAmelCase ,       __UpperCAmelCase				):
								def func():
											return returned_obj

								__UpperCAmelCase   :      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"""				):
											__UpperCAmelCase   :      Any										=     _create_code_pyaa(
											    *[getattr(__UpperCAmelCase ,       __UpperCAmelCase				) if k != """co_filename""" else co_filename for k in code_args_pyaa]				)
								else:
											__UpperCAmelCase   :      Dict										=     code.replace(co_filename=__UpperCAmelCase				)
								return FunctionType(__UpperCAmelCase ,       func.__globals__ ,       func.__name__ ,       func.__defaults__ ,       func.__closure__				)

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

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





		def 							__A       (     self				)       ->     int:

					'''simple docstring'''
					__UpperCAmelCase				,  __UpperCAmelCase   :      int										=     [0], [1]

					def func():
								return foo, bar

					__UpperCAmelCase   :      Tuple										=     """__main__"""

					def globalvars_mocka_side_effect(__UpperCAmelCase ,       *__UpperCAmelCase ,       **__UpperCAmelCase				):
								return {"foo": foo, "bar": bar}

					def globalvars_mocka_side_effect(__UpperCAmelCase ,       *__UpperCAmelCase ,       **__UpperCAmelCase				):
								return {"bar": bar, "foo": foo}

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



class _A  (    __SCREAMING_SNAKE_CASE    ):





		def 							__A       (     self				)       ->     str:

					'''simple docstring'''
					__UpperCAmelCase   :      int										=     Hasher.hash("""hello"""				)
					__UpperCAmelCase   :      Tuple										=     Hasher.hash("""hello"""				)
					__UpperCAmelCase   :      Optional[int]										=     Hasher.hash("""there"""				)
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     Optional[int]:

					'''simple docstring'''
					__UpperCAmelCase   :      Dict										=     Hasher.hash(Foo("""hello"""				)				)
					__UpperCAmelCase   :      Any										=     Hasher.hash(Foo("""hello"""				)				)
					__UpperCAmelCase   :      Tuple										=     Hasher.hash(Foo("""there"""				)				)
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     Dict:

					'''simple docstring'''
					__UpperCAmelCase   :      List[Any]										=     Hasher()
					for x in ["hello", Foo("""hello"""				)]:
								hasher.update(__UpperCAmelCase				)
					__UpperCAmelCase   :      List[str]										=     hasher.hexdigest()
					__UpperCAmelCase   :      Union[str, Any]										=     Hasher()
					for x in ["hello", Foo("""hello"""				)]:
								hasher.update(__UpperCAmelCase				)
					__UpperCAmelCase   :      Optional[int]										=     hasher.hexdigest()
					__UpperCAmelCase   :      List[Any]										=     Hasher()
					for x in ["there", Foo("""there"""				)]:
								hasher.update(__UpperCAmelCase				)
					__UpperCAmelCase   :      List[Any]										=     hasher.hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)





		def 							__A       (     self				)       ->     Dict:

					'''simple docstring'''
					with self.assertRaises(pickle.PicklingError				):
								Hasher.hash(UnpicklableCallable(Foo("""hello"""				)				)				)





		def 							__A       (     self				)       ->     List[Any]:

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





		@require_tiktoken
		def 							__A       (     self				)       ->     Optional[Any]:

					'''simple docstring'''
					import tiktoken

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





		@require_torch
		def 							__A       (     self				)       ->     Any:

					'''simple docstring'''
					import torch

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





		@require_spacy
		@require_spacy_model("""en_core_web_sm"""				)
		@require_spacy_model("""fr_core_news_sm"""				)
		@pytest.mark.integration
		def 							__A       (     self				)       ->     List[str]:

					'''simple docstring'''
					import spacy

					__UpperCAmelCase   :      Optional[Any]										=     spacy.load("""en_core_web_sm"""				)
					__UpperCAmelCase   :      str										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					__UpperCAmelCase   :      Tuple										=     spacy.load("""fr_core_news_sm"""				)
					__UpperCAmelCase   :      Tuple										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					__UpperCAmelCase   :      Optional[int]										=     spacy.load("""en_core_web_sm"""				)
					__UpperCAmelCase   :      Any										=     mda(datasets.utils.py_utils.dumps(__UpperCAmelCase				)				).hexdigest()
					self.assertEqual(__UpperCAmelCase ,       __UpperCAmelCase				)
					self.assertNotEqual(__UpperCAmelCase ,       __UpperCAmelCase				)


@pytest.mark.integration
def   lowercase_	(   lowerCAmelCase__	:  Path ):

			"""simple docstring"""





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


def   lowercase_	(   ):

			"""simple docstring"""





			__UpperCAmelCase   :      Any										=     {"""a""": [0, 1, 2]}
			__UpperCAmelCase   :      Dict										=     DatasetChild(InMemoryTable.from_pydict(lowerCAmelCase__ ) )
			__UpperCAmelCase   :      Union[str, Any]										=     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   lowercase_	(   ):

			"""simple docstring"""





			__UpperCAmelCase   :      str										=     {"""a""": [0, 1, 2]}



			class _A  (    datasets.Dataset    ):





					@fingerprint_transform(inplace=__UpperCAmelCase				)
					def 							__A       (     self ,       __UpperCAmelCase				)       ->     Tuple:

								'''simple docstring'''
								return DummyDatasetChild(self.data ,       fingerprint=__UpperCAmelCase				)


			__UpperCAmelCase   :      Any										=     DummyDatasetChild(InMemoryTable.from_pydict(lowerCAmelCase__ ) ).func()



			class _A  (    datasets.Dataset    ):





					@fingerprint_transform(inplace=__UpperCAmelCase ,       version="""1.0.0"""				)
					def 							__A       (     self ,       __UpperCAmelCase				)       ->     List[str]:

								'''simple docstring'''
								return DummyDatasetChild(self.data ,       fingerprint=__UpperCAmelCase				)


			__UpperCAmelCase   :      int										=     DummyDatasetChild(InMemoryTable.from_pydict(lowerCAmelCase__ ) ).func()



			class _A  (    datasets.Dataset    ):





					@fingerprint_transform(inplace=__UpperCAmelCase ,       version="""2.0.0"""				)
					def 							__A       (     self ,       __UpperCAmelCase				)       ->     Any:

								'''simple docstring'''
								return DummyDatasetChild(self.data ,       fingerprint=__UpperCAmelCase				)


			__UpperCAmelCase   :      Dict										=     DummyDatasetChild(InMemoryTable.from_pydict(lowerCAmelCase__ ) ).func()

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






def   lowercase_	(   ):

			"""simple docstring"""





			__UpperCAmelCase   :      Dict										=     Hasher()
			hasher.update(lambda lowerCAmelCase__ : x )









'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_UpperCamelCase											=			logging.get_logger(__name__)

_UpperCamelCase											=			{
    '''nghuyong/ernie-1.0-base-zh''': '''https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json''',
    '''nghuyong/ernie-2.0-base-en''': '''https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json''',
    '''nghuyong/ernie-2.0-large-en''': '''https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-base-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-medium-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-mini-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-micro-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json''',
    '''nghuyong/ernie-3.0-nano-zh''': '''https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json''',
    '''nghuyong/ernie-gram-zh''': '''https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json''',
    '''nghuyong/ernie-health-zh''': '''https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json''',
}



class _A  (    __SCREAMING_SNAKE_CASE    ):
		_SCREAMING_SNAKE_CASE					:    Optional[int]						      =			"ernie"





		def __init__(     self ,       __UpperCAmelCase=30_522 ,       __UpperCAmelCase=768 ,       __UpperCAmelCase=12 ,       __UpperCAmelCase=12 ,       __UpperCAmelCase=3_072 ,       __UpperCAmelCase="gelu" ,       __UpperCAmelCase=0.1 ,       __UpperCAmelCase=0.1 ,       __UpperCAmelCase=512 ,       __UpperCAmelCase=2 ,       __UpperCAmelCase=3 ,       __UpperCAmelCase=False ,       __UpperCAmelCase=0.02 ,       __UpperCAmelCase=1E-12 ,       __UpperCAmelCase=0 ,       __UpperCAmelCase="absolute" ,       __UpperCAmelCase=True ,       __UpperCAmelCase=None ,       **__UpperCAmelCase ,       )       ->     List[Any]:

					'''simple docstring'''
					super().__init__(pad_token_id=__UpperCAmelCase ,       **__UpperCAmelCase				)

					__UpperCAmelCase   :      List[str]										=     vocab_size
					__UpperCAmelCase   :      Optional[int]										=     hidden_size
					__UpperCAmelCase   :      Optional[Any]										=     num_hidden_layers
					__UpperCAmelCase   :      int										=     num_attention_heads
					__UpperCAmelCase   :      int										=     hidden_act
					__UpperCAmelCase   :      List[Any]										=     intermediate_size
					__UpperCAmelCase   :      Optional[Any]										=     hidden_dropout_prob
					__UpperCAmelCase   :      Dict										=     attention_probs_dropout_prob
					__UpperCAmelCase   :      int										=     max_position_embeddings
					__UpperCAmelCase   :      str										=     type_vocab_size
					__UpperCAmelCase   :      int										=     task_type_vocab_size
					__UpperCAmelCase   :      List[str]										=     use_task_id
					__UpperCAmelCase   :      Union[str, Any]										=     initializer_range
					__UpperCAmelCase   :      Tuple										=     layer_norm_eps
					__UpperCAmelCase   :      List[str]										=     position_embedding_type
					__UpperCAmelCase   :      Union[str, Any]										=     use_cache
					__UpperCAmelCase   :      Optional[int]										=     classifier_dropout



class _A  (    __SCREAMING_SNAKE_CASE    ):





		@property
		def 							__A       (     self				)       ->     Mapping[str, Mapping[int, str]]:

					'''simple docstring'''
					if self.task == "multiple-choice":
								__UpperCAmelCase   :      Union[str, Any]										=     {0: """batch""", 1: """choice""", 2: """sequence"""}
					else:
								__UpperCAmelCase   :      Tuple										=     {0: """batch""", 1: """sequence"""}
					return OrderedDict(
					    [
					        ("""input_ids""", dynamic_axis),
					        ("""attention_mask""", dynamic_axis),
					        ("""token_type_ids""", dynamic_axis),
					        ("""task_type_ids""", dynamic_axis),
					    ]				)




