






'''simple docstring'''


from __future__ import annotations

import unittest

from transformers import is_tf_available, is_torch_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow


if is_tf_available():
					from transformers import (
					    AutoConfig,
					    BertConfig,
					    GPTaConfig,
					    TaConfig,
					    TFAutoModel,
					    TFAutoModelForCausalLM,
					    TFAutoModelForMaskedLM,
					    TFAutoModelForPreTraining,
					    TFAutoModelForQuestionAnswering,
					    TFAutoModelForSeqaSeqLM,
					    TFAutoModelForSequenceClassification,
					    TFAutoModelWithLMHead,
					    TFBertForMaskedLM,
					    TFBertForPreTraining,
					    TFBertForQuestionAnswering,
					    TFBertForSequenceClassification,
					    TFBertModel,
					    TFGPTaLMHeadModel,
					    TFRobertaForMaskedLM,
					    TFTaForConditionalGeneration,
					)
					from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
					from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
					from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST

if is_torch_available():
					from transformers import (
					    AutoModel,
					    AutoModelForCausalLM,
					    AutoModelForMaskedLM,
					    AutoModelForPreTraining,
					    AutoModelForQuestionAnswering,
					    AutoModelForSeqaSeqLM,
					    AutoModelForSequenceClassification,
					    AutoModelWithLMHead,
					    BertForMaskedLM,
					    BertForPreTraining,
					    BertForQuestionAnswering,
					    BertForSequenceClassification,
					    BertModel,
					    GPTaLMHeadModel,
					    RobertaForMaskedLM,
					    TaForConditionalGeneration,
					)
@is_pt_tf_cross_test
class    _SCREAMING_SNAKE_CASE							(		unittest.TestCase	):


			'''simple docstring'''





			@slow
			def 				A      (   self							:						Optional[Any]			)							->    Tuple:

									'''simple docstring'''







									for model_name in ["bert-base-uncased"]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModel.from_pretrained(lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModel.from_pretrained(lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						Optional[int]			)							->    str:

									'''simple docstring'''







									for model_name in ["bert-base-uncased"]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForPreTraining.from_pretrained(lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForPreTraining.from_pretrained(lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						List[str]			)							->    List[str]:

									'''simple docstring'''







									for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForCausalLM.from_pretrained(lowercase ,      from_pt=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = TFAutoModelForCausalLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForCausalLM.from_pretrained(lowercase ,      from_tf=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = AutoModelForCausalLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						List[Any]			)							->    Dict:

									'''simple docstring'''







									for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelWithLMHead.from_pretrained(lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelWithLMHead.from_pretrained(lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						List[Any]			)							->    Optional[int]:

									'''simple docstring'''







									for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForMaskedLM.from_pretrained(lowercase ,      from_pt=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = TFAutoModelForMaskedLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForMaskedLM.from_pretrained(lowercase ,      from_tf=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = AutoModelForMaskedLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						Union[str, Any]			)							->    int:

									'''simple docstring'''







									for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForSeqaSeqLM.from_pretrained(lowercase ,      from_pt=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = TFAutoModelForSeqaSeqLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForSeqaSeqLM.from_pretrained(lowercase ,      from_tf=lowercase			)
															UpperCamelCase__    ,   UpperCamelCase__         = AutoModelForSeqaSeqLM.from_pretrained(
															    lowercase ,      output_loading_info=lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						Optional[Any]			)							->    Tuple:

									'''simple docstring'''







									for model_name in ["bert-base-uncased"]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForSequenceClassification.from_pretrained(lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForSequenceClassification.from_pretrained(lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			@slow
			def 				A      (   self							:						Optional[Any]			)							->    Dict:

									'''simple docstring'''







									for model_name in ["bert-base-uncased"]:
															UpperCamelCase__         = AutoConfig.from_pretrained(lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = TFAutoModelForQuestionAnswering.from_pretrained(lowercase ,      from_pt=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)

															UpperCamelCase__         = AutoModelForQuestionAnswering.from_pretrained(lowercase ,      from_tf=lowercase			)
															self.assertIsNotNone(lowercase			)
															self.assertIsInstance(lowercase ,      lowercase			)






			def 				A      (   self							:						Any			)							->    Tuple:

									'''simple docstring'''







									UpperCamelCase__         = TFAutoModelWithLMHead.from_pretrained(lowercase ,      from_pt=lowercase			)
									self.assertIsInstance(lowercase ,      lowercase			)
									self.assertEqual(model.num_parameters() ,      1_4_4_1_0			)
									self.assertEqual(model.num_parameters(only_trainable=lowercase			) ,      1_4_4_1_0			)

									UpperCamelCase__         = AutoModelWithLMHead.from_pretrained(lowercase ,      from_tf=lowercase			)
									self.assertIsInstance(lowercase ,      lowercase			)
									self.assertEqual(model.num_parameters() ,      1_4_4_1_0			)
									self.assertEqual(model.num_parameters(only_trainable=lowercase			) ,      1_4_4_1_0			)







			def 				A      (   self							:						Tuple			)							->    int:

									'''simple docstring'''







									UpperCamelCase__         = TFAutoModelWithLMHead.from_pretrained(lowercase ,      from_pt=lowercase			)
									self.assertIsInstance(lowercase ,      lowercase			)
									self.assertEqual(model.num_parameters() ,      1_4_4_1_0			)
									self.assertEqual(model.num_parameters(only_trainable=lowercase			) ,      1_4_4_1_0			)

									UpperCamelCase__         = AutoModelWithLMHead.from_pretrained(lowercase ,      from_tf=lowercase			)
									self.assertIsInstance(lowercase ,      lowercase			)
									self.assertEqual(model.num_parameters() ,      1_4_4_1_0			)
									self.assertEqual(model.num_parameters(only_trainable=lowercase			) ,      1_4_4_1_0			)








'''simple docstring'''


import inspect
import unittest
class    _SCREAMING_SNAKE_CASE							(		unittest.TestCase	):


			'''simple docstring'''





			def 				A      (   self							:						Tuple			)							->    Any:

									'''simple docstring'''







									try:
															import diffusers  # noqa: F401
									except ImportError:
															assert False







			def 				A      (   self							:						Optional[int]			)							->    Union[str, Any]:

									'''simple docstring'''







									import diffusers
									from diffusers.dependency_versions_table import deps

									UpperCamelCase__         = inspect.getmembers(lowercase ,      inspect.isclass			)

									for cls_name, cls_module in all_classes:
															if "dummy_" in cls_module.__module__:
																					for backend in cls_module._backends:
																											if backend == "k_diffusion":
																																	UpperCamelCase__         = """k-diffusion"""
																											elif backend == "invisible_watermark":
																																	UpperCamelCase__         = """invisible-watermark"""
																											assert backend in deps, f"{backend} is not in the deps table!"
