

"""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  UpperCamelCase		(   self:       Dict				):






         """simple docstring"""


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

              A__								=     TFAutoModel.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModel.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       List[str]				):






         """simple docstring"""


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

              A__								=     TFAutoModelForPreTraining.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForPreTraining.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       Optional[int]				):






         """simple docstring"""


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

              A__								=     TFAutoModelForCausalLM.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              A__								=     TFAutoModelForCausalLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForCausalLM.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              A__								=     AutoModelForCausalLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       List[Any]				):






         """simple docstring"""


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

              A__								=     TFAutoModelWithLMHead.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelWithLMHead.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       List[str]				):






         """simple docstring"""


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

              A__								=     TFAutoModelForMaskedLM.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              A__								=     TFAutoModelForMaskedLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForMaskedLM.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              A__								=     AutoModelForMaskedLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       Optional[int]				):






         """simple docstring"""


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

              A__								=     TFAutoModelForSeqaSeqLM.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              A__								=     TFAutoModelForSeqaSeqLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForSeqaSeqLM.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              A__								=     AutoModelForSeqaSeqLM.from_pretrained(
                  snake_case_			,  output_loading_info=snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       Optional[int]				):






         """simple docstring"""


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

              A__								=     TFAutoModelForSequenceClassification.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForSequenceClassification.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    @slow
    def  UpperCamelCase		(   self:       Tuple				):






         """simple docstring"""


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

              A__								=     TFAutoModelForQuestionAnswering.from_pretrained(snake_case_			,  from_pt=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

              A__								=     AutoModelForQuestionAnswering.from_pretrained(snake_case_			,  from_tf=snake_case_				)
              self.assertIsNotNone(snake_case_				)
              self.assertIsInstance(snake_case_			,  snake_case_				)

    def  UpperCamelCase		(   self:       List[Any]				):






         """simple docstring"""


         A__								=     TFAutoModelWithLMHead.from_pretrained(snake_case_			,  from_pt=snake_case_				)
         self.assertIsInstance(snake_case_			,  snake_case_				)
         self.assertEqual(model.num_parameters()			,  1_44_10				)
         self.assertEqual(model.num_parameters(only_trainable=snake_case_				)			,  1_44_10				)

         A__								=     AutoModelWithLMHead.from_pretrained(snake_case_			,  from_tf=snake_case_				)
         self.assertIsInstance(snake_case_			,  snake_case_				)
         self.assertEqual(model.num_parameters()			,  1_44_10				)
         self.assertEqual(model.num_parameters(only_trainable=snake_case_				)			,  1_44_10				)





    def  UpperCamelCase		(   self:       List[str]				):






         """simple docstring"""


         A__								=     TFAutoModelWithLMHead.from_pretrained(snake_case_			,  from_pt=snake_case_				)
         self.assertIsInstance(snake_case_			,  snake_case_				)
         self.assertEqual(model.num_parameters()			,  1_44_10				)
         self.assertEqual(model.num_parameters(only_trainable=snake_case_				)			,  1_44_10				)

         A__								=     AutoModelWithLMHead.from_pretrained(snake_case_			,  from_tf=snake_case_				)
         self.assertIsInstance(snake_case_			,  snake_case_				)
         self.assertEqual(model.num_parameters()			,  1_44_10				)
         self.assertEqual(model.num_parameters(only_trainable=snake_case_				)			,  1_44_10				)













"""simple docstring"""




import torch

from diffusers import DiffusionPipeline

class  _UpperCAmelCase  (   UpperCAmelCase__		):



      '''simple docstring'''

      def __init__(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        super().__init__()

        self.register_modules(unet=snake_case_					,      scheduler=snake_case_  )

      def __call__(     self  ):

        """simple docstring"""

        A_  :       Optional[Any]										=  torch.randn(
            (1, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)					,      )
        A_  :       List[str]										=  1

        A_  :       List[str]										=  self.unet(snake_case_					,      snake_case_  ).sample
        A_  :       Optional[int]										=  self.scheduler.step(snake_case_					,      snake_case_					,      snake_case_  ).prev_sample

        A_  :       List[Any]										=  scheduler_output - scheduler_output + torch.ones_like(snake_case_  )

        return result