





from typing import TYPE_CHECKING

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


__A    :   Any          =       {
    "configuration_deberta_v2": ["DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaV2Config", "DebertaV2OnnxConfig"],
    "tokenization_deberta_v2": ["DebertaV2Tokenizer"],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A    :   List[Any]          =       ["DebertaV2TokenizerFast"]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A    :   Optional[Any]          =       [
				    "TF_DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "TFDebertaV2ForMaskedLM",
				    "TFDebertaV2ForQuestionAnswering",
				    "TFDebertaV2ForSequenceClassification",
				    "TFDebertaV2ForTokenClassification",
				    "TFDebertaV2Model",
				    "TFDebertaV2PreTrainedModel",
				]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A    :   Tuple          =       [
				    "DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "DebertaV2ForMaskedLM",
				    "DebertaV2ForMultipleChoice",
				    "DebertaV2ForQuestionAnswering",
				    "DebertaV2ForSequenceClassification",
				    "DebertaV2ForTokenClassification",
				    "DebertaV2Model",
				    "DebertaV2PreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_deberta_va import (
				    DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    DebertaVaConfig,
				    DebertaVaOnnxConfig,
				)
				from .tokenization_deberta_va import DebertaVaTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_deberta_va_fast import DebertaVaTokenizerFast

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_deberta_va import (
								    TF_DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFDebertaVaForMaskedLM,
								    TFDebertaVaForQuestionAnswering,
								    TFDebertaVaForSequenceClassification,
								    TFDebertaVaForTokenClassification,
								    TFDebertaVaModel,
								    TFDebertaVaPreTrainedModel,
								)

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_deberta_va import (
								    DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
								    DebertaVaForMaskedLM,
								    DebertaVaForMultipleChoice,
								    DebertaVaForQuestionAnswering,
								    DebertaVaForSequenceClassification,
								    DebertaVaForTokenClassification,
								    DebertaVaModel,
								    DebertaVaPreTrainedModel,
								)

else:
				import sys

				__A    :   int          =       _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)










import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard

class      A_	(unittest.TestCase      ):
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    {
				    '''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''': 7_6},
				}
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)
				self.assertTrue(hasattr(_A							, '''model_details'''		)		)
				self.assertTrue(hasattr(_A							, '''intended_use'''		)		)
				self.assertTrue(hasattr(_A							, '''factors'''		)		)
				self.assertTrue(hasattr(_A							, '''metrics'''		)		)
				self.assertTrue(hasattr(_A							, '''evaluation_data'''		)		)
				self.assertTrue(hasattr(_A							, '''training_data'''		)		)
				self.assertTrue(hasattr(_A							, '''quantitative_analyses'''		)		)
				self.assertTrue(hasattr(_A							, '''ethical_considerations'''		)		)
				self.assertTrue(hasattr(_A							, '''caveats_and_recommendations'''		)		)
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)
				UpperCAmelCase       		=    json.loads(modelcard.to_json_string()		)
				for key, value in self.inputs_dict.items():
							self.assertEqual(obj[key]							, _A		)
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)

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

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







	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							model_card_first.save_pretrained(_A		)
							UpperCAmelCase       		=    ModelCard.from_pretrained(_A		)

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



