




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






      def __init__(self ,  a__					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				Any       						= foo






      def __call__(self					)       ->   List[str]:
         return self.foo






class 						lowercase     (   datasets.Dataset):






      @fingerprint_transform(inplace=a__					)
      def    A__(self ,  a__ ,  *a__ ,  **a__					)       ->   int:
         return DatasetChild(self.data ,  fingerprint=a__					)






      @fingerprint_transform(inplace=a__					)
      def    A__(self ,  a__ ,  *a__ ,  **a__					)       ->   List[Any]:
         return DatasetChild(self.data ,  fingerprint=a__					)






class 						lowercase     :






      def __init__(self ,  a__					)       ->   Dict:
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= callable






      def __call__(self ,  *a__ ,  **a__					)       ->   Any:
         if self.callable is not None:
            return self.callable(*a__ ,  **a__					)






      def __getstate__(self					)       ->   Dict:
         raise pickle.PicklingError()






class 						lowercase     (   UpperCAmelCase_):






      @require_transformers
      @pytest.mark.integration
      def    A__(self					)       ->   List[str]:
         from transformers import AutoTokenizer

         def encode(a__					):
            return tokenizer(a__					)

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






      @require_transformers
      @pytest.mark.integration
      def    A__(self					)       ->   Optional[Any]:
         from transformers import AutoTokenizer

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






      @require_regex
      def    A__(self					)       ->   int:
         import regex

         SCREAMING_SNAKE_CASE__			:				Tuple       						= regex.Regex('''foo'''					)
         SCREAMING_SNAKE_CASE__			:				str       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				List[str]       						= regex.Regex('''bar'''					)
         SCREAMING_SNAKE_CASE__			:				int       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= regex.Regex('''foo'''					)
         SCREAMING_SNAKE_CASE__			:				Dict       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






class 						lowercase     (   UpperCAmelCase_):






      def    A__(self					)       ->   Union[str, Any]:
         def func():
            return foo

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






      def    A__(self					)       ->   Tuple:
         def func():
            pass

         SCREAMING_SNAKE_CASE__			:				Tuple       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()

         def func():
            pass

         SCREAMING_SNAKE_CASE__			:				str       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
         self.assertEqual(a__ ,  a__					)






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				Any       						= mda(datasets.utils.py_utils.dumps(Foo([0]					)					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= mda(datasets.utils.py_utils.dumps(Foo([1]					)					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				Any       						= mda(datasets.utils.py_utils.dumps(Foo([0]					)					)					).hexdigest()
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= mda(datasets.utils.py_utils.dumps(Foo([0]					).__call__					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= mda(datasets.utils.py_utils.dumps(Foo([1]					).__call__					)					).hexdigest()
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= mda(datasets.utils.py_utils.dumps(Foo([0]					).__call__					)					).hexdigest()
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				Dict       						= (
             '''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(*a__					):
            if hasattr(args[-3] ,  '''encode'''					):
               SCREAMING_SNAKE_CASE__			:				Tuple       						= list(a__					)
               SCREAMING_SNAKE_CASE__			:				Tuple       						= args[-3].encode()  # co_lnotab
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= args[-1_0].encode()  # co_code
            if hasattr(a__ ,  '''co_posonlyargcount'''					):
               if len(a__					) == 1_6:
                  return CodeType(*a__					)
               elif len(a__					) == 1_5:
                  return CodeType(args[0] ,  0 ,  *args[1:]					)
               return CodeType(args[0] ,  0 ,  0 ,  *args[1:]					)
            elif hasattr(a__ ,  '''co_kwonlyargcount'''					):
               if len(a__					) == 1_6:
                  return CodeType(args[0] ,  *args[2:]					)
               elif len(a__					) == 1_5:
                  return CodeType(*a__					)
               return CodeType(args[0] ,  0 ,  *args[1:]					)
            if len(a__					) == 1_6:
               return CodeType(args[0] ,  *args[3:]					)
            elif len(a__					) == 1_5:
               return CodeType(args[0] ,  *args[2:]					)
            return CodeType(*a__					)

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

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

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

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






      def    A__(self					)       ->   Tuple:
         SCREAMING_SNAKE_CASE__						,				SCREAMING_SNAKE_CASE__			:				List[str]       						= [0], [1]

         def func():
            return foo, bar

         SCREAMING_SNAKE_CASE__			:				Dict       						= '''__main__'''

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

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

         with patch('''dill.detect.globalvars''' ,  side_effect=a__					) as globalvars_mocka:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
            self.assertGreater(globalvars_mocka.call_count ,  0					)
         with patch('''dill.detect.globalvars''' ,  side_effect=a__					) as globalvars_mocka:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= mda(datasets.utils.py_utils.dumps(a__					)					).hexdigest()
            self.assertGreater(globalvars_mocka.call_count ,  0					)
         self.assertEqual(a__ ,  a__					)






class 						lowercase     (   UpperCAmelCase_):






      def    A__(self					)       ->   Optional[int]:
         SCREAMING_SNAKE_CASE__			:				int       						= Hasher.hash('''hello'''					)
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= Hasher.hash('''hello'''					)
         SCREAMING_SNAKE_CASE__			:				List[str]       						= Hasher.hash('''there'''					)
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				Dict       						= Hasher.hash(Foo('''hello'''					)					)
         SCREAMING_SNAKE_CASE__			:				List[str]       						= Hasher.hash(Foo('''hello'''					)					)
         SCREAMING_SNAKE_CASE__			:				int       						= Hasher.hash(Foo('''there'''					)					)
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






      def    A__(self					)       ->   Optional[Any]:
         SCREAMING_SNAKE_CASE__			:				Any       						= Hasher()
         for x in ["hello", Foo('''hello'''					)]:
            hasher.update(a__					)
         SCREAMING_SNAKE_CASE__			:				Dict       						= hasher.hexdigest()
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= Hasher()
         for x in ["hello", Foo('''hello'''					)]:
            hasher.update(a__					)
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= hasher.hexdigest()
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= Hasher()
         for x in ["there", Foo('''there'''					)]:
            hasher.update(a__					)
         SCREAMING_SNAKE_CASE__			:				Any       						= hasher.hexdigest()
         self.assertEqual(a__ ,  a__					)
         self.assertNotEqual(a__ ,  a__					)






      def    A__(self					)       ->   List[Any]:
         with self.assertRaises(pickle.PicklingError					):
            Hasher.hash(UnpicklableCallable(Foo('''hello'''					)					)					)






      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				int       						= '''abc'''
         SCREAMING_SNAKE_CASE__			:				str       						= [string, string]  # two strings have the same ids
         SCREAMING_SNAKE_CASE__			:				List[str]       						= [string, string]
         SCREAMING_SNAKE_CASE__			:				Dict       						= json.loads(f"""[\"{string}\", \"{string}\"]"""					)  # two strings have different ids
         self.assertIs(obja[0] ,  a__					)
         self.assertIs(obja[0] ,  obja[1]					)
         self.assertIs(obja[0] ,  a__					)
         self.assertIs(obja[0] ,  obja[1]					)
         self.assertIsNot(obja[0] ,  a__					)
         self.assertIsNot(obja[0] ,  obja[1]					)
         SCREAMING_SNAKE_CASE__			:				str       						= Hasher.hash(a__					)
         SCREAMING_SNAKE_CASE__			:				Tuple       						= Hasher.hash(a__					)
         SCREAMING_SNAKE_CASE__			:				int       						= Hasher.hash(a__					)
         self.assertEqual(a__ ,  a__					)
         self.assertEqual(a__ ,  a__					)






      @require_tiktoken
      def    A__(self					)       ->   Optional[int]:
         import tiktoken

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






      @require_torch
      def    A__(self					)       ->   Dict:
         import torch

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






      @require_spacy
      @require_spacy_model('''en_core_web_sm'''					)
      @require_spacy_model('''fr_core_news_sm'''					)
      @pytest.mark.integration
      def    A__(self					)       ->   Dict:
         import spacy

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


@pytest.mark.integration
def 				UpperCamelCase	(  snake_case   ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__			:				List[str]       						= tmp_path / '''dir1'''
   SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= tmp_path / '''dir2'''
   dira.mkdir()
   dira.mkdir()
   SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= '''script.py'''
   SCREAMING_SNAKE_CASE__			:				List[Any]       						= dedent(
       '''
    from datasets.fingerprint import Hasher
    def foo():
        pass
    print(Hasher.hash(foo))
    '''   )
   SCREAMING_SNAKE_CASE__			:				List[str]       						= dira / script_filename
   SCREAMING_SNAKE_CASE__			:				Optional[int]       						= 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   )
   SCREAMING_SNAKE_CASE__			:				Dict       						= subprocess.check_output(['''python''', str(snake_case   )]   )
   SCREAMING_SNAKE_CASE__			:				List[str]       						= subprocess.check_output(['''python''', str(snake_case   )]   )
   assert fingerprinta == fingerprinta


def 				UpperCamelCase	(  ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__			:				List[str]       						= {'''a''': [0, 1, 2]}
   SCREAMING_SNAKE_CASE__			:				str       						= DatasetChild(InMemoryTable.from_pydict(snake_case   )   )
   SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= dataset.funca()._fingerprint
   assert expected_fingerprint == dataset.funca()._fingerprint
   assert expected_fingerprint != dataset.funca()._fingerprint

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


def 				UpperCamelCase	(  ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__			:				Dict       						= {'''a''': [0, 1, 2]}






   class 						lowercase     (   datasets.Dataset):






         @fingerprint_transform(inplace=a__					)
         def    A__(self ,  a__					)       ->   List[str]:
            return DummyDatasetChild(self.data ,  fingerprint=a__					)

   SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= DummyDatasetChild(InMemoryTable.from_pydict(snake_case   )   ).func()






   class 						lowercase     (   datasets.Dataset):






         @fingerprint_transform(inplace=a__ ,  version='''1.0.0'''					)
         def    A__(self ,  a__					)       ->   int:
            return DummyDatasetChild(self.data ,  fingerprint=a__					)

   SCREAMING_SNAKE_CASE__			:				Optional[int]       						= DummyDatasetChild(InMemoryTable.from_pydict(snake_case   )   ).func()






   class 						lowercase     (   datasets.Dataset):






         @fingerprint_transform(inplace=a__ ,  version='''2.0.0'''					)
         def    A__(self ,  a__					)       ->   Tuple:
            return DummyDatasetChild(self.data ,  fingerprint=a__					)

   SCREAMING_SNAKE_CASE__			:				int       						= DummyDatasetChild(InMemoryTable.from_pydict(snake_case   )   ).func()

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







def 				UpperCamelCase	(  ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= Hasher()
   hasher.update(lambda snake_case   : x   )







'''simple docstring'''





# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


lowercase__			=	{
    '''configuration_convnextv2''': [
        '''CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ConvNextV2Config''',
    ]
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowercase__			=	[
           '''CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''ConvNextV2ForImageClassification''',
           '''ConvNextV2Model''',
           '''ConvNextV2PreTrainedModel''',
           '''ConvNextV2Backbone''',
       ]


if TYPE_CHECKING:
       from .configuration_convnextva import (
           CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
           ConvNextVaConfig,
       )

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_convnextva import (
                  CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST,
                  ConvNextVaBackbone,
                  ConvNextVaForImageClassification,
                  ConvNextVaModel,
                  ConvNextVaPreTrainedModel,
              )

else:
       import sys

       lowercase__			=	_LazyModule(__name__, globals()['''__file__'''], _import_structure)

