'''simple docstring'''

import inspect
import unittest

from transformers import EfficientNetConfig
from transformers.testing_utils import is_pipeline_test, require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import EfficientNetForImageClassification, EfficientNetModel
      from transformers.models.efficientnet.modeling_efficientnet import EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
      from PIL import Image

      from transformers import AutoImageProcessor




class    lowerCamelCase__  :



   def __init__(    self					,      lowerCAmelCase__					,      lowerCAmelCase__=13					,      lowerCAmelCase__=32					,      lowerCAmelCase__=3					,      lowerCAmelCase__=[3, 3, 5]					,      lowerCAmelCase__=[32, 16, 24]					,      lowerCAmelCase__=[16, 24, 40]					,      lowerCAmelCase__=[1, 1, 2]					,      lowerCAmelCase__=[1, 1, 2]					,      lowerCAmelCase__=[1, 6, 6]					,      lowerCAmelCase__=True					,      lowerCAmelCase__=True					,      lowerCAmelCase__=37					,      lowerCAmelCase__="gelu"					,      lowerCAmelCase__=10					,      )				->     Union[str, Any]:
        """simple docstring"""





        _UpperCamelCase  :str       =parent
        _UpperCamelCase  :str       =batch_size
        _UpperCamelCase  :Any       =image_size
        _UpperCamelCase  :str       =num_channels
        _UpperCamelCase  :Dict       =kernel_sizes
        _UpperCamelCase  :List[str]       =in_channels
        _UpperCamelCase  :List[str]       =out_channels
        _UpperCamelCase  :Any       =strides
        _UpperCamelCase  :Tuple       =num_block_repeats
        _UpperCamelCase  :Tuple       =expand_ratios
        _UpperCamelCase  :int       =is_training
        _UpperCamelCase  :Union[str, Any]       =hidden_act
        _UpperCamelCase  :Optional[Any]       =num_labels
        _UpperCamelCase  :Dict       =use_labels



   def  _UpperCamelCase		(    self     )				->     Optional[Any]:
        """simple docstring"""





        _UpperCamelCase  :Optional[int]       =floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )

        _UpperCamelCase  :List[Any]       =None
        if self.use_labels:
             _UpperCamelCase  :int       =ids_tensor([self.batch_size]					,      self.num_labels     )

        _UpperCamelCase  :int       =self.get_config()
        return config, pixel_values, labels



   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        return EfficientNetConfig(
            num_channels=self.num_channels					,      kernel_sizes=self.kernel_sizes					,      in_channels=self.in_channels					,      out_channels=self.out_channels					,      strides=self.strides					,      num_block_repeats=self.num_block_repeats					,      expand_ratios=self.expand_ratios					,      hidden_act=self.hidden_act					,      num_labels=self.num_labels					,      )



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )				->     int:
        """simple docstring"""





        _UpperCamelCase  :Dict       =EfficientNetModel(config=lowerCAmelCase__     )
        model.to(lowerCAmelCase__     )
        model.eval()
        _UpperCamelCase  :Optional[Any]       =model(lowerCAmelCase__     )
        # expected last hidden states: B, C, H // 4, W // 4
        self.parent.assertEqual(
            result.last_hidden_state.shape					,      (self.batch_size, config.hidden_dim, self.image_size // 4, self.image_size // 4)					,      )



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )				->     Any:
        """simple docstring"""





        _UpperCamelCase  :Any       =EfficientNetForImageClassification(lowerCAmelCase__     )
        model.to(lowerCAmelCase__     )
        model.eval()
        _UpperCamelCase  :Dict       =model(lowerCAmelCase__					,      labels=lowerCAmelCase__     )
        self.parent.assertEqual(result.logits.shape					,      (self.batch_size, self.num_labels)     )




   def  _UpperCamelCase		(    self     )				->     Optional[Any]:
        """simple docstring"""





        _UpperCamelCase  :Optional[Any]       =self.prepare_config_and_inputs()
        _UpperCamelCase       ,      _UpperCamelCase       ,      _UpperCamelCase  :Tuple       =config_and_inputs
        _UpperCamelCase  :Any       ={"""pixel_values""": pixel_values}
        return config, inputs_dict




@require_torch
class    lowerCamelCase__  (   __snake_case       ,				__snake_case       ,				unittest.TestCase     ):
   __UpperCAmelCase           =						(EfficientNetModel, EfficientNetForImageClassification) if is_torch_available() else ()
   __UpperCAmelCase           =						(
       {"""feature-extraction""": EfficientNetModel, """image-classification""": EfficientNetForImageClassification}
       if is_torch_available()
       else {}
   )

   __UpperCAmelCase           =						False
   __UpperCAmelCase           =						False
   __UpperCAmelCase           =						False
   __UpperCAmelCase           =						False
   __UpperCAmelCase           =						False



   def  _UpperCamelCase		(    self     )				->     Union[str, Any]:
        """simple docstring"""





        _UpperCamelCase  :Tuple       =EfficientNetModelTester(self     )
        _UpperCamelCase  :Dict       =ConfigTester(
            self					,      config_class=lowerCAmelCase__					,      has_text_modality=lowerCAmelCase__					,      hidden_size=37     )



   def  _UpperCamelCase		(    self     )				->     Optional[Any]:
        """simple docstring"""





        self.create_and_test_config_common_properties()
        self.config_tester.create_and_test_config_to_json_string()
        self.config_tester.create_and_test_config_to_json_file()
        self.config_tester.create_and_test_config_from_and_save_pretrained()
        self.config_tester.create_and_test_config_with_num_labels()
        self.config_tester.check_config_can_be_init_without_params()
        self.config_tester.check_config_arguments_init()



   def  _UpperCamelCase		(    self     )				->     Tuple:
        """simple docstring"""





        return



   @unittest.skip(reason="""EfficientNet does not use inputs_embeds"""     )
   def  _UpperCamelCase		(    self     )				->     List[Any]:
        """simple docstring"""





        pass



   @unittest.skip(reason="""EfficientNet does not support input and output embeddings"""     )
   def  _UpperCamelCase		(    self     )				->     str:
        """simple docstring"""





        pass



   @unittest.skip(reason="""EfficientNet does not use feedforward chunking"""     )
   def  _UpperCamelCase		(    self     )				->     List[Any]:
        """simple docstring"""





        pass



   def  _UpperCamelCase		(    self     )				->     Dict:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :int       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _UpperCamelCase  :Optional[int]       =model_class(lowerCAmelCase__     )
             _UpperCamelCase  :Optional[int]       =inspect.signature(model.forward     )
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             _UpperCamelCase  :Optional[Any]       =[*signature.parameters.keys()]

             _UpperCamelCase  :Union[str, Any]       =["""pixel_values"""]
             self.assertListEqual(arg_names[:1]					,      lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     Optional[int]:
        """simple docstring"""





        _UpperCamelCase  :int       =self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     Tuple:
        """simple docstring"""





        def check_hidden_states_output(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     ):
             _UpperCamelCase  :Any       =model_class(lowerCAmelCase__     )
             model.to(lowerCAmelCase__     )
             model.eval()

             with torch.no_grad():
                  _UpperCamelCase  :str       =model(**self._prepare_for_class(lowerCAmelCase__					,      lowerCAmelCase__     )     )

             _UpperCamelCase  :Optional[Any]       =outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
             _UpperCamelCase  :Any       =sum(config.num_block_repeats     ) * 4
             self.assertEqual(len(lowerCAmelCase__     )					,      lowerCAmelCase__     )

             # EfficientNet's feature maps are of shape (batch_size, num_channels, height, width)
             self.assertListEqual(
                 list(hidden_states[0].shape[-2:]     )					,      [self.model_tester.image_size // 2, self.model_tester.image_size // 2]					,      )

        _UpperCamelCase       ,      _UpperCamelCase  :Tuple       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _UpperCamelCase  :Any       =True
             check_hidden_states_output(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             _UpperCamelCase  :Optional[Any]       =True

             check_hidden_states_output(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     List[Any]:
        """simple docstring"""





        _UpperCamelCase  :List[str]       =self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__     )



   @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""     )
   def  _UpperCamelCase		(    self     )				->     Tuple:
        """simple docstring"""





        pass



   @slow
   def  _UpperCamelCase		(    self     )				->     List[Any]:
        """simple docstring"""





        for model_name in EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             _UpperCamelCase  :Tuple       =EfficientNetModel.from_pretrained(lowerCAmelCase__     )
             self.assertIsNotNone(lowerCAmelCase__     )




   @is_pipeline_test
   @require_vision
   @slow
   def  _UpperCamelCase		(    self     )				->     Optional[int]:
        """simple docstring"""





        super().test_pipeline_image_classification()




def  _lowerCAmelCase				(				)  ->      List[str]:
     '''simple docstring'''







     _UpperCamelCase  :Dict       =Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""      )
     return image




@require_torch
@require_vision
class    lowerCamelCase__  (   unittest.TestCase     ):



   @cached_property
   def  _UpperCamelCase		(    self     )				->     Optional[Any]:
        """simple docstring"""





        return AutoImageProcessor.from_pretrained("""google/efficientnet-b7"""     ) if is_vision_available() else None




   @slow
   def  _UpperCamelCase		(    self     )				->     int:
        """simple docstring"""





        _UpperCamelCase  :str       =EfficientNetForImageClassification.from_pretrained("""google/efficientnet-b7"""     ).to(lowerCAmelCase__     )

        _UpperCamelCase  :Optional[Any]       =self.default_image_processor
        _UpperCamelCase  :Any       =prepare_img()
        _UpperCamelCase  :Union[str, Any]       =image_processor(images=lowerCAmelCase__					,      return_tensors="""pt"""     ).to(lowerCAmelCase__     )

        # forward pass
        with torch.no_grad():
             _UpperCamelCase  :List[Any]       =model(**lowerCAmelCase__     )

        # verify the logits
        _UpperCamelCase  :List[str]       =torch.Size((1, 1_000)     )
        self.assertEqual(outputs.logits.shape					,      lowerCAmelCase__     )

        _UpperCamelCase  :int       =torch.tensor([0.0001, 0.0002, 0.0002]     ).to(lowerCAmelCase__     )
        self.assertTrue(torch.allclose(outputs.logits[0, :3]					,      lowerCAmelCase__					,      atol=1e-4     )     )
from __future__ import annotations

import unittest

from transformers import MPNetConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import tensorflow as tf

      from transformers.models.mpnet.modeling_tf_mpnet import (
          TFMPNetForMaskedLM,
          TFMPNetForMultipleChoice,
          TFMPNetForQuestionAnswering,
          TFMPNetForSequenceClassification,
          TFMPNetForTokenClassification,
          TFMPNetModel,
      )



class     snake_case_			:






   def __init__( self							:	Optional[Any]      ,		lowercase_							:	Tuple      ,		lowercase_							:	List[str]=13      ,		lowercase_							:	str=7      ,		lowercase_							:	str=True      ,		lowercase_							:	Dict=True      ,		lowercase_							:	List[str]=False      ,		lowercase_							:	Optional[Any]=True      ,		lowercase_							:	List[str]=99      ,		lowercase_							:	Optional[int]=64      ,		lowercase_							:	Optional[int]=2      ,		lowercase_							:	List[Any]=4      ,		lowercase_							:	Union[str, Any]=64      ,		lowercase_							:	Optional[Any]="gelu"      ,		lowercase_							:	str=0.1      ,		lowercase_							:	Union[str, Any]=0.1      ,		lowercase_							:	Optional[Any]=5_12      ,		lowercase_							:	Optional[Any]=16      ,		lowercase_							:	Optional[Any]=2      ,		lowercase_							:	Any=0.02      ,		lowercase_							:	List[Any]=3      ,		lowercase_							:	List[str]=4      ,		lowercase_							:	Union[str, Any]=None      ,		)   ->		Optional[int]:
       lowercase__					:  str          =							parent
       lowercase__					:  List[str]          =							batch_size
       lowercase__					:  Optional[int]          =							seq_length
       lowercase__					:  List[str]          =							is_training
       lowercase__					:  Union[str, Any]          =							use_input_mask
       lowercase__					:  Tuple          =							use_token_type_ids
       lowercase__					:  str          =							use_labels
       lowercase__					:  int          =							vocab_size
       lowercase__					:  Optional[Any]          =							hidden_size
       lowercase__					:  Dict          =							num_hidden_layers
       lowercase__					:  Any          =							num_attention_heads
       lowercase__					:  Dict          =							intermediate_size
       lowercase__					:  List[Any]          =							hidden_act
       lowercase__					:  int          =							hidden_dropout_prob
       lowercase__					:  Dict          =							attention_probs_dropout_prob
       lowercase__					:  Union[str, Any]          =							max_position_embeddings
       lowercase__					:  List[Any]          =							type_vocab_size
       lowercase__					:  str          =							type_sequence_label_size
       lowercase__					:  Union[str, Any]          =							initializer_range
       lowercase__					:  str          =							num_labels
       lowercase__					:  List[Any]          =							num_choices
       lowercase__					:  List[str]          =							scope






   def  __UpperCamelCase	( self							:	Dict    )   ->		Tuple:
       lowercase__					:  int          =							ids_tensor([self.batch_size, self.seq_length]      ,		self.vocab_size    )

       lowercase__					:  List[str]          =							None
       if self.use_input_mask:
           lowercase__					:  str          =							random_attention_mask([self.batch_size, self.seq_length]    )

       lowercase__					:  Any          =							None
       lowercase__					:  Optional[Any]          =							None
       lowercase__					:  Optional[int]          =							None
       if self.use_labels:
           lowercase__					:  str          =							ids_tensor([self.batch_size]      ,		self.type_sequence_label_size    )
           lowercase__					:  Optional[Any]          =							ids_tensor([self.batch_size, self.seq_length]      ,		self.num_labels    )
           lowercase__					:  Any          =							ids_tensor([self.batch_size]      ,		self.num_choices    )

       lowercase__					:  Any          =							MPNetConfig(
           vocab_size=self.vocab_size      ,		hidden_size=self.hidden_size      ,		num_hidden_layers=self.num_hidden_layers      ,		num_attention_heads=self.num_attention_heads      ,		intermediate_size=self.intermediate_size      ,		hidden_act=self.hidden_act      ,		hidden_dropout_prob=self.hidden_dropout_prob      ,		attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,		max_position_embeddings=self.max_position_embeddings      ,		initializer_range=self.initializer_range      ,		)
       return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels






   def  __UpperCamelCase	( self							:	int      ,		lowercase_							:	Optional[Any]      ,		lowercase_							:	Union[str, Any]      ,		lowercase_							:	Any      ,		lowercase_							:	Optional[Any]      ,		lowercase_							:	Any      ,		lowercase_							:	List[Any]    )   ->		List[str]:
       lowercase__					:  int          =							TFMPNetModel(config=lowercase_    )
       lowercase__					:  Dict          =							{"input_ids": input_ids, "attention_mask": input_mask}
       lowercase__					:  Dict          =							model(lowercase_    )
       lowercase__					:  Tuple          =							[input_ids, input_mask]
       lowercase__					:  Any          =							model(lowercase_    )
       self.parent.assertEqual(result.last_hidden_state.shape      ,		(self.batch_size, self.seq_length, self.hidden_size)    )






   def  __UpperCamelCase	( self							:	List[Any]      ,		lowercase_							:	Optional[int]      ,		lowercase_							:	Tuple      ,		lowercase_							:	str      ,		lowercase_							:	Union[str, Any]      ,		lowercase_							:	Union[str, Any]      ,		lowercase_							:	List[Any]    )   ->		Union[str, Any]:
       lowercase__					:  List[str]          =							TFMPNetForMaskedLM(config=lowercase_    )
       lowercase__					:  Dict          =							{"input_ids": input_ids, "attention_mask": input_mask}
       lowercase__					:  Optional[int]          =							model(lowercase_    )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length, self.vocab_size)    )






   def  __UpperCamelCase	( self							:	Optional[Any]      ,		lowercase_							:	List[Any]      ,		lowercase_							:	Union[str, Any]      ,		lowercase_							:	Dict      ,		lowercase_							:	Tuple      ,		lowercase_							:	Tuple      ,		lowercase_							:	Optional[Any]    )   ->		List[Any]:
       lowercase__					:  List[Any]          =							TFMPNetForQuestionAnswering(config=lowercase_    )
       lowercase__					:  Optional[int]          =							{
           "input_ids": input_ids,
           "attention_mask": input_mask,
       }
       lowercase__					:  int          =							model(lowercase_    )
       self.parent.assertEqual(result.start_logits.shape      ,		(self.batch_size, self.seq_length)    )
       self.parent.assertEqual(result.end_logits.shape      ,		(self.batch_size, self.seq_length)    )






   def  __UpperCamelCase	( self							:	Union[str, Any]      ,		lowercase_							:	List[str]      ,		lowercase_							:	List[Any]      ,		lowercase_							:	Tuple      ,		lowercase_							:	Optional[Any]      ,		lowercase_							:	Optional[int]      ,		lowercase_							:	Any    )   ->		int:
       lowercase__					:  Optional[Any]          =							self.num_labels
       lowercase__					:  int          =							TFMPNetForSequenceClassification(lowercase_    )
       lowercase__					:  Any          =							{"input_ids": input_ids, "attention_mask": input_mask}
       lowercase__					:  Optional[Any]          =							model(lowercase_    )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.num_labels)    )






   def  __UpperCamelCase	( self							:	List[str]      ,		lowercase_							:	int      ,		lowercase_							:	Optional[int]      ,		lowercase_							:	Union[str, Any]      ,		lowercase_							:	Optional[Any]      ,		lowercase_							:	List[str]      ,		lowercase_							:	List[str]    )   ->		Optional[int]:
       lowercase__					:  List[Any]          =							self.num_choices
       lowercase__					:  List[str]          =							TFMPNetForMultipleChoice(lowercase_    )
       lowercase__					:  Tuple          =							tf.tile(tf.expand_dims(lowercase_      ,		1    )      ,		(1, self.num_choices, 1)    )
       lowercase__					:  List[str]          =							tf.tile(tf.expand_dims(lowercase_      ,		1    )      ,		(1, self.num_choices, 1)    )
       lowercase__					:  Tuple          =							{
           "input_ids": multiple_choice_inputs_ids,
           "attention_mask": multiple_choice_input_mask,
       }
       lowercase__					:  List[str]          =							model(lowercase_    )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.num_choices)    )






   def  __UpperCamelCase	( self							:	Tuple      ,		lowercase_							:	Tuple      ,		lowercase_							:	str      ,		lowercase_							:	List[Any]      ,		lowercase_							:	str      ,		lowercase_							:	str      ,		lowercase_							:	Tuple    )   ->		int:
       lowercase__					:  Dict          =							self.num_labels
       lowercase__					:  int          =							TFMPNetForTokenClassification(lowercase_    )
       lowercase__					:  List[str]          =							{"input_ids": input_ids, "attention_mask": input_mask}
       lowercase__					:  Dict          =							model(lowercase_    )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length, self.num_labels)    )







   def  __UpperCamelCase	( self							:	List[Any]    )   ->		List[str]:
       lowercase__					:  int          =							self.prepare_config_and_inputs()
       ((lowercase__)   ,  (lowercase__)   ,  (lowercase__)   ,  (lowercase__)   ,  (lowercase__)   ,  (lowercase__))					:  str          =							config_and_inputs
       lowercase__					:  Union[str, Any]          =							{"input_ids": input_ids, "attention_mask": input_mask}
       return config, inputs_dict



@require_tf
class     snake_case_			(						__A    ,__A    ,unittest.TestCase			):
   __A      :						List[str]   =							(
       (
           TFMPNetForMaskedLM,
           TFMPNetForMultipleChoice,
           TFMPNetForQuestionAnswering,
           TFMPNetForSequenceClassification,
           TFMPNetForTokenClassification,
           TFMPNetModel,
       )
       if is_tf_available()
       else ()
   )
   __A      :						int   =							(
       {
           "feature-extraction": TFMPNetModel,
           "fill-mask": TFMPNetForMaskedLM,
           "question-answering": TFMPNetForQuestionAnswering,
           "text-classification": TFMPNetForSequenceClassification,
           "token-classification": TFMPNetForTokenClassification,
           "zero-shot": TFMPNetForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   __A      :						str   =							False
   __A      :						Union[str, Any]   =							False






   def  __UpperCamelCase	( self							:	List[Any]    )   ->		List[str]:
       lowercase__					:  Optional[int]          =							TFMPNetModelTester(self    )
       lowercase__					:  List[Any]          =							ConfigTester(self      ,		config_class=lowercase_      ,		hidden_size=37    )






   def  __UpperCamelCase	( self							:	int    )   ->		Dict:
       self.config_tester.run_common_tests()






   def  __UpperCamelCase	( self							:	Any    )   ->		Any:
       lowercase__					:  Tuple          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_model(*lowercase_    )






   def  __UpperCamelCase	( self							:	Optional[Any]    )   ->		Dict:
       lowercase__					:  str          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_for_masked_lm(*lowercase_    )






   def  __UpperCamelCase	( self							:	Optional[int]    )   ->		Any:
       lowercase__					:  Optional[Any]          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_for_question_answering(*lowercase_    )






   def  __UpperCamelCase	( self							:	int    )   ->		List[Any]:
       lowercase__					:  Dict          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_for_sequence_classification(*lowercase_    )






   def  __UpperCamelCase	( self							:	Dict    )   ->		Any:
       lowercase__					:  List[Any]          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_for_multiple_choice(*lowercase_    )






   def  __UpperCamelCase	( self							:	List[Any]    )   ->		Dict:
       lowercase__					:  List[Any]          =							self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_mpnet_for_token_classification(*lowercase_    )







   @slow
   def  __UpperCamelCase	( self							:	Dict    )   ->		int:
       for model_name in ["microsoft/mpnet-base"]:
           lowercase__					:  List[str]          =							TFMPNetModel.from_pretrained(lowercase_    )
           self.assertIsNotNone(lowercase_    )



@require_tf
class     snake_case_			(						unittest.TestCase			):






   @slow
   def  __UpperCamelCase	( self							:	int    )   ->		List[Any]:
       lowercase__					:  Optional[Any]          =							TFMPNetModel.from_pretrained("microsoft/mpnet-base"    )
       lowercase__					:  Tuple          =							tf.constant([[0, 1, 2, 3, 4, 5]]    )
       lowercase__					:  List[str]          =							model(lowercase_    )[0]

       lowercase__					:  List[Any]          =							[1, 6, 7_68]
       self.assertEqual(output.shape      ,		lowercase_    )

       lowercase__					:  Optional[int]          =							tf.constant(
           [
               [
                   [-0.1_06_71_72, 0.08_21_64_73, 0.0_02_45_43],
                   [-0.03_46_58_79, 0.8_35_41_18, -0.03_25_22_88],
                   [-0.06_56_94_76, -0.12_42_41_11, -0.0_49_44_36],
               ]
           ]    )
       tf.debugging.assert_near(output[:, :3, :3]      ,		lowercase_      ,		atol=1E-4    )



