




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    __lowerCAmelCase			:







			def __init__(	self   :      int   ,   snake_case__   :      Tuple				):




									"""simple docstring"""


									_UpperCAmelCase													=					foo







			def __call__(	self   :      Tuple				):




									"""simple docstring"""


									return self.foo






class    __lowerCAmelCase			(	datasets.Dataset			):







			@fingerprint_transform(inplace=lowerCAmelCase__				)
			def UpperCamelCase      (	self   :      Tuple   ,   snake_case__   :      str   ,   *snake_case__   :      List[str]   ,   **snake_case__   :      str				):




									"""simple docstring"""


									return DatasetChild(self.data   ,   fingerprint=lowerCAmelCase__				)







			@fingerprint_transform(inplace=lowerCAmelCase__				)
			def UpperCamelCase      (	self   :      int   ,   snake_case__   :      Optional[Any]   ,   *snake_case__   :      Any   ,   **snake_case__   :      Dict				):




									"""simple docstring"""


									return DatasetChild(self.data   ,   fingerprint=lowerCAmelCase__				)






class    __lowerCAmelCase			:







			def __init__(	self   :      Any   ,   snake_case__   :      List[Any]				):




									"""simple docstring"""


									_UpperCAmelCase													=					callable







			def __call__(	self   :      str   ,   *snake_case__   :      List[str]   ,   **snake_case__   :      List[Any]				):




									"""simple docstring"""


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







			def __getstate__(	self   :      Union[str, Any]				):




									"""simple docstring"""


									raise pickle.PicklingError()






class    __lowerCAmelCase			(	lowercase__			):







			@require_transformers
			@pytest.mark.integration
			def UpperCamelCase      (	self   :      Any				):




									"""simple docstring"""


									from transformers import AutoTokenizer

									def encode(snake_case__   :      Optional[int]				):
															return tokenizer(lowerCAmelCase__				)

									# TODO: add hash consistency tests across sessions
									_UpperCAmelCase													=					AutoTokenizer.from_pretrained("bert-base-uncased"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lambda snake_case__				: tokenizer(lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					AutoTokenizer.from_pretrained("bert-base-cased"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lambda snake_case__				: tokenizer(lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					AutoTokenizer.from_pretrained("bert-base-uncased"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lambda snake_case__				: tokenizer(lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase													=					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 UpperCamelCase      (	self   :      Tuple				):




									"""simple docstring"""


									from transformers import AutoTokenizer

									_UpperCAmelCase													=					AutoTokenizer.from_pretrained("gpt2"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									tokenizer("Hello world !"				)  # call once to change the tokenizer's cache
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			@require_regex
			def UpperCamelCase      (	self   :      List[Any]				):




									"""simple docstring"""


									import regex

									_UpperCAmelCase													=					regex.Regex("foo"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					regex.Regex("bar"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					regex.Regex("foo"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)






class    __lowerCAmelCase			(	lowercase__			):







			def UpperCamelCase      (	self   :      Optional[Any]				):




									"""simple docstring"""


									def func():
															return foo

									_UpperCAmelCase													=					[0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					[1]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					[0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Tuple				):




									"""simple docstring"""


									def func():
															pass

									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()

									def func():
															pass

									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Union[str, Any]				):




									"""simple docstring"""


									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([1]				)				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Tuple				):




									"""simple docstring"""


									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([1]				).__call__				)				).hexdigest()
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Dict				):




									"""simple docstring"""


									_UpperCAmelCase													=					(
									    "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(*snake_case__   :      int				):
															if hasattr(args[-3]   ,   "encode"				):
																					_UpperCAmelCase													=					list(lowerCAmelCase__				)
																					_UpperCAmelCase													=					args[-3].encode()  # co_lnotab
																					_UpperCAmelCase													=					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(snake_case__   :      Tuple   ,   snake_case__   :      Union[str, Any]				):
															def func():
																					return returned_obj

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

									_UpperCAmelCase							,			_UpperCAmelCase													=					"<ipython-input-2-e0383a102aae>", [0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase							,			_UpperCAmelCase													=					"<ipython-input-2-e0383a102aae>", [1]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase							,			_UpperCAmelCase													=					"<ipython-input-5-713f6613acf3>", [0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)

									_UpperCAmelCase							,			_UpperCAmelCase													=					os.path.join(gettempdir()   ,   "ipykernel_12345"   ,   "321456789.py"				), [0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase							,			_UpperCAmelCase													=					os.path.join(gettempdir()   ,   "ipykernel_12345"   ,   "321456789.py"				), [1]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									_UpperCAmelCase							,			_UpperCAmelCase													=					os.path.join(gettempdir()   ,   "ipykernel_12345"   ,   "654123987.py"				), [0]
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(create_ipython_func(lowerCAmelCase__   ,   lowerCAmelCase__				)				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      str				):




									"""simple docstring"""


									_UpperCAmelCase							,			_UpperCAmelCase													=					[0], [1]

									def func():
															return foo, bar

									_UpperCAmelCase													=					"__main__"

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

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

									with patch("dill.detect.globalvars"   ,   side_effect=lowerCAmelCase__				) as globalvars_mocka:
															_UpperCAmelCase													=					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:
															_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
															self.assertGreater(globalvars_mocka.call_count   ,   0				)
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)






class    __lowerCAmelCase			(	lowercase__			):







			def UpperCamelCase      (	self   :      Dict				):




									"""simple docstring"""


									_UpperCAmelCase													=					Hasher.hash("hello"				)
									_UpperCAmelCase													=					Hasher.hash("hello"				)
									_UpperCAmelCase													=					Hasher.hash("there"				)
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Dict				):




									"""simple docstring"""


									_UpperCAmelCase													=					Hasher.hash(Foo("hello"				)				)
									_UpperCAmelCase													=					Hasher.hash(Foo("hello"				)				)
									_UpperCAmelCase													=					Hasher.hash(Foo("there"				)				)
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Optional[int]				):




									"""simple docstring"""


									_UpperCAmelCase													=					Hasher()
									for x in ["hello", Foo("hello"				)]:
															hasher.update(lowerCAmelCase__				)
									_UpperCAmelCase													=					hasher.hexdigest()
									_UpperCAmelCase													=					Hasher()
									for x in ["hello", Foo("hello"				)]:
															hasher.update(lowerCAmelCase__				)
									_UpperCAmelCase													=					hasher.hexdigest()
									_UpperCAmelCase													=					Hasher()
									for x in ["there", Foo("there"				)]:
															hasher.update(lowerCAmelCase__				)
									_UpperCAmelCase													=					hasher.hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			def UpperCamelCase      (	self   :      Any				):




									"""simple docstring"""


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







			def UpperCamelCase      (	self   :      Any				):




									"""simple docstring"""


									_UpperCAmelCase													=					"abc"
									_UpperCAmelCase													=					[string, string]  # two strings have the same ids
									_UpperCAmelCase													=					[string, string]
									_UpperCAmelCase													=					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]				)
									_UpperCAmelCase													=					Hasher.hash(lowerCAmelCase__				)
									_UpperCAmelCase													=					Hasher.hash(lowerCAmelCase__				)
									_UpperCAmelCase													=					Hasher.hash(lowerCAmelCase__				)
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			@require_tiktoken
			def UpperCamelCase      (	self   :      Any				):




									"""simple docstring"""


									import tiktoken

									_UpperCAmelCase													=					tiktoken.get_encoding("gpt2"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					tiktoken.get_encoding("r50k_base"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					tiktoken.get_encoding("gpt2"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)







			@require_torch
			def UpperCamelCase      (	self   :      Union[str, Any]				):




									"""simple docstring"""


									import torch

									_UpperCAmelCase													=					torch.tensor([1.0]				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					torch.tensor([2.0]				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					torch.tensor([1.0]				)
									_UpperCAmelCase													=					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 UpperCamelCase      (	self   :      Any				):




									"""simple docstring"""


									import spacy

									_UpperCAmelCase													=					spacy.load("en_core_web_sm"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					spacy.load("fr_core_news_sm"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									_UpperCAmelCase													=					spacy.load("en_core_web_sm"				)
									_UpperCAmelCase													=					mda(datasets.utils.py_utils.dumps(lowerCAmelCase__				)				).hexdigest()
									self.assertEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)
									self.assertNotEqual(lowerCAmelCase__   ,   lowerCAmelCase__				)




@pytest.mark.integration
def 							__SCREAMING_SNAKE_CASE  (      snake_case_						):

						'''simple docstring'''


						_UpperCAmelCase													=					tmp_path / "dir1"
						_UpperCAmelCase													=					tmp_path / "dir2"
						dira.mkdir()
						dira.mkdir()
						_UpperCAmelCase													=					"script.py"
						_UpperCAmelCase													=					dedent(
						    "\n    from datasets.fingerprint import Hasher\n    def foo():\n        pass\n    print(Hasher.hash(foo))\n    "						)
						_UpperCAmelCase													=					dira / script_filename
						_UpperCAmelCase													=					dira / script_filename
						with script_patha.open("w"						) as f:
												f.write(lowercase_						)
						with script_patha.open("w"						) as f:
												f.write(lowercase_						)
						_UpperCAmelCase													=					subprocess.check_output(["python", str(lowercase_						)]						)
						_UpperCAmelCase													=					subprocess.check_output(["python", str(lowercase_						)]						)
						assert fingerprinta == fingerprinta


def 							__SCREAMING_SNAKE_CASE  (      ):

						'''simple docstring'''


						_UpperCAmelCase													=					{"a": [0, 1, 2]}
						_UpperCAmelCase													=					DatasetChild(InMemoryTable.from_pydict(lowercase_						)						)
						_UpperCAmelCase													=					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 							__SCREAMING_SNAKE_CASE  (      ):

						'''simple docstring'''


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






						class    __lowerCAmelCase			(	datasets.Dataset			):







									@fingerprint_transform(inplace=lowerCAmelCase__				)
									def UpperCamelCase      (	self   :      Union[str, Any]   ,   snake_case__   :      List[str]				):




															"""simple docstring"""


															return DummyDatasetChild(self.data   ,   fingerprint=lowerCAmelCase__				)




						_UpperCAmelCase													=					DummyDatasetChild(InMemoryTable.from_pydict(lowercase_						)						).func()






						class    __lowerCAmelCase			(	datasets.Dataset			):







									@fingerprint_transform(inplace=lowerCAmelCase__   ,   version="1.0.0"				)
									def UpperCamelCase      (	self   :      Any   ,   snake_case__   :      str				):




															"""simple docstring"""


															return DummyDatasetChild(self.data   ,   fingerprint=lowerCAmelCase__				)




						_UpperCAmelCase													=					DummyDatasetChild(InMemoryTable.from_pydict(lowercase_						)						).func()






						class    __lowerCAmelCase			(	datasets.Dataset			):







									@fingerprint_transform(inplace=lowerCAmelCase__   ,   version="2.0.0"				)
									def UpperCamelCase      (	self   :      int   ,   snake_case__   :      Optional[Any]				):




															"""simple docstring"""


															return DummyDatasetChild(self.data   ,   fingerprint=lowerCAmelCase__				)




						_UpperCAmelCase													=					DummyDatasetChild(InMemoryTable.from_pydict(lowercase_						)						).func()

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





def 							__SCREAMING_SNAKE_CASE  (      ):

						'''simple docstring'''


						_UpperCAmelCase													=					Hasher()
						hasher.update(lambda snake_case_						: x						)










from __future__ import annotations

from collections.abc import Generator


def 							__SCREAMING_SNAKE_CASE  (      snake_case_						):

						'''simple docstring'''


						if not isinstance(snake_case_     ,   snake_case_						) or n < 1:
												raise Exception("Sequence only defined for positive integers"						)

						yield n
						while n != 1:
												if n % 2 == 0:
																		n //= 2
												else:
																		_UpperCAmelCase													=					3 * n + 1
												yield n


def 							__SCREAMING_SNAKE_CASE  (      ):

						'''simple docstring'''


						_UpperCAmelCase													=					43
						_UpperCAmelCase													=					tuple(collatz_sequence(snake_case_						)						)
						print(snake_case_						)
						print(f"""Collatz sequence from {n} took {len(snake_case_						)} steps."""						)


if __name__ == "__main__":
				main()




