'''simple docstring'''




import os
import sys
import unittest


_lowercase		:				List[str]	       =		os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
_lowercase		:				Any	       =		os.path.join(git_repo_path, "src", "transformers")

_lowercase		:				Tuple	       =		"\n{0} = None\n"

_lowercase		:				Optional[Any]	       =		"\nclass {0}(metaclass=DummyObject):\n    _backends = {1}\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, {1})\n"


_lowercase		:				Any	       =		"\ndef {0}(*args, **kwargs):\n    requires_backends({0}, {1})\n"





class 					__magic_name__		(					unittest.TestCase):







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Union[str, Any]					):
										lowercase_      :    Union[str, Any]       		= find_backend("""    _import_structure[\"models.albert\"].append(\"AlbertTokenizerFast\")"""					)
										self.assertIsNone(lowercase_					)

										lowercase_      :    Optional[int]       		= find_backend("""    if not is_tokenizers_available():"""					)
										self.assertEqual(lowercase_       ,    """tokenizers"""					)

										lowercase_      :    Optional[Any]       		= find_backend("""    if not is_tensorflow_text_available():"""					)
										self.assertEqual(lowercase_       ,    """tensorflow_text"""					)

										lowercase_      :    str       		= find_backend("""    if not (is_sentencepiece_available() and is_tokenizers_available()):"""					)
										self.assertEqual(lowercase_       ,    """sentencepiece_and_tokenizers"""					)

										lowercase_      :    str       		= find_backend(
										    """    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"""					)
										self.assertEqual(lowercase_       ,    """sentencepiece_and_tensorflow_text"""					)

										lowercase_      :    Union[str, Any]       		= find_backend(
										    """    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):"""					)
										self.assertEqual(lowercase_       ,    """sentencepiece_and_tokenizers_and_vision"""					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						List[Any]					):
										lowercase_      :    Union[str, Any]       		= read_init()
										# We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
										self.assertIn("""torch"""       ,    lowercase_					)
										self.assertIn("""tensorflow_text"""       ,    lowercase_					)
										self.assertIn("""sentencepiece_and_tokenizers"""       ,    lowercase_					)

										# Likewise, we can't assert on the exact content of a key
										self.assertIn("""BertModel"""       ,    objects["""torch"""]					)
										self.assertIn("""TFBertModel"""       ,    objects["""tf"""]					)
										self.assertIn("""FlaxBertModel"""       ,    objects["""flax"""]					)
										self.assertIn("""BertModel"""       ,    objects["""torch"""]					)
										self.assertIn("""TFBertTokenizer"""       ,    objects["""tensorflow_text"""]					)
										self.assertIn("""convert_slow_tokenizer"""       ,    objects["""sentencepiece_and_tokenizers"""]					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Tuple					):
										lowercase_      :    Any       		= create_dummy_object("""CONSTANT"""       ,    """'torch'"""					)
										self.assertEqual(lowercase_       ,    """\nCONSTANT = None\n"""					)

										lowercase_      :    Optional[Any]       		= create_dummy_object("""function"""       ,    """'torch'"""					)
										self.assertEqual(
										    lowercase_       ,    """\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"""					)

										lowercase_      :    Tuple       		= """
class FakeClass(metaclass=DummyObject):
    _backends = 'torch'

    def __init__(self, *args, **kwargs):
        requires_backends(self, 'torch')
"""
										lowercase_      :    str       		= create_dummy_object("""FakeClass"""       ,    """'torch'"""					)
										self.assertEqual(lowercase_       ,    lowercase_					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Union[str, Any]					):
										lowercase_      :    Tuple       		= """# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, [\"torch\"])


class FakeClass(metaclass=DummyObject):
    _backends = [\"torch\"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, [\"torch\"])
"""
										lowercase_      :    Optional[int]       		= create_dummy_files({"""torch""": ["""CONSTANT""", """function""", """FakeClass"""]}					)
										self.assertEqual(dummy_files["""torch"""]       ,    lowercase_					)






'''simple docstring'''




from typing import TYPE_CHECKING

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


_lowercase		:				List[Any]	       =		{"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]}


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_lowercase		:				int	       =		[
						    "FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "FocalNetForImageClassification",
						    "FocalNetForMaskedImageModeling",
						    "FocalNetBackbone",
						    "FocalNetModel",
						    "FocalNetPreTrainedModel",
						]

if TYPE_CHECKING:
						from .configuration_focalnet import FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FocalNetConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_focalnet import (
												    FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST,
												    FocalNetBackbone,
												    FocalNetForImageClassification,
												    FocalNetForMaskedImageModeling,
												    FocalNetModel,
												    FocalNetPreTrainedModel,
												)

else:
						import sys

						_lowercase		:				Union[str, Any]	       =		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





