code: 
  
  
  '''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 						__lowerCAmelCase		:
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        def __init__(self					:					Any     ,		UpperCamelCase					:					Dict				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				foo
  
  
  
  
  
  
        def __call__(self					:					Union[str, Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               return self.foo
  
  
  
  
  
  
  class 						__lowerCAmelCase		(datasets.Dataset  ):
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        @fingerprint_transform(inplace=UpperCamelCase				)
        def    UpperCamelCase__	(self					:					Union[str, Any]     ,		UpperCamelCase					:					str     ,		*UpperCamelCase					:					Tuple     ,		**UpperCamelCase					:					Optional[Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               return DatasetChild(self.data     ,		fingerprint=UpperCamelCase				)
  
  
  
  
  
  
        @fingerprint_transform(inplace=UpperCamelCase				)
        def    UpperCamelCase__	(self					:					Union[str, Any]     ,		UpperCamelCase					:					Optional[int]     ,		*UpperCamelCase					:					int     ,		**UpperCamelCase					:					List[str]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               return DatasetChild(self.data     ,		fingerprint=UpperCamelCase				)
  
  
  
  
  
  
  class 						__lowerCAmelCase		:
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        def __init__(self					:					List[str]     ,		UpperCamelCase					:					str				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				callable
  
  
  
        def __call__(self					:					Tuple     ,		*UpperCamelCase					:					Union[str, Any]     ,		**UpperCamelCase					:					Union[str, Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               if self.callable is not None:
                      return self.callable(*UpperCamelCase     ,		**UpperCamelCase				)
  
  
  
  
  
  
        def __getstate__(self					:					List[Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               raise pickle.PicklingError()
  
  
  
  
  
  
  class 						__lowerCAmelCase		(lowercase_  ):
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        @require_transformers
        @pytest.mark.integration
        def    UpperCamelCase__	(self					:					int				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               from transformers import AutoTokenizer
  
               def encode(UpperCamelCase					:					Union[str, Any]				):
                      return tokenizer(UpperCamelCase				)
  
               # TODO: add hash consistency tests across sessions
               lowercase__       =				AutoTokenizer.from_pretrained('''bert-base-uncased'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(lambda UpperCamelCase				: tokenizer(UpperCamelCase				)				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				AutoTokenizer.from_pretrained('''bert-base-cased'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(lambda UpperCamelCase				: tokenizer(UpperCamelCase				)				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				AutoTokenizer.from_pretrained('''bert-base-uncased'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(lambda UpperCamelCase				: tokenizer(UpperCamelCase				)				)				).hexdigest()
               lowercase__       =				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    UpperCamelCase__	(self					:					Optional[Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               from transformers import AutoTokenizer
  
               lowercase__       =				AutoTokenizer.from_pretrained('''gpt2'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               tokenizer('''Hello world !'''				)  # call once to change the tokenizer's cache
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
  
  
  
        @require_regex
        def    UpperCamelCase__	(self					:					str				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               import regex
  
               lowercase__       =				regex.Regex('''foo'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				regex.Regex('''bar'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				regex.Regex('''foo'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
  
  
  
  class 						__lowerCAmelCase		(lowercase_  ):
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        def    UpperCamelCase__	(self					:					List[str]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               def func():
                      return foo
  
               lowercase__       =				[0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				[1]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				[0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					Optional[int]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               def func():
                      pass
  
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
  
               def func():
                      pass
  
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					str				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([1]				)				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([0]				)				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					Dict				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([1]				).__call__				)				).hexdigest()
               lowercase__       =				mda(datasets.utils.py_utils.dumps(Foo([0]				).__call__				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					Optional[int]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				(
                   '''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					:					Any				):
                      if hasattr(args[-3]     ,		'''encode'''				):
                             lowercase__       =				list(UpperCamelCase				)
                             lowercase__       =				args[-3].encode()  # co_lnotab
                             lowercase__       =				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					:					Any     ,		UpperCamelCase					:					List[Any]				):
                      def func():
                             return returned_obj
  
                      lowercase__       =				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'''				):
                             lowercase__       =				_create_code_pyaa(
                                 *[getattr(UpperCamelCase     ,		UpperCamelCase				) if k != '''co_filename''' else co_filename for k in code_args_pyaa]				)
                      else:
                             lowercase__       =				code.replace(co_filename=UpperCamelCase				)
                      return FunctionType(UpperCamelCase     ,		func.__globals__     ,		func.__name__     ,		func.__defaults__     ,		func.__closure__				)
  
               lowercase__    ,lowercase__       =				'''<ipython-input-2-e0383a102aae>''', [0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               lowercase__    ,lowercase__       =				'''<ipython-input-2-e0383a102aae>''', [1]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               lowercase__    ,lowercase__       =				'''<ipython-input-5-713f6613acf3>''', [0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
               lowercase__    ,lowercase__       =				os.path.join(gettempdir()     ,		'''ipykernel_12345'''     ,		'''321456789.py'''				), [0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               lowercase__    ,lowercase__       =				os.path.join(gettempdir()     ,		'''ipykernel_12345'''     ,		'''321456789.py'''				), [1]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               lowercase__    ,lowercase__       =				os.path.join(gettempdir()     ,		'''ipykernel_12345'''     ,		'''654123987.py'''				), [0]
               lowercase__       =				mda(datasets.utils.py_utils.dumps(create_ipython_func(UpperCamelCase     ,		UpperCamelCase				)				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
  
  
  
        def    UpperCamelCase__	(self					:					Tuple				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__    ,lowercase__       =				[0], [1]
  
               def func():
                      return foo, bar
  
               lowercase__       =				'''__main__'''
  
               def globalvars_mocka_side_effect(UpperCamelCase					:					List[str]     ,		*UpperCamelCase					:					List[str]     ,		**UpperCamelCase					:					List[str]				):
                      return {"foo": foo, "bar": bar}
  
               def globalvars_mocka_side_effect(UpperCamelCase					:					int     ,		*UpperCamelCase					:					List[str]     ,		**UpperCamelCase					:					Any				):
                      return {"bar": bar, "foo": foo}
  
               with patch('''dill.detect.globalvars'''     ,		side_effect=UpperCamelCase				) as globalvars_mocka:
                      lowercase__       =				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:
                      lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
                      self.assertGreater(globalvars_mocka.call_count     ,		0				)
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
  
  
  
  class 						__lowerCAmelCase		(lowercase_  ):
  
  
  
  
  
        '''simple docstring'''
  
  
  
  
  
  
        def    UpperCamelCase__	(self					:					Any				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				Hasher.hash('''hello'''				)
               lowercase__       =				Hasher.hash('''hello'''				)
               lowercase__       =				Hasher.hash('''there'''				)
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					int				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				Hasher.hash(Foo('''hello'''				)				)
               lowercase__       =				Hasher.hash(Foo('''hello'''				)				)
               lowercase__       =				Hasher.hash(Foo('''there'''				)				)
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					str				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				Hasher()
               for x in ["hello", Foo('''hello'''				)]:
                      hasher.update(UpperCamelCase				)
               lowercase__       =				hasher.hexdigest()
               lowercase__       =				Hasher()
               for x in ["hello", Foo('''hello'''				)]:
                      hasher.update(UpperCamelCase				)
               lowercase__       =				hasher.hexdigest()
               lowercase__       =				Hasher()
               for x in ["there", Foo('''there'''				)]:
                      hasher.update(UpperCamelCase				)
               lowercase__       =				hasher.hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        def    UpperCamelCase__	(self					:					str				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               with self.assertRaises(pickle.PicklingError				):
                      Hasher.hash(UnpicklableCallable(Foo('''hello'''				)				)				)
  
  
  
        def    UpperCamelCase__	(self					:					Optional[int]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               lowercase__       =				'''abc'''
               lowercase__       =				[string, string]  # two strings have the same ids
               lowercase__       =				[string, string]
               lowercase__       =				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]				)
               lowercase__       =				Hasher.hash(UpperCamelCase				)
               lowercase__       =				Hasher.hash(UpperCamelCase				)
               lowercase__       =				Hasher.hash(UpperCamelCase				)
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        @require_tiktoken
        def    UpperCamelCase__	(self					:					int				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               import tiktoken
  
               lowercase__       =				tiktoken.get_encoding('''gpt2'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				tiktoken.get_encoding('''r50k_base'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				tiktoken.get_encoding('''gpt2'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
        @require_torch
        def    UpperCamelCase__	(self					:					Union[str, Any]				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               import torch
  
               lowercase__       =				torch.tensor([1.0]				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				torch.tensor([2.0]				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				torch.tensor([1.0]				)
               lowercase__       =				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    UpperCamelCase__	(self					:					Any				):
  
               '''simple docstring'''
  
  
  
  
  
  
  
               import spacy
  
               lowercase__       =				spacy.load('''en_core_web_sm'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				spacy.load('''fr_core_news_sm'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               lowercase__       =				spacy.load('''en_core_web_sm'''				)
               lowercase__       =				mda(datasets.utils.py_utils.dumps(UpperCamelCase				)				).hexdigest()
               self.assertEqual(UpperCamelCase     ,		UpperCamelCase				)
               self.assertNotEqual(UpperCamelCase     ,		UpperCamelCase				)
  
  
  
  
  
  
  @pytest.mark.integration
  def _SCREAMING_SNAKE_CASE   (A ) -> List[Any]:
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         lowercase__       =				tmp_path / '''dir1'''
         lowercase__       =				tmp_path / '''dir2'''
         dira.mkdir()
         dira.mkdir()
         lowercase__       =				'''script.py'''
         lowercase__       =				dedent(
             '''
      from datasets.fingerprint import Hasher
      def foo():
          pass
      print(Hasher.hash(foo))
      ''' )
         lowercase__       =				dira / script_filename
         lowercase__       =				dira / script_filename
         with script_patha.open('''w''' ) as f:
                f.write(A )
         with script_patha.open('''w''' ) as f:
                f.write(A )
         lowercase__       =				subprocess.check_output(['''python''', str(A )] )
         lowercase__       =				subprocess.check_output(['''python''', str(A )] )
         assert fingerprinta == fingerprinta
  
  def _SCREAMING_SNAKE_CASE   () -> Tuple:
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         lowercase__       =				{'''a''': [0, 1, 2]}
         lowercase__       =				DatasetChild(InMemoryTable.from_pydict(A ) )
         lowercase__       =				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   () -> Dict:
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         lowercase__       =				{'''a''': [0, 1, 2]}
         class 						__lowerCAmelCase		(datasets.Dataset  ):
  
  
  
  
  
               '''simple docstring'''
  
  
  
  
  
  
               @fingerprint_transform(inplace=UpperCamelCase				)
               def    UpperCamelCase__	(self					:					Union[str, Any]     ,		UpperCamelCase					:					List[str]				):
  
                      '''simple docstring'''
  
  
  
  
  
  
  
                      return DummyDatasetChild(self.data     ,		fingerprint=UpperCamelCase				)
  
  
  
  
  
  
         lowercase__       =				DummyDatasetChild(InMemoryTable.from_pydict(A ) ).func()
         class 						__lowerCAmelCase		(datasets.Dataset  ):
  
  
  
  
  
               '''simple docstring'''
  
  
  
  
  
  
               @fingerprint_transform(inplace=UpperCamelCase     ,		version='''1.0.0'''				)
               def    UpperCamelCase__	(self					:					Optional[Any]     ,		UpperCamelCase					:					Any				):
  
                      '''simple docstring'''
  
  
  
  
  
  
  
                      return DummyDatasetChild(self.data     ,		fingerprint=UpperCamelCase				)
  
  
  
  
  
  
         lowercase__       =				DummyDatasetChild(InMemoryTable.from_pydict(A ) ).func()
         class 						__lowerCAmelCase		(datasets.Dataset  ):
  
  
  
  
  
               '''simple docstring'''
  
  
  
  
  
  
               @fingerprint_transform(inplace=UpperCamelCase     ,		version='''2.0.0'''				)
               def    UpperCamelCase__	(self					:					int     ,		UpperCamelCase					:					Union[str, Any]				):
  
                      '''simple docstring'''
  
  
  
  
  
  
  
                      return DummyDatasetChild(self.data     ,		fingerprint=UpperCamelCase				)
  
  
  
  
  
  
         lowercase__       =				DummyDatasetChild(InMemoryTable.from_pydict(A ) ).func()
  
         assert len({fingeprint_no_version, fingeprint_a, fingeprint_a} ) == 3
  
  def _SCREAMING_SNAKE_CASE   () -> List[Any]:
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         lowercase__       =				Hasher()
         hasher.update(lambda A : x )
  
  
  
  
  
style_context: 
  
  
  '''simple docstring'''
  
  import argparse
  
  import torch
  
  from transformers import ElectraConfig, ElectraForMaskedLM, ElectraForPreTraining, load_tf_weights_in_electra
  from transformers.utils import logging
  
  
  logging.set_verbosity_info()
  
  def _SCREAMING_SNAKE_CASE   (A						,				A						,				A						,				A ) -> Dict:
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         lowercase__       =				ElectraConfig.from_json_file(A )
         print(f"Building PyTorch model from configuration: {config}" )
  
         if discriminator_or_generator == "discriminator":
                lowercase__       =				ElectraForPreTraining(A )
         elif discriminator_or_generator == "generator":
                lowercase__       =				ElectraForMaskedLM(A )
         else:
                raise ValueError('''The discriminator_or_generator argument should be either \'discriminator\' or \'generator\'''' )
  
         # Load weights from tf checkpoint
         load_tf_weights_in_electra(
             A						,				A						,				A						,				discriminator_or_generator=A )
  
         # Save pytorch-model
         print(f"Save PyTorch model to {pytorch_dump_path}" )
         torch.save(model.state_dict()						,				A )
  
  
  if __name__ == "__main__":
   lowerCamelCase							:     Tuple								=			argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
   )
   parser.add_argument(
       '--config_file',
       default=None,
       type=str,
       required=True,
       help='The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.',
   )
   parser.add_argument(
       '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
   )
   parser.add_argument(
       '--discriminator_or_generator',
       default=None,
       type=str,
       required=True,
       help=(
           'Whether to export the generator or the discriminator. Should be a string, either \'discriminator\' or '
           '\'generator\'.'
       ),
   )
   lowerCamelCase							:     Optional[int]								=			parser.parse_args()
   convert_tf_checkpoint_to_pytorch(
       args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.discriminator_or_generator
   )
  
  
  
  
  