


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






 """simple docstring"""




 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     Tuple:
     # for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     for model_name in ["bert-base-uncased"]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModel.from_pretrained(__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModel.from_pretrained(__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     Tuple:
     # for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     for model_name in ["bert-base-uncased"]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForPreTraining.from_pretrained(__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForPreTraining.from_pretrained(__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     int:
     for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForCausalLM.from_pretrained(__A ,    from_pt=__A						)
         a		,      a 		=TFAutoModelForCausalLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForCausalLM.from_pretrained(__A ,    from_tf=__A						)
         a		,      a 		=AutoModelForCausalLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     str:
     for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelWithLMHead.from_pretrained(__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelWithLMHead.from_pretrained(__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     List[Any]:
     for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForMaskedLM.from_pretrained(__A ,    from_pt=__A						)
         a		,      a 		=TFAutoModelForMaskedLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForMaskedLM.from_pretrained(__A ,    from_tf=__A						)
         a		,      a 		=AutoModelForMaskedLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     Optional[int]:
     for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForSeqaSeqLM.from_pretrained(__A ,    from_pt=__A						)
         a		,      a 		=TFAutoModelForSeqaSeqLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForSeqaSeqLM.from_pretrained(__A ,    from_tf=__A						)
         a		,      a 		=AutoModelForSeqaSeqLM.from_pretrained(
             __A ,    output_loading_info=__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     Tuple:
     # for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     for model_name in ["bert-base-uncased"]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForSequenceClassification.from_pretrained(__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForSequenceClassification.from_pretrained(__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 @slow
 def       SCREAMING_SNAKE_CASE							(		self						)					->     str:
     # for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     for model_name in ["bert-base-uncased"]:
         a 		=AutoConfig.from_pretrained(__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=TFAutoModelForQuestionAnswering.from_pretrained(__A ,    from_pt=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)

         a 		=AutoModelForQuestionAnswering.from_pretrained(__A ,    from_tf=__A						)
         self.assertIsNotNone(__A						)
         self.assertIsInstance(__A ,    __A						)


 def       SCREAMING_SNAKE_CASE							(		self						)					->     Optional[Any]:
     a 		=TFAutoModelWithLMHead.from_pretrained(__A ,    from_pt=__A						)
     self.assertIsInstance(__A ,    __A						)
     self.assertEqual(model.num_parameters() ,    1_4410						)
     self.assertEqual(model.num_parameters(only_trainable=__A						) ,    1_4410						)

     a 		=AutoModelWithLMHead.from_pretrained(__A ,    from_tf=__A						)
     self.assertIsInstance(__A ,    __A						)
     self.assertEqual(model.num_parameters() ,    1_4410						)
     self.assertEqual(model.num_parameters(only_trainable=__A						) ,    1_4410						)





 def       SCREAMING_SNAKE_CASE							(		self						)					->     List[Any]:
     a 		=TFAutoModelWithLMHead.from_pretrained(__A ,    from_pt=__A						)
     self.assertIsInstance(__A ,    __A						)
     self.assertEqual(model.num_parameters() ,    1_4410						)
     self.assertEqual(model.num_parameters(only_trainable=__A						) ,    1_4410						)

     a 		=AutoModelWithLMHead.from_pretrained(__A ,    from_tf=__A						)
     self.assertIsInstance(__A ,    __A						)
     self.assertEqual(model.num_parameters() ,    1_4410						)
     self.assertEqual(model.num_parameters(only_trainable=__A						) ,    1_4410						)



'''simple docstring'''
from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
		if not (is_transformers_available() and is_torch_available()):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
		from .multicontrolnet import MultiControlNetModel
		from .pipeline_controlnet import StableDiffusionControlNetPipeline
		from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
		from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
		from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline