




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        __SCREAMING_SNAKE_CASE (	lowercase_   )							->						Optional[int]:

    """simple docstring"""


    if is_torch_available():
        import torch

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

    return isinstance(lowercase_       ,  np.ndarray   )


class 			_lowerCamelCase    (      A_ ):

      """simple docstring"""

      def    snake_case						(  self       :			str					):
          __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]			,							*snake_case       :			Optional[Any]			,							**snake_case       :			List[str]					):
          raise Exception(F"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."					)







      def    snake_case						(  self       :			Tuple			,							*snake_case       :			Dict			,							**snake_case       :			Optional[Any]					):
          raise Exception(F"You cannot use ``setdefault`` on a {self.__class__.__name__} instance."					)







      def    snake_case						(  self       :			Any			,							*snake_case       :			Any			,							**snake_case       :			Union[str, Any]					):
          raise Exception(F"You cannot use ``pop`` on a {self.__class__.__name__} instance."					)







      def    snake_case						(  self       :			int			,							*snake_case       :			Tuple			,							**snake_case       :			Optional[int]					):
          raise Exception(F"You cannot use ``update`` on a {self.__class__.__name__} instance."					)







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







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







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







          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			,							snake_case       :			List[Any]			,							snake_case       :			Optional[int]					):
          super().__setitem__(__lowercase			,							__lowercase					)
          # Don't call self.__setattr__ to avoid recursion errors
          super().__setattr__(__lowercase			,							__lowercase					)







      def    snake_case						(  self       :			Dict					):
          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__)


