






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_			(		lowercase_	)							->Optional[Any]:







 """simple docstring"""

 if is_torch_available():
  import torch

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

 return isinstance(lowercase_					,       np.ndarray	)
class 					a_(						lowercase__					):



     """simple docstring"""



     def   __UpperCamelCase		(						self			:					Tuple)    ->					List[Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE							  =						fields(self)

      # Safety and consistency checks
      if not len(lowerCAmelCase__):
       raise ValueError(f'''{self.__class__.__name__} has no fields.''')

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

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





     def __delitem__(						self			:					List[Any]       ,       *lowerCAmelCase__			:					Union[str, Any]       ,       **lowerCAmelCase__			:					str)    ->					Optional[int]:

      """simple docstring"""
      raise Exception(f'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.''')





     def   __UpperCamelCase		(						self			:					Any       ,       *lowerCAmelCase__			:					Optional[int]       ,       **lowerCAmelCase__			:					Dict)    ->					List[str]:

      """simple docstring"""
      raise Exception(f'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.''')





     def   __UpperCamelCase		(						self			:					Optional[Any]       ,       *lowerCAmelCase__			:					str       ,       **lowerCAmelCase__			:					List[str])    ->					List[str]:

      """simple docstring"""
      raise Exception(f'''You cannot use ``pop`` on a {self.__class__.__name__} instance.''')





     def   __UpperCamelCase		(						self			:					int       ,       *lowerCAmelCase__			:					Optional[int]       ,       **lowerCAmelCase__			:					Dict)    ->					List[Any]:

      """simple docstring"""
      raise Exception(f'''You cannot use ``update`` on a {self.__class__.__name__} instance.''')





     def __getitem__(						self			:					Tuple       ,       lowerCAmelCase__			:					Any)    ->					Dict:

      """simple docstring"""
      if isinstance(lowerCAmelCase__       ,       lowerCAmelCase__):
       SCREAMING_SNAKE_CASE							  =						dict(self.items())
       return inner_dict[k]
      else:
       return self.to_tuple()[k]





     def __setattr__(						self			:					Tuple       ,       lowerCAmelCase__			:					Dict       ,       lowerCAmelCase__			:					str)    ->					Any:

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





     def __setitem__(						self			:					Union[str, Any]       ,       lowerCAmelCase__			:					Optional[int]       ,       lowerCAmelCase__			:					Tuple)    ->					Optional[Any]:

      """simple docstring"""
      # Will raise a KeyException if needed
      super().__setitem__(lowerCAmelCase__       ,       lowerCAmelCase__)
      # Don't call self.__setattr__ to avoid recursion errors
      super().__setattr__(lowerCAmelCase__       ,       lowerCAmelCase__)





     def   __UpperCamelCase		(						self			:					str)    ->					Tuple[Any]:

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












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__UpperCAmelCase      				=							{"configuration_visual_bert": ["VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VisualBertConfig"]}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __UpperCAmelCase      				=							[
          "VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
          "VisualBertForMultipleChoice",
          "VisualBertForPreTraining",
          "VisualBertForQuestionAnswering",
          "VisualBertForRegionToPhraseAlignment",
          "VisualBertForVisualReasoning",
          "VisualBertLayer",
          "VisualBertModel",
          "VisualBertPreTrainedModel",
      ]


if TYPE_CHECKING:
      from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_visual_bert import (
                VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                VisualBertForMultipleChoice,
                VisualBertForPreTraining,
                VisualBertForQuestionAnswering,
                VisualBertForRegionToPhraseAlignment,
                VisualBertForVisualReasoning,
                VisualBertLayer,
                VisualBertModel,
                VisualBertPreTrainedModel,
            )


else:
      import sys

      __UpperCAmelCase      				=							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




