'''simple docstring'''


import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput






@dataclass
class 	__SCREAMING_SNAKE_CASE		(			__lowerCamelCase			):







  '''simple docstring'''






  lowerCamelCase_						:Optional[Any]		       =						42
  lowerCamelCase_						:Optional[Any]		       =						None
  lowerCamelCase_						:Tuple		       =						None







class 	__SCREAMING_SNAKE_CASE		(			unittest.TestCase			):







  '''simple docstring'''






  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Any  = ModelOutputTest(a=3_0		)
       self.assertEqual(x.a ,						3_0		)
       self.assertIsNone(x.b		)
       self.assertIsNone(x.c		)
       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  Dict  = x.d


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Optional[int]  = ModelOutputTest(a=3_0 ,						b=1_0		)
       self.assertEqual(x[0] ,						3_0		)
       self.assertEqual(x[1] ,						1_0		)
       self.assertEqual(x[:2] ,						(3_0, 1_0)		)
       self.assertEqual(x[:] ,						(3_0, 1_0)		)

       UpperCAmelCase_				:  Any  = ModelOutputTest(a=3_0 ,						c=1_0		)
       self.assertEqual(x[0] ,						3_0		)
       self.assertEqual(x[1] ,						1_0		)
       self.assertEqual(x[:2] ,						(3_0, 1_0)		)
       self.assertEqual(x[:] ,						(3_0, 1_0)		)


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Dict  = ModelOutputTest(a=3_0 ,						b=1_0		)
       self.assertEqual(x['a'] ,						3_0		)
       self.assertEqual(x['b'] ,						1_0		)
       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  Tuple  = x['c']

       UpperCAmelCase_				:  Any  = ModelOutputTest(a=3_0 ,						c=1_0		)
       self.assertEqual(x['a'] ,						3_0		)
       self.assertEqual(x['c'] ,						1_0		)
       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  Optional[int]  = x['b']


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Any  = ModelOutputTest(a=3_0		)
       self.assertEqual(list(x.keys()		) ,						['a']		)
       self.assertEqual(list(x.values()		) ,						[3_0]		)
       self.assertEqual(list(x.items()		) ,						[('a', 3_0)]		)
       self.assertEqual(list(__lowerCAmelCase		) ,						['a']		)

       UpperCAmelCase_				:  str  = ModelOutputTest(a=3_0 ,						b=1_0		)
       self.assertEqual(list(x.keys()		) ,						['a', 'b']		)
       self.assertEqual(list(x.values()		) ,						[3_0, 1_0]		)
       self.assertEqual(list(x.items()		) ,						[('a', 3_0), ('b', 1_0)]		)
       self.assertEqual(list(__lowerCAmelCase		) ,						['a', 'b']		)

       UpperCAmelCase_				:  Any  = ModelOutputTest(a=3_0 ,						c=1_0		)
       self.assertEqual(list(x.keys()		) ,						['a', 'c']		)
       self.assertEqual(list(x.values()		) ,						[3_0, 1_0]		)
       self.assertEqual(list(x.items()		) ,						[('a', 3_0), ('c', 1_0)]		)
       self.assertEqual(list(__lowerCAmelCase		) ,						['a', 'c']		)

       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  List[str]  = x.update({'d': 2_0}		)
       with self.assertRaises(__lowerCAmelCase		):
            del x["a"]
       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  Any  = x.pop('a'		)
       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  str  = x.setdefault('d' ,						3_2		)


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  List[str]  = ModelOutputTest(a=3_0		)
       UpperCAmelCase_				:  List[Any]  = 1_0
       self.assertEqual(x.a ,						1_0		)
       self.assertEqual(x['a'] ,						1_0		)


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Dict  = ModelOutputTest(a=3_0		)
       UpperCAmelCase_				:  List[str]  = 1_0
       self.assertEqual(x.a ,						1_0		)
       self.assertEqual(x['a'] ,						1_0		)


  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  List[Any]  = ModelOutputTest({'a': 3_0, 'b': 1_0}		)
       self.assertEqual(list(x.keys()		) ,						['a', 'b']		)
       self.assertEqual(x.a ,						3_0		)
       self.assertEqual(x.b ,						1_0		)






  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       UpperCAmelCase_				:  Union[str, Any]  = ModelOutputTest([('a', 3_0), ('b', 1_0)]		)
       self.assertEqual(list(x.keys()		) ,						['a', 'b']		)
       self.assertEqual(x.a ,						3_0		)
       self.assertEqual(x.b ,						1_0		)

       with self.assertRaises(__lowerCAmelCase		):
            UpperCAmelCase_				:  Union[str, Any]  = ModelOutputTest([('a', 3_0), (1_0, 1_0)]		)

       UpperCAmelCase_				:  int  = ModelOutputTest(a=(3_0, 3_0)		)
       self.assertEqual(list(x.keys()		) ,						['a']		)
       self.assertEqual(x.a ,						(3_0, 3_0)		)







'''simple docstring'''

from typing import TYPE_CHECKING

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


lowerCAmelCase_			:			Tuple    	=   {"configuration_vilt": ["VILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViltConfig"]}

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCAmelCase_			:			Optional[int]    	=   ["ViltFeatureExtractor"]
       lowerCAmelCase_			:			str    	=   ["ViltImageProcessor"]
       lowerCAmelCase_			:			Any    	=   ["ViltProcessor"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCAmelCase_			:			Any    	=   [
           "VILT_PRETRAINED_MODEL_ARCHIVE_LIST",
           "ViltForImageAndTextRetrieval",
           "ViltForImagesAndTextClassification",
           "ViltForTokenClassification",
           "ViltForMaskedLM",
           "ViltForQuestionAnswering",
           "ViltLayer",
           "ViltModel",
           "ViltPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_vilt import VILT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViltConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_vilt import ViltFeatureExtractor
              from .image_processing_vilt import ViltImageProcessor
              from .processing_vilt import ViltProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_vilt import (
                  VILT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  ViltForImageAndTextRetrieval,
                  ViltForImagesAndTextClassification,
                  ViltForMaskedLM,
                  ViltForQuestionAnswering,
                  ViltForTokenClassification,
                  ViltLayer,
                  ViltModel,
                  ViltPreTrainedModel,
              )


else:
       import sys

       lowerCAmelCase_			:			str    	=   _LazyModule(__name__, globals()["__file__"], _import_structure)






