



"""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     lowerCAmelCase__						(	unittest.TestCase ):


	'''simple docstring'''







	@slow
	def 			_lowerCAmelCase     (      self				:       int    )						->	Tuple:





					"""simple docstring"""


					for model_name in ["bert-base-uncased"]:
									SCREAMING_SNAKE_CASE						:							List[str]							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							int							=     TFAutoModel.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     AutoModel.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





	@slow
	def 			_lowerCAmelCase     (      self				:       Optional[Any]    )						->	List[str]:





					"""simple docstring"""


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

									SCREAMING_SNAKE_CASE						:							Tuple							=     TFAutoModelForPreTraining.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							str							=     AutoModelForPreTraining.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





	@slow
	def 			_lowerCAmelCase     (      self				:       Any    )						->	Tuple:





					"""simple docstring"""


					for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									SCREAMING_SNAKE_CASE						:							Optional[int]							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Optional[int]							=     TFAutoModelForCausalLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							List[str]							=     TFAutoModelForCausalLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Optional[Any]							=     AutoModelForCausalLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							Dict							=     AutoModelForCausalLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





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





					"""simple docstring"""


					for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									SCREAMING_SNAKE_CASE						:							str							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Any							=     TFAutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							List[str]							=     AutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





	@slow
	def 			_lowerCAmelCase     (      self				:       Tuple    )						->	Dict:





					"""simple docstring"""


					for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									SCREAMING_SNAKE_CASE						:							Tuple							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Tuple							=     TFAutoModelForMaskedLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     TFAutoModelForMaskedLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Optional[int]							=     AutoModelForMaskedLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							Dict							=     AutoModelForMaskedLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





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





					"""simple docstring"""


					for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									SCREAMING_SNAKE_CASE						:							Optional[int]							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							List[Any]							=     TFAutoModelForSeqaSeqLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							int							=     TFAutoModelForSeqaSeqLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     AutoModelForSeqaSeqLM.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						:							Optional[Any]							=     AutoModelForSeqaSeqLM.from_pretrained(
									    _SCREAMING_SNAKE_CASE     ,       output_loading_info=_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





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





					"""simple docstring"""


					for model_name in ["bert-base-uncased"]:
									SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     TFAutoModelForSequenceClassification.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							List[Any]							=     AutoModelForSequenceClassification.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





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





					"""simple docstring"""


					for model_name in ["bert-base-uncased"]:
									SCREAMING_SNAKE_CASE						:							List[str]							=     AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Any							=     TFAutoModelForQuestionAnswering.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )

									SCREAMING_SNAKE_CASE						:							Dict							=     AutoModelForQuestionAnswering.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
									self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )
									self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )





	def 			_lowerCAmelCase     (      self				:       Tuple    )						->	Optional[int]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Optional[int]							=     TFAutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
					self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )
					self.assertEqual(model.num_parameters()     ,       14_410    )
					self.assertEqual(model.num_parameters(only_trainable=_SCREAMING_SNAKE_CASE    )     ,       14_410    )

					SCREAMING_SNAKE_CASE						:							str							=     AutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
					self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )
					self.assertEqual(model.num_parameters()     ,       14_410    )
					self.assertEqual(model.num_parameters(only_trainable=_SCREAMING_SNAKE_CASE    )     ,       14_410    )







	def 			_lowerCAmelCase     (      self				:       Any    )						->	List[str]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Dict							=     TFAutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_pt=_SCREAMING_SNAKE_CASE    )
					self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )
					self.assertEqual(model.num_parameters()     ,       14_410    )
					self.assertEqual(model.num_parameters(only_trainable=_SCREAMING_SNAKE_CASE    )     ,       14_410    )

					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     AutoModelWithLMHead.from_pretrained(_SCREAMING_SNAKE_CASE     ,       from_tf=_SCREAMING_SNAKE_CASE    )
					self.assertIsInstance(_SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE    )
					self.assertEqual(model.num_parameters()     ,       14_410    )
					self.assertEqual(model.num_parameters(only_trainable=_SCREAMING_SNAKE_CASE    )     ,       14_410    )










"""simple docstring"""

# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from ...utils import deprecate
from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline  # noqa: F401


deprecate(
    'stable diffusion controlnet',
    '0.22.0',
    'Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.flax_pipeline_stable_diffusion_controlnet is deprecated. Please import `from diffusers import FlaxStableDiffusionControlNetPipeline` instead.',
    standard_warn=False,
    stacklevel=3,
)





