





from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available




def  A_(      A ):
	if is_torch_available():
		import torch

		if isinstance(A					,   torch.Tensor ):
			return True

	return isinstance(A					,   np.ndarray )







class 	_UpperCamelCase	(							A_	):







					'''simple docstring'''

					def 							SCREAMING_SNAKE_CASE				(    self     :	str		):






						'''simple docstring'''







						UpperCAmelCase_		    =  fields(self		)

						# Safety and consistency checks
						if not len(__lowercase		):
							raise ValueError(F"""{self.__class__.__name__} has no fields."""		)

						UpperCAmelCase_		    =  getattr(self			,       class_fields[0].name		)
						UpperCAmelCase_		    =  all(getattr(self			,       field.name		) is None for field in class_fields[1:]		)

						if other_fields_are_none and isinstance(__lowercase			,       __lowercase		):
							for key, value in first_field.items():
								UpperCAmelCase_		    =  value
						else:
							for field in class_fields:
								UpperCAmelCase_		    =  getattr(self			,       field.name		)
								if v is not None:
									UpperCAmelCase_		    =  v





					def __delitem__(    self     :	Optional[int]			,       *__lowercase     :	Optional[Any]			,       **__lowercase     :	List[str]		):






						'''simple docstring'''







						raise Exception(F"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""		)





					def 							SCREAMING_SNAKE_CASE				(    self     :	Tuple			,       *__lowercase     :	Dict			,       **__lowercase     :	Optional[Any]		):






						'''simple docstring'''







						raise Exception(F"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""		)





					def 							SCREAMING_SNAKE_CASE				(    self     :	Any			,       *__lowercase     :	Any			,       **__lowercase     :	Union[str, Any]		):






						'''simple docstring'''







						raise Exception(F"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""		)





					def 							SCREAMING_SNAKE_CASE				(    self     :	int			,       *__lowercase     :	Tuple			,       **__lowercase     :	Optional[int]		):






						'''simple docstring'''







						raise Exception(F"""You cannot use ``update`` on a {self.__class__.__name__} instance."""		)





					def __getitem__(    self     :	Any			,       __lowercase     :	Tuple		):






						'''simple docstring'''







						if isinstance(__lowercase			,       __lowercase		):
							UpperCAmelCase_		    =  dict(self.items()		)
							return inner_dict[k]
						else:
							return self.to_tuple()[k]





					def __setattr__(    self     :	int			,       __lowercase     :	str			,       __lowercase     :	Dict		):






						'''simple docstring'''







						if name in self.keys() and value is not None:
							# Don't call self.__setitem__ to avoid recursion errors
							super().__setitem__(__lowercase			,       __lowercase		)
						super().__setattr__(__lowercase			,       __lowercase		)





					def __setitem__(    self     :	Any			,       __lowercase     :	List[Any]			,       __lowercase     :	Optional[int]		):






						'''simple docstring'''







						super().__setitem__(__lowercase			,       __lowercase		)
						# Don't call self.__setattr__ to avoid recursion errors
						super().__setattr__(__lowercase			,       __lowercase		)





					def 							SCREAMING_SNAKE_CASE				(    self     :	Dict		):






						'''simple docstring'''







						return tuple(self[k] for k in self.keys()		)









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


UpperCamelCase__ :			Any       	=			{
    """configuration_splinter""": ["""SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SplinterConfig"""],
    """tokenization_splinter""": ["""SplinterTokenizer"""],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCamelCase__ :			Any       	=			["""SplinterTokenizerFast"""]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCamelCase__ :			Union[str, Any]       	=			[
				    """SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """SplinterForQuestionAnswering""",
				    """SplinterForPreTraining""",
				    """SplinterLayer""",
				    """SplinterModel""",
				    """SplinterPreTrainedModel""",
				]


if TYPE_CHECKING:
				from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
				from .tokenization_splinter import SplinterTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_splinter_fast import SplinterTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_splinter import (
								    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
								    SplinterForPreTraining,
								    SplinterForQuestionAnswering,
								    SplinterLayer,
								    SplinterModel,
								    SplinterPreTrainedModel,
								)


else:
				import sys

				UpperCamelCase__ :			List[str]       	=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


