code: 
  
  
  '''simple docstring'''
  
  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 _lowerCamelCase :
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		def __init__(      self	:		Union[str, Any]						,  _A	:		Optional[Any]						,  _A	:		Tuple=13						,  _A	:		Tuple=7						,  _A	:		Tuple=True						,  _A	:		Union[str, Any]=True						,  _A	:		List[Any]=False						,  _A	:		Tuple=True						,  _A	:		Optional[int]=99						,  _A	:		str=64						,  _A	:		Tuple=2						,  _A	:		Union[str, Any]=4						,  _A	:		Union[str, Any]=64						,  _A	:		Any="gelu"						,  _A	:		str=0.1						,  _A	:		str=0.1						,  _A	:		Any=512						,  _A	:		str=16						,  _A	:		Tuple=2						,  _A	:		int=0.02						,  _A	:		List[str]=3						,  _A	:		str=4						,  _A	:		List[Any]=None						,  )						->				Optional[int]:
  			__magic_name__ :					Optional[int]  			=  parent
  			__magic_name__ :					Any  			=  batch_size
  			__magic_name__ :					Optional[Any]  			=  seq_length
  			__magic_name__ :					Dict  			=  is_training
  			__magic_name__ :					Union[str, Any]  			=  use_input_mask
  			__magic_name__ :					List[Any]  			=  use_token_type_ids
  			__magic_name__ :					Dict  			=  use_labels
  			__magic_name__ :					List[str]  			=  vocab_size
  			__magic_name__ :					int  			=  hidden_size
  			__magic_name__ :					Union[str, Any]  			=  num_hidden_layers
  			__magic_name__ :					Optional[Any]  			=  num_attention_heads
  			__magic_name__ :					Any  			=  intermediate_size
  			__magic_name__ :					Union[str, Any]  			=  hidden_act
  			__magic_name__ :					int  			=  hidden_dropout_prob
  			__magic_name__ :					Optional[int]  			=  attention_probs_dropout_prob
  			__magic_name__ :					Any  			=  max_position_embeddings
  			__magic_name__ :					int  			=  type_vocab_size
  			__magic_name__ :					Any  			=  type_sequence_label_size
  			__magic_name__ :					Any  			=  initializer_range
  			__magic_name__ :					List[Any]  			=  num_labels
  			__magic_name__ :					Tuple  			=  num_choices
  			__magic_name__ :					Dict  			=  scope
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Tuple    )						->				Tuple:
  			__magic_name__ :					Union[str, Any]  			=  ids_tensor([self.batch_size, self.seq_length]						,  self.vocab_size    )
  
  			__magic_name__ :					Tuple  			=  None
  			if self.use_input_mask:
  				__magic_name__ :					Dict  			=  random_attention_mask([self.batch_size, self.seq_length]    )
  
  			__magic_name__ :					Any  			=  None
  			__magic_name__ :					Dict  			=  None
  			__magic_name__ :					Dict  			=  None
  			if self.use_labels:
  				__magic_name__ :					Optional[Any]  			=  ids_tensor([self.batch_size]						,  self.type_sequence_label_size    )
  				__magic_name__ :					Any  			=  ids_tensor([self.batch_size, self.seq_length]						,  self.num_labels    )
  				__magic_name__ :					Union[str, Any]  			=  ids_tensor([self.batch_size]						,  self.num_choices    )
  
  			__magic_name__ :					List[str]  			=  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      __lowerCAmelCase	(      self	:		Dict						,  _A	:		Dict						,  _A	:		List[Any]						,  _A	:		Tuple						,  _A	:		List[Any]						,  _A	:		int						,  _A	:		List[Any]    )						->				List[Any]:
  			__magic_name__ :					str  			=  TFMPNetModel(config=_A    )
  			__magic_name__ :					Optional[Any]  			=  {'input_ids': input_ids, 'attention_mask': input_mask}
  			__magic_name__ :					Tuple  			=  model(_A    )
  			__magic_name__ :					str  			=  [input_ids, input_mask]
  			__magic_name__ :					List[Any]  			=  model(_A    )
  			self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.hidden_size)    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		List[str]						,  _A	:		Optional[int]						,  _A	:		int						,  _A	:		List[Any]						,  _A	:		Dict						,  _A	:		Dict						,  _A	:		int    )						->				Dict:
  			__magic_name__ :					List[Any]  			=  TFMPNetForMaskedLM(config=_A    )
  			__magic_name__ :					int  			=  {'input_ids': input_ids, 'attention_mask': input_mask}
  			__magic_name__ :					List[Any]  			=  model(_A    )
  			self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length, self.vocab_size)    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Optional[Any]						,  _A	:		Optional[Any]						,  _A	:		Any						,  _A	:		str						,  _A	:		Optional[Any]						,  _A	:		Dict						,  _A	:		List[str]    )						->				int:
  			__magic_name__ :					List[Any]  			=  TFMPNetForQuestionAnswering(config=_A    )
  			__magic_name__ :					str  			=  {
  			    'input_ids': input_ids,
  			    'attention_mask': input_mask,
  			}
  			__magic_name__ :					List[Any]  			=  model(_A    )
  			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      __lowerCAmelCase	(      self	:		List[str]						,  _A	:		Union[str, Any]						,  _A	:		Union[str, Any]						,  _A	:		List[Any]						,  _A	:		Optional[Any]						,  _A	:		Union[str, Any]						,  _A	:		Union[str, Any]    )						->				List[Any]:
  			__magic_name__ :					Tuple  			=  self.num_labels
  			__magic_name__ :					str  			=  TFMPNetForSequenceClassification(_A    )
  			__magic_name__ :					Tuple  			=  {'input_ids': input_ids, 'attention_mask': input_mask}
  			__magic_name__ :					Dict  			=  model(_A    )
  			self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.num_labels)    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		List[str]						,  _A	:		Union[str, Any]						,  _A	:		Optional[Any]						,  _A	:		List[str]						,  _A	:		Union[str, Any]						,  _A	:		Dict						,  _A	:		Optional[Any]    )						->				int:
  			__magic_name__ :					List[str]  			=  self.num_choices
  			__magic_name__ :					Optional[int]  			=  TFMPNetForMultipleChoice(_A    )
  			__magic_name__ :					Union[str, Any]  			=  tf.tile(tf.expand_dims(_A						,  1    )						,  (1, self.num_choices, 1)    )
  			__magic_name__ :					int  			=  tf.tile(tf.expand_dims(_A						,  1    )						,  (1, self.num_choices, 1)    )
  			__magic_name__ :					Tuple  			=  {
  			    'input_ids': multiple_choice_inputs_ids,
  			    'attention_mask': multiple_choice_input_mask,
  			}
  			__magic_name__ :					Dict  			=  model(_A    )
  			self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.num_choices)    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		List[str]						,  _A	:		Tuple						,  _A	:		List[Any]						,  _A	:		Tuple						,  _A	:		Dict						,  _A	:		Dict						,  _A	:		Union[str, Any]    )						->				Any:
  			__magic_name__ :					List[Any]  			=  self.num_labels
  			__magic_name__ :					List[str]  			=  TFMPNetForTokenClassification(_A    )
  			__magic_name__ :					Tuple  			=  {'input_ids': input_ids, 'attention_mask': input_mask}
  			__magic_name__ :					Tuple  			=  model(_A    )
  			self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length, self.num_labels)    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Optional[Any]    )						->				Union[str, Any]:
  			__magic_name__ :					Dict  			=  self.prepare_config_and_inputs()
  			((__magic_name__)			,       (__magic_name__)			,       (__magic_name__)			,       (__magic_name__)			,       (__magic_name__)			,       (__magic_name__)) :					Union[str, Any]  			=  config_and_inputs
  			__magic_name__ :					List[Any]  			=  {'input_ids': input_ids, 'attention_mask': input_mask}
  			return config, inputs_dict
  
  
  
  
  
  
  
  @require_tf
  class _lowerCamelCase (		lowercase__	,  lowercase__	,  unittest.TestCase							):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		A_			:    str   					=       (
  		    (
  		        TFMPNetForMaskedLM,
  		        TFMPNetForMultipleChoice,
  		        TFMPNetForQuestionAnswering,
  		        TFMPNetForSequenceClassification,
  		        TFMPNetForTokenClassification,
  		        TFMPNetModel,
  		    )
  		    if is_tf_available()
  		    else ()
  		)
  		A_			:    Union[str, Any]   					=       (
  		    {
  		        """feature-extraction""": TFMPNetModel,
  		        """fill-mask""": TFMPNetForMaskedLM,
  		        """question-answering""": TFMPNetForQuestionAnswering,
  		        """text-classification""": TFMPNetForSequenceClassification,
  		        """token-classification""": TFMPNetForTokenClassification,
  		        """zero-shot""": TFMPNetForSequenceClassification,
  		    }
  		    if is_tf_available()
  		    else {}
  		)
  		A_			:    Dict   					=       False
  		A_			:    Any   					=       False
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		str    )						->				List[str]:
  			__magic_name__ :					Optional[int]  			=  TFMPNetModelTester(self    )
  			__magic_name__ :					str  			=  ConfigTester(self						,  config_class=_A						,  hidden_size=37    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Union[str, Any]    )						->				Tuple:
  			self.config_tester.run_common_tests()
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Union[str, Any]    )						->				Any:
  			__magic_name__ :					Optional[int]  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_model(*_A    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Union[str, Any]    )						->				Optional[Any]:
  			__magic_name__ :					Dict  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_for_masked_lm(*_A    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Optional[int]    )						->				Union[str, Any]:
  			__magic_name__ :					int  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_for_question_answering(*_A    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Dict    )						->				Tuple:
  			__magic_name__ :					Any  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_for_sequence_classification(*_A    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Union[str, Any]    )						->				int:
  			__magic_name__ :					Union[str, Any]  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_for_multiple_choice(*_A    )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Tuple    )						->				Optional[Any]:
  			__magic_name__ :					Tuple  			=  self.model_tester.prepare_config_and_inputs()
  			self.model_tester.create_and_check_mpnet_for_token_classification(*_A    )
  
  
  
  
  
  
  
  		@slow
  		def      __lowerCAmelCase	(      self	:		str    )						->				List[str]:
  			for model_name in ["microsoft/mpnet-base"]:
  				__magic_name__ :					Optional[int]  			=  TFMPNetModel.from_pretrained(_A    )
  				self.assertIsNotNone(_A    )
  
  
  
  
  
  
  
  @require_tf
  class _lowerCamelCase (		unittest.TestCase							):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		@slow
  		def      __lowerCAmelCase	(      self	:		Tuple    )						->				List[str]:
  			__magic_name__ :					Tuple  			=  TFMPNetModel.from_pretrained('microsoft/mpnet-base'    )
  			__magic_name__ :					List[str]  			=  tf.constant([[0, 1, 2, 3, 4, 5]]    )
  			__magic_name__ :					int  			=  model(_A    )[0]
  
  			__magic_name__ :					List[str]  			=  [1, 6, 768]
  			self.assertEqual(output.shape						,  _A    )
  
  			__magic_name__ :					Union[str, Any]  			=  tf.constant(
  			    [
  			        [
  			            [-0.106_7172, 0.0821_6473, 0.002_4543],
  			            [-0.0346_5879, 0.835_4118, -0.0325_2288],
  			            [-0.0656_9476, -0.1242_4111, -0.049_4436],
  			        ]
  			    ]    )
  			tf.debugging.assert_near(output[:, :3, :3]						,  _A						,  atol=1E-4    )
style_context: 
  
  
  '''simple docstring'''
  
  from sklearn.metrics import mean_absolute_error
  
  import datasets
  
  
  lowerCAmelCase   :Union[str, Any]								=    '''\
  @article{scikit-learn,
   title={Scikit-learn: Machine Learning in {P}ython},
   author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.
           and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.
           and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and
           Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},
   journal={Journal of Machine Learning Research},
   volume={12},
   pages={2825--2830},
   year={2011}
  }
  '''
  
  lowerCAmelCase   :int								=    '''\
  Mean Absolute Error (MAE) is the mean of the magnitude of difference between the predicted and actual
  values.
  '''
  
  
  lowerCAmelCase   :Optional[int]								=    '''
  Args:
      predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)
          Estimated target values.
      references: array-like of shape (n_samples,) or (n_samples, n_outputs)
          Ground truth (correct) target values.
      sample_weight: array-like of shape (n_samples,), default=None
          Sample weights.
      multioutput: {"raw_values", "uniform_average"} or array-like of shape (n_outputs,), default="uniform_average"
          Defines aggregating of multiple output values. Array-like value defines weights used to average errors.
  
                   "raw_values" : Returns a full set of errors in case of multioutput input.
  
                   "uniform_average" : Errors of all outputs are averaged with uniform weight.
  
  Returns:
      mae : mean absolute error.
          If multioutput is "raw_values", then mean absolute error is returned for each output separately. If multioutput is "uniform_average" or an ndarray of weights, then the weighted average of all output errors is returned.
          MAE output is non-negative floating point. The best value is 0.0.
  Examples:
  
      >>> mae_metric = datasets.load_metric("mae")
      >>> predictions = [2.5, 0.0, 2, 8]
      >>> references = [3, -0.5, 2, 7]
      >>> results = mae_metric.compute(predictions=predictions, references=references)
      >>> print(results)
      {\'mae\': 0.5}
  
      If you\'re using multi-dimensional lists, then set the config as follows :
  
      >>> mae_metric = datasets.load_metric("mae", "multilist")
      >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]
      >>> references = [[0, 2], [-1, 2], [8, -5]]
      >>> results = mae_metric.compute(predictions=predictions, references=references)
      >>> print(results)
      {\'mae\': 0.75}
      >>> results = mae_metric.compute(predictions=predictions, references=references, multioutput=\'raw_values\')
      >>> print(results)
      {\'mae\': array([0.5, 1. ])}
  '''
  @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION	,  _KWARGS_DESCRIPTION							)
  class _lowerCamelCase (		datasets.Metric							):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Union[str, Any]    )						->				int:
  			return datasets.MetricInfo(
  			    description=_DESCRIPTION						,  citation=_CITATION						,  inputs_description=_KWARGS_DESCRIPTION						,  features=datasets.Features(self._get_feature_types()    )						,  reference_urls=[
  			        'https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_absolute_error.html'
  			    ]						,  )
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Tuple    )						->				List[str]:
  			if self.config_name == "multilist":
  				return {
  				    "predictions": datasets.Sequence(datasets.Value('float'    )    ),
  				    "references": datasets.Sequence(datasets.Value('float'    )    ),
  				}
  			else:
  				return {
  				    "predictions": datasets.Value('float'    ),
  				    "references": datasets.Value('float'    ),
  				}
  
  
  
  
  
  
  
  		def      __lowerCAmelCase	(      self	:		Dict						,  _A	:		Optional[int]						,  _A	:		Optional[Any]						,  _A	:		Optional[Any]=None						,  _A	:		Tuple="uniform_average"    )						->				Any:
  			__magic_name__ :					Optional[Any]  			=  mean_absolute_error(_A						,  _A						,  sample_weight=_A						,  multioutput=_A    )
  
  			return {"mae": mae_score}