



'''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 			_SCREAMING_SNAKE_CASE				:



			def __init__(     self		:						int    ,			__UpperCamelCase		:						Optional[Any]			)      ->      Optional[int]:
							"""simple docstring"""





							snake_case__      :   Union[str, Any]      =    foo







			def __call__(     self		:						List[str]			)      ->      Optional[Any]:
							"""simple docstring"""





							return self.foo






class 			_SCREAMING_SNAKE_CASE				(datasets.Dataset      ):



			@fingerprint_transform(inplace=UpperCamelCase_			)
			def 				lowerCAmelCase (     self		:						Optional[Any]    ,			__UpperCamelCase		:						Optional[Any]    ,			*__UpperCamelCase		:						Any    ,			**__UpperCamelCase		:						List[str]			)      ->      Optional[Any]:
							"""simple docstring"""





							return DatasetChild(self.data    ,			fingerprint=UpperCamelCase_			)







			@fingerprint_transform(inplace=UpperCamelCase_			)
			def 				lowerCAmelCase (     self		:						List[str]    ,			__UpperCamelCase		:						Any    ,			*__UpperCamelCase		:						Any    ,			**__UpperCamelCase		:						Union[str, Any]			)      ->      List[Any]:
							"""simple docstring"""





							return DatasetChild(self.data    ,			fingerprint=UpperCamelCase_			)






class 			_SCREAMING_SNAKE_CASE				:



			def __init__(     self		:						Union[str, Any]    ,			__UpperCamelCase		:						Optional[int]			)      ->      Union[str, Any]:
							"""simple docstring"""





							snake_case__      :   Any      =    callable



			def __call__(     self		:						Union[str, Any]    ,			*__UpperCamelCase		:						List[str]    ,			**__UpperCamelCase		:						Union[str, Any]			)      ->      List[Any]:
							"""simple docstring"""





							if self.callable is not None:
											return self.callable(*UpperCamelCase_    ,			**UpperCamelCase_			)







			def __getstate__(     self		:						Dict			)      ->      Tuple:
							"""simple docstring"""





							raise pickle.PicklingError()






class 			_SCREAMING_SNAKE_CASE				(__A      ):



			@require_transformers
			@pytest.mark.integration
			def 				lowerCAmelCase (     self		:						Optional[int]			)      ->      Dict:
							"""simple docstring"""





							from transformers import AutoTokenizer

							def encode(__UpperCamelCase		:						int			):
											return tokenizer(UpperCamelCase_			)

							# TODO: add hash consistency tests across sessions
							snake_case__      :   Dict      =    AutoTokenizer.from_pretrained('''bert-base-uncased'''			)
							snake_case__      :   int      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   List[str]      =    mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase			: tokenizer(UpperCamelCase_			)			)			).hexdigest()
							snake_case__      :   Union[str, Any]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Optional[int]      =    AutoTokenizer.from_pretrained('''bert-base-cased'''			)
							snake_case__      :   List[str]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase			: tokenizer(UpperCamelCase_			)			)			).hexdigest()
							snake_case__      :   Tuple      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Tuple      =    AutoTokenizer.from_pretrained('''bert-base-uncased'''			)
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   int      =    mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase			: tokenizer(UpperCamelCase_			)			)			).hexdigest()
							snake_case__      :   Optional[Any]      =    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 				lowerCAmelCase (     self		:						Optional[int]			)      ->      int:
							"""simple docstring"""





							from transformers import AutoTokenizer

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







			@require_regex
			def 				lowerCAmelCase (     self		:						Dict			)      ->      List[str]:
							"""simple docstring"""





							import regex

							snake_case__      :   Tuple      =    regex.Regex('''foo'''			)
							snake_case__      :   List[str]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   List[Any]      =    regex.Regex('''bar'''			)
							snake_case__      :   List[str]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   List[Any]      =    regex.Regex('''foo'''			)
							snake_case__      :   str      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)






class 			_SCREAMING_SNAKE_CASE				(__A      ):



			def 				lowerCAmelCase (     self		:						Union[str, Any]			)      ->      Any:
							"""simple docstring"""





							def func():
											return foo

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



			def 				lowerCAmelCase (     self		:						Dict			)      ->      int:
							"""simple docstring"""





							def func():
											pass

							snake_case__      :   Dict      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()

							def func():
											pass

							snake_case__      :   Optional[Any]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			def 				lowerCAmelCase (     self		:						List[Any]			)      ->      Tuple:
							"""simple docstring"""





							snake_case__      :   Union[str, Any]      =    mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
							snake_case__      :   str      =    mda(datasets.utils.py_utils.dumps(Foo([1]			)			)			).hexdigest()
							snake_case__      :   Dict      =    mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			def 				lowerCAmelCase (     self		:						Tuple			)      ->      Any:
							"""simple docstring"""





							snake_case__      :   List[str]      =    mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(Foo([1]			).__call__			)			).hexdigest()
							snake_case__      :   int      =    mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			def 				lowerCAmelCase (     self		:						Tuple			)      ->      List[str]:
							"""simple docstring"""





							snake_case__      :   List[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		:						int			):
											if hasattr(args[-3]    ,			'''encode'''			):
															snake_case__      :   Union[str, Any]      =    list(UpperCamelCase_			)
															snake_case__      :   Tuple      =    args[-3].encode()  # co_lnotab
															snake_case__      :   Optional[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		:						Tuple    ,			__UpperCamelCase		:						Optional[Any]			):
											def func():
															return returned_obj

											snake_case__      :   Union[str, Any]      =    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__      :   List[Any]      =    _create_code_pyaa(
															    *[getattr(UpperCamelCase_    ,			UpperCamelCase_			) if k != '''co_filename''' else co_filename for k in code_args_pyaa]			)
											else:
															snake_case__      :   Union[str, Any]      =    code.replace(co_filename=UpperCamelCase_			)
											return FunctionType(UpperCamelCase_    ,			func.__globals__    ,			func.__name__    ,			func.__defaults__    ,			func.__closure__			)

							snake_case__      :   int      =    '''<ipython-input-2-e0383a102aae>''', [0]
							snake_case__      :   Any      =    mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase_    ,			UpperCamelCase_			)			)			).hexdigest()
							snake_case__      :   Any      =    '''<ipython-input-2-e0383a102aae>''', [1]
							snake_case__      :   Dict      =    mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase_    ,			UpperCamelCase_			)			)			).hexdigest()
							snake_case__      :   Optional[Any]      =    '''<ipython-input-5-713f6613acf3>''', [0]
							snake_case__      :   int      =    mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase_    ,			UpperCamelCase_			)			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)

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







			def 				lowerCAmelCase (     self		:						Optional[int]			)      ->      List[str]:
							"""simple docstring"""





							snake_case__      :   Optional[int]      =    [0], [1]

							def func():
											return foo, bar

							snake_case__      :   List[str]      =    '''__main__'''

							def globalvars_mocka_side_effect(__UpperCamelCase		:						str    ,			*__UpperCamelCase		:						Any    ,			**__UpperCamelCase		:						Any			):
											return {"foo": foo, "bar": bar}

							def globalvars_mocka_side_effect(__UpperCamelCase		:						Optional[int]    ,			*__UpperCamelCase		:						Optional[int]    ,			**__UpperCamelCase		:						Optional[int]			):
											return {"bar": bar, "foo": foo}

							with patch('''dill.detect.globalvars'''    ,			side_effect=UpperCamelCase_			) as globalvars_mocka:
											snake_case__      :   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:
											snake_case__      :   Optional[Any]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
											self.assertGreater(globalvars_mocka.call_count    ,			0			)
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)






class 			_SCREAMING_SNAKE_CASE				(__A      ):



			def 				lowerCAmelCase (     self		:						str			)      ->      List[str]:
							"""simple docstring"""





							snake_case__      :   str      =    Hasher.hash('''hello'''			)
							snake_case__      :   str      =    Hasher.hash('''hello'''			)
							snake_case__      :   str      =    Hasher.hash('''there'''			)
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			def 				lowerCAmelCase (     self		:						List[str]			)      ->      Any:
							"""simple docstring"""





							snake_case__      :   int      =    Hasher.hash(Foo('''hello'''			)			)
							snake_case__      :   Any      =    Hasher.hash(Foo('''hello'''			)			)
							snake_case__      :   List[str]      =    Hasher.hash(Foo('''there'''			)			)
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			def 				lowerCAmelCase (     self		:						int			)      ->      List[Any]:
							"""simple docstring"""





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



			def 				lowerCAmelCase (     self		:						Any			)      ->      Optional[int]:
							"""simple docstring"""





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



			def 				lowerCAmelCase (     self		:						List[str]			)      ->      int:
							"""simple docstring"""





							snake_case__      :   str      =    '''abc'''
							snake_case__      :   Tuple      =    [string, string]  # two strings have the same ids
							snake_case__      :   Any      =    [string, string]
							snake_case__      :   List[Any]      =    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]			)
							snake_case__      :   Tuple      =    Hasher.hash(UpperCamelCase_			)
							snake_case__      :   Union[str, Any]      =    Hasher.hash(UpperCamelCase_			)
							snake_case__      :   List[Any]      =    Hasher.hash(UpperCamelCase_			)
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			@require_tiktoken
			def 				lowerCAmelCase (     self		:						Optional[Any]			)      ->      Optional[int]:
							"""simple docstring"""





							import tiktoken

							snake_case__      :   Dict      =    tiktoken.get_encoding('''gpt2'''			)
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   List[str]      =    tiktoken.get_encoding('''r50k_base'''			)
							snake_case__      :   str      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Any      =    tiktoken.get_encoding('''gpt2'''			)
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



			@require_torch
			def 				lowerCAmelCase (     self		:						Union[str, Any]			)      ->      List[str]:
							"""simple docstring"""





							import torch

							snake_case__      :   str      =    torch.tensor([1.0]			)
							snake_case__      :   Any      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   str      =    torch.tensor([2.0]			)
							snake_case__      :   str      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Union[str, Any]      =    torch.tensor([1.0]			)
							snake_case__      :   Any      =    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 				lowerCAmelCase (     self		:						Tuple			)      ->      str:
							"""simple docstring"""





							import spacy

							snake_case__      :   Union[str, Any]      =    spacy.load('''en_core_web_sm'''			)
							snake_case__      :   Optional[int]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Any      =    spacy.load('''fr_core_news_sm'''			)
							snake_case__      :   List[Any]      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							snake_case__      :   Union[str, Any]      =    spacy.load('''en_core_web_sm'''			)
							snake_case__      :   str      =    mda(datasets.utils.py_utils.dumps(UpperCamelCase_			)			).hexdigest()
							self.assertEqual(UpperCamelCase_    ,			UpperCamelCase_			)
							self.assertNotEqual(UpperCamelCase_    ,			UpperCamelCase_			)



@pytest.mark.integration
def 							__UpperCAmelCase				(				UpperCamelCase__				:Path			)		->						List[str]:
				snake_case__      :   List[Any]      =    tmp_path / '''dir1'''
				snake_case__      :   List[str]      =    tmp_path / '''dir2'''
				dira.mkdir()
				dira.mkdir()
				snake_case__      :   Tuple      =    '''script.py'''
				snake_case__      :   List[Any]      =    dedent(
				    '''
    from datasets.fingerprint import Hasher
    def foo():
        pass
    print(Hasher.hash(foo))
    '''			)
				snake_case__      :   Union[str, Any]      =    dira / script_filename
				snake_case__      :   Tuple      =    dira / script_filename
				with script_patha.open('''w'''			) as f:
								f.write(snake_case_			)
				with script_patha.open('''w'''			) as f:
								f.write(snake_case_			)
				snake_case__      :   Union[str, Any]      =    subprocess.check_output(['''python''', str(snake_case_			)]			)
				snake_case__      :   Optional[Any]      =    subprocess.check_output(['''python''', str(snake_case_			)]			)
				assert fingerprinta == fingerprinta


def 							__UpperCAmelCase				(				)		->						Union[str, Any]:
				snake_case__      :   List[Any]      =    {'''a''': [0, 1, 2]}
				snake_case__      :   Dict      =    DatasetChild(InMemoryTable.from_pydict(snake_case_			)			)
				snake_case__      :   str      =    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 							__UpperCAmelCase				(				)		->						Dict:
				snake_case__      :   str      =    {'''a''': [0, 1, 2]}






				class 			_SCREAMING_SNAKE_CASE				(datasets.Dataset      ):



							@fingerprint_transform(inplace=UpperCamelCase_			)
							def 				lowerCAmelCase (     self		:						List[Any]    ,			__UpperCamelCase		:						Optional[int]			)      ->      int:
											"""simple docstring"""





											return DummyDatasetChild(self.data    ,			fingerprint=UpperCamelCase_			)



				snake_case__      :   Optional[Any]      =    DummyDatasetChild(InMemoryTable.from_pydict(snake_case_			)			).func()






				class 			_SCREAMING_SNAKE_CASE				(datasets.Dataset      ):



							@fingerprint_transform(inplace=UpperCamelCase_    ,			version='''1.0.0'''			)
							def 				lowerCAmelCase (     self		:						List[Any]    ,			__UpperCamelCase		:						Dict			)      ->      Union[str, Any]:
											"""simple docstring"""





											return DummyDatasetChild(self.data    ,			fingerprint=UpperCamelCase_			)



				snake_case__      :   Optional[int]      =    DummyDatasetChild(InMemoryTable.from_pydict(snake_case_			)			).func()






				class 			_SCREAMING_SNAKE_CASE				(datasets.Dataset      ):



							@fingerprint_transform(inplace=UpperCamelCase_    ,			version='''2.0.0'''			)
							def 				lowerCAmelCase (     self		:						Optional[int]    ,			__UpperCamelCase		:						Any			)      ->      int:
											"""simple docstring"""





											return DummyDatasetChild(self.data    ,			fingerprint=UpperCamelCase_			)



				snake_case__      :   Optional[Any]      =    DummyDatasetChild(InMemoryTable.from_pydict(snake_case_			)			).func()

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



def 							__UpperCAmelCase				(				)		->						Optional[Any]:
				snake_case__      :   int      =    Hasher()
				hasher.update(lambda UpperCamelCase__			: x			)









'''simple docstring'''






class 	_lowerCAmelCase     :






		'''simple docstring'''
		def __init__(						self							:       int      ,		UpperCamelCase_							:       int		)      ->			None:







									'''simple docstring'''





									_lowercase							:		Optional[Any]				=   data
									_lowercase							:		int
									_lowercase							:		Node





def 				_SCREAMING_SNAKE_CASE(					snake_case_    :     Node  )		->None:






							'''simple docstring'''
							_lowercase							:		str				=   0
							_lowercase							:		List[Any]				=   x





def 				_SCREAMING_SNAKE_CASE(					snake_case_    :     Node ,       snake_case_    :     Node  )		->None:






							'''simple docstring'''
							_lowercase			, _lowercase							:		Union[str, Any]				=   find_set(snake_case_  ), find_set(snake_case_  )
							if x == y:
														return

							elif x.rank > y.rank:
														_lowercase							:		Optional[Any]				=   x
							else:
														_lowercase							:		Optional[int]				=   y
														if x.rank == y.rank:
																					y.rank += 1





def 				_SCREAMING_SNAKE_CASE(					snake_case_    :     Node  )		->Node:






							'''simple docstring'''
							if x != x.parent:
														_lowercase							:		str				=   find_set(x.parent  )
							return x.parent





def 				_SCREAMING_SNAKE_CASE(					snake_case_    :     Node  )		->set:






							'''simple docstring'''
							_lowercase							:		str				=   ({0, 1, 2}, {3, 4, 5})
							for s in sets:
														if node.data in s:
																					return s
							_lowercase							:		Optional[Any]				=   F"{node.data} is not in {sets}"
							raise ValueError(snake_case_  )





def 				_SCREAMING_SNAKE_CASE(					)		->None:






							'''simple docstring'''
							_lowercase							:		Any				=   [Node(snake_case_  ) for i in range(6  )]
							for v in vertex:
														make_set(snake_case_  )

							union_set(vertex[0] ,       vertex[1]  )
							union_set(vertex[1] ,       vertex[2]  )
							union_set(vertex[3] ,       vertex[4]  )
							union_set(vertex[3] ,       vertex[5]  )

							for nodea in vertex:
														for nodea in vertex:
																					if find_python_set(snake_case_  ).isdisjoint(find_python_set(snake_case_  )  ):
																												assert find_set(snake_case_  ) != find_set(snake_case_  )
																					else:
																												assert find_set(snake_case_  ) == find_set(snake_case_  )


if __name__ == "__main__":
						test_disjoint_set()



