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



   def __init__(    self					,      lowerCAmelCase__     )				->     int:
        """simple docstring"""





        _UpperCamelCase  :Optional[Any]       =foo




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





        return self.foo




class    lowerCamelCase__  (   datasets.Dataset     ):



   @fingerprint_transform(inplace=__UpperCAmelCase     )
   def  _UpperCamelCase		(    self					,      lowerCAmelCase__					,      *lowerCAmelCase__					,      **lowerCAmelCase__     )				->     Optional[int]:
        """simple docstring"""





        return DatasetChild(self.data					,      fingerprint=__UpperCAmelCase     )




   @fingerprint_transform(inplace=__UpperCAmelCase     )
   def  _UpperCamelCase		(    self					,      lowerCAmelCase__					,      *lowerCAmelCase__					,      **lowerCAmelCase__     )				->     Optional[int]:
        """simple docstring"""





        return DatasetChild(self.data					,      fingerprint=__UpperCAmelCase     )




class    lowerCamelCase__  :



   def __init__(    self					,      lowerCAmelCase__     )				->     int:
        """simple docstring"""





        _UpperCamelCase  :Any       =callable



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





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




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





        raise pickle.PicklingError()




class    lowerCamelCase__  (   SCREAMING_SNAKE_CASE_     ):



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





        from transformers import AutoTokenizer

        def encode(lowerCAmelCase__     ):
             return tokenizer(__UpperCAmelCase     )

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





        from transformers import AutoTokenizer

        _UpperCamelCase  :int       =AutoTokenizer.from_pretrained("""gpt2"""     )
        _UpperCamelCase  :Dict       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        tokenizer("""Hello world !"""     )  # call once to change the tokenizer's cache
        _UpperCamelCase  :Tuple       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        self.assertEqual(__UpperCAmelCase					,      __UpperCAmelCase     )




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





        import regex

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




class    lowerCamelCase__  (   SCREAMING_SNAKE_CASE_     ):



   def  _UpperCamelCase		(    self     )				->     int:
        """simple docstring"""





        def func():
             return foo

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



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





        def func():
             pass

        _UpperCamelCase  :int       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()

        def func():
             pass

        _UpperCamelCase  :Any       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        self.assertEqual(__UpperCAmelCase					,      __UpperCAmelCase     )



   def  _UpperCamelCase		(    self     )				->     str:
        """simple docstring"""





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



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





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



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





        _UpperCamelCase  :Optional[Any]       =(
            """co_argcount""",
            """co_kwonlyargcount""",
            """co_nlocals""",
            """co_stacksize""",
            """co_flags""",
            """co_code""",
            """co_consts""",
            """co_names""",
            """co_varnames""",
            """co_filename""",
            """co_name""",
            """co_firstlineno""",
            """co_lnotab""",
            """co_freevars""",
            """co_cellvars""",
        )

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

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

        _UpperCamelCase       ,      _UpperCamelCase  :Dict       ="""<ipython-input-2-e0383a102aae>""", [0]
        _UpperCamelCase  :Optional[int]       =mda(datasets.utils.py_utils.dumps(create_ipython_func(__UpperCAmelCase					,      __UpperCAmelCase     )     )     ).hexdigest()
        _UpperCamelCase       ,      _UpperCamelCase  :Optional[Any]       ="""<ipython-input-2-e0383a102aae>""", [1]
        _UpperCamelCase  :Tuple       =mda(datasets.utils.py_utils.dumps(create_ipython_func(__UpperCAmelCase					,      __UpperCAmelCase     )     )     ).hexdigest()
        _UpperCamelCase       ,      _UpperCamelCase  :Union[str, 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[Any]       =os.path.join(gettempdir()					,      """ipykernel_12345"""					,      """321456789.py"""     ), [0]
        _UpperCamelCase  :List[str]       =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  :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  _UpperCamelCase		(    self     )				->     List[str]:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :int       =[0], [1]

        def func():
             return foo, bar

        _UpperCamelCase  :int       ="""__main__"""

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

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

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




class    lowerCamelCase__  (   SCREAMING_SNAKE_CASE_     ):



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





        _UpperCamelCase  :str       =Hasher.hash("""hello"""     )
        _UpperCamelCase  :List[str]       =Hasher.hash("""hello"""     )
        _UpperCamelCase  :str       =Hasher.hash("""there"""     )
        self.assertEqual(__UpperCAmelCase					,      __UpperCAmelCase     )
        self.assertNotEqual(__UpperCAmelCase					,      __UpperCAmelCase     )



   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        _UpperCamelCase  :Optional[Any]       =Hasher.hash(Foo("""hello"""     )     )
        _UpperCamelCase  :int       =Hasher.hash(Foo("""hello"""     )     )
        _UpperCamelCase  :Dict       =Hasher.hash(Foo("""there"""     )     )
        self.assertEqual(__UpperCAmelCase					,      __UpperCAmelCase     )
        self.assertNotEqual(__UpperCAmelCase					,      __UpperCAmelCase     )



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





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



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





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



   def  _UpperCamelCase		(    self     )				->     int:
        """simple docstring"""





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



   @require_tiktoken
   def  _UpperCamelCase		(    self     )				->     int:
        """simple docstring"""





        import tiktoken

        _UpperCamelCase  :List[str]       =tiktoken.get_encoding("""gpt2"""     )
        _UpperCamelCase  :Union[str, Any]       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        _UpperCamelCase  :int       =tiktoken.get_encoding("""r50k_base"""     )
        _UpperCamelCase  :List[str]       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        _UpperCamelCase  :Union[str, 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  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        import torch

        _UpperCamelCase  :Tuple       =torch.tensor([1.0]     )
        _UpperCamelCase  :Tuple       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        _UpperCamelCase  :str       =torch.tensor([2.0]     )
        _UpperCamelCase  :List[str]       =mda(datasets.utils.py_utils.dumps(__UpperCAmelCase     )     ).hexdigest()
        _UpperCamelCase  :Any       =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  _UpperCamelCase		(    self     )				->     Optional[int]:
        """simple docstring"""





        import spacy

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




@pytest.mark.integration
def  _lowerCAmelCase				(				__a      )  ->      Any:
     '''simple docstring'''







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



def  _lowerCAmelCase				(				)  ->      Union[str, Any]:
     '''simple docstring'''







     _UpperCamelCase  :Optional[int]       ={"""a""": [0, 1, 2]}
     _UpperCamelCase  :int       =DatasetChild(InMemoryTable.from_pydict(__a      )      )
     _UpperCamelCase  :Tuple       =dataset.funca()._fingerprint
     assert expected_fingerprint == dataset.funca()._fingerprint
     assert expected_fingerprint != dataset.funca()._fingerprint

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



def  _lowerCAmelCase				(				)  ->      Any:
     '''simple docstring'''







     _UpperCamelCase  :Union[str, Any]       ={"""a""": [0, 1, 2]}




     class    lowerCamelCase__  (   datasets.Dataset     ):



        @fingerprint_transform(inplace=__UpperCAmelCase     )
        def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     List[Any]:
             """simple docstring"""





             return DummyDatasetChild(self.data					,      fingerprint=__UpperCAmelCase     )




     _UpperCamelCase  :Dict       =DummyDatasetChild(InMemoryTable.from_pydict(__a      )      ).func()




     class    lowerCamelCase__  (   datasets.Dataset     ):



        @fingerprint_transform(inplace=__UpperCAmelCase					,      version="""1.0.0"""     )
        def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     Any:
             """simple docstring"""





             return DummyDatasetChild(self.data					,      fingerprint=__UpperCAmelCase     )




     _UpperCamelCase  :List[str]       =DummyDatasetChild(InMemoryTable.from_pydict(__a      )      ).func()




     class    lowerCamelCase__  (   datasets.Dataset     ):



        @fingerprint_transform(inplace=__UpperCAmelCase					,      version="""2.0.0"""     )
        def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     int:
             """simple docstring"""





             return DummyDatasetChild(self.data					,      fingerprint=__UpperCAmelCase     )




     _UpperCamelCase  :Dict       =DummyDatasetChild(InMemoryTable.from_pydict(__a      )      ).func()

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



def  _lowerCAmelCase				(				)  ->      Any:
     '''simple docstring'''







     _UpperCamelCase  :str       =Hasher()
     hasher.update(lambda __a      : x      )

"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
    is_vision_available,
)


UpperCamelCase_						   =   {
    'configuration_mobilevitv2': [
        'MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'MobileViTV2Config',
        'MobileViTV2OnnxConfig',
    ],
}


try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase_						   =   [
          'MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST',
          'MobileViTV2ForImageClassification',
          'MobileViTV2ForSemanticSegmentation',
          'MobileViTV2Model',
          'MobileViTV2PreTrainedModel',
      ]

if TYPE_CHECKING:
      from .configuration_mobilevitva import (
          MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
          MobileViTVaConfig,
          MobileViTVaOnnxConfig,
      )

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_mobilevitva import (
                MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
                MobileViTVaForImageClassification,
                MobileViTVaForSemanticSegmentation,
                MobileViTVaModel,
                MobileViTVaPreTrainedModel,
            )

else:
      import sys

      UpperCamelCase_						   =   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)