






import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard
class 				_UpperCAmelCase (	unittest.TestCase     ):




				def     lowercase__       (					self						:   List[str]  ):

								'''simple docstring'''
								lowercase__       			=      {
								    '''model_details''': {
								        '''Organization''': '''testing''',
								        '''Model date''': '''today''',
								        '''Model version''': '''v2.1, Developed by Test Corp in 2019.''',
								        '''Architecture''': '''Convolutional Neural Network.''',
								    },
								    '''metrics''': '''BLEU and ROUGE-1''',
								    '''evaluation_data''': {
								        '''Datasets''': {'''BLEU''': '''My-great-dataset-v1''', '''ROUGE-1''': '''My-short-dataset-v2.1'''},
								        '''Preprocessing''': '''See details on https://arxiv.org/pdf/1810.03993.pdf''',
								    },
								    '''training_data''': {
								        '''Dataset''': '''English Wikipedia dump dated 2018-12-01''',
								        '''Preprocessing''': (
								            '''Using SentencePiece vocabulary of size 52k tokens. See details on'''
								            ''' https://arxiv.org/pdf/1810.03993.pdf'''
								        ),
								    },
								    '''quantitative_analyses''': {'''BLEU''': 55.1, '''ROUGE-1''': 76},
								}




				def     lowercase__       (					self						:   Tuple  ):

								'''simple docstring'''
								lowercase__       			=      ModelCard.from_dict(self.inputs_dict  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''model_details'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''intended_use'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''factors'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''metrics'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''evaluation_data'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''training_data'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''quantitative_analyses'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''ethical_considerations'''  )  )
								self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE,  '''caveats_and_recommendations'''  )  )




				def     lowercase__       (					self						:   List[str]  ):

								'''simple docstring'''
								lowercase__       			=      ModelCard.from_dict(self.inputs_dict  )
								lowercase__       			=      json.loads(modelcard.to_json_string()  )
								for key, value in self.inputs_dict.items():
												self.assertEqual(obj[key],  __SCREAMING_SNAKE_CASE  )




				def     lowercase__       (					self						:   Optional[Any]  ):

								'''simple docstring'''
								lowercase__       			=      ModelCard.from_dict(self.inputs_dict  )

								with tempfile.TemporaryDirectory() as tmpdirname:
												lowercase__       			=      os.path.join(__SCREAMING_SNAKE_CASE,  '''modelcard.json'''  )
												model_card_first.to_json_file(__SCREAMING_SNAKE_CASE  )
												lowercase__       			=      ModelCard.from_json_file(__SCREAMING_SNAKE_CASE  )

								self.assertEqual(model_card_second.to_dict(),  model_card_first.to_dict()  )




				def     lowercase__       (					self						:   Union[str, Any]  ):

								'''simple docstring'''
								lowercase__       			=      ModelCard.from_dict(self.inputs_dict  )

								with tempfile.TemporaryDirectory() as tmpdirname:
												model_card_first.save_pretrained(__SCREAMING_SNAKE_CASE  )
												lowercase__       			=      ModelCard.from_pretrained(__SCREAMING_SNAKE_CASE  )

								self.assertEqual(model_card_second.to_dict(),  model_card_first.to_dict()  )












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A__     :      int             =			{
    'configuration_sam': [
        'SAM_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'SamConfig',
        'SamMaskDecoderConfig',
        'SamPromptEncoderConfig',
        'SamVisionConfig',
    ],
    'processing_sam': ['SamProcessor'],
}


try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      List[Any]             =			[
							    'SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'SamModel',
							    'SamPreTrainedModel',
							]
try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      int             =			[
							    'TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'TFSamModel',
							    'TFSamPreTrainedModel',
							]
try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      Tuple             =			['SamImageProcessor']


if TYPE_CHECKING:
							from .configuration_sam import (
							    SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    SamConfig,
							    SamMaskDecoderConfig,
							    SamPromptEncoderConfig,
							    SamVisionConfig,
							)
							from .processing_sam import SamProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .image_processing_sam import SamImageProcessor

else:
							import sys

							A__     :      Dict             =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




