





"""simple docstring"""





import os
import tempfile
import unittest

from transformers import FlaubertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

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


if is_torch_available():
  import torch

  from transformers import (
      FlaubertForMultipleChoice,
      FlaubertForQuestionAnswering,
      FlaubertForQuestionAnsweringSimple,
      FlaubertForSequenceClassification,
      FlaubertForTokenClassification,
      FlaubertModel,
      FlaubertWithLMHeadModel,
  )
  from transformers.models.flaubert.modeling_flaubert import FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST






class    _lowerCAmelCase  (	a			):
       """simple docstring"""




       def __init__(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase=1_3       ,					__UpperCAmelCase=7       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=False       ,					__UpperCAmelCase=2       ,					__UpperCAmelCase=9_9       ,					__UpperCAmelCase=0       ,					__UpperCAmelCase=3_2       ,					__UpperCAmelCase=5       ,					__UpperCAmelCase=4       ,					__UpperCAmelCase=0.1       ,					__UpperCAmelCase=0.1       ,					__UpperCAmelCase=5_1_2       ,					__UpperCAmelCase=1_2       ,					__UpperCAmelCase=2       ,					__UpperCAmelCase=0.02       ,					__UpperCAmelCase=3       ,					__UpperCAmelCase=4       ,					__UpperCAmelCase="last"       ,					__UpperCAmelCase=None       ,					__UpperCAmelCase=None       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :Tuple											=				parent
         lowerCAmelCase__     :Optional[Any]											=				batch_size
         lowerCAmelCase__     :Dict											=				seq_length
         lowerCAmelCase__     :Optional[int]											=				is_training
         lowerCAmelCase__     :Tuple											=				use_input_lengths
         lowerCAmelCase__     :List[str]											=				use_token_type_ids
         lowerCAmelCase__     :str											=				use_labels
         lowerCAmelCase__     :List[str]											=				gelu_activation
         lowerCAmelCase__     :List[Any]											=				sinusoidal_embeddings
         lowerCAmelCase__     :Any											=				causal
         lowerCAmelCase__     :Union[str, Any]											=				asm
         lowerCAmelCase__     :int											=				n_langs
         lowerCAmelCase__     :Any											=				vocab_size
         lowerCAmelCase__     :List[Any]											=				n_special
         lowerCAmelCase__     :int											=				hidden_size
         lowerCAmelCase__     :Tuple											=				num_hidden_layers
         lowerCAmelCase__     :str											=				num_attention_heads
         lowerCAmelCase__     :str											=				hidden_dropout_prob
         lowerCAmelCase__     :Optional[Any]											=				attention_probs_dropout_prob
         lowerCAmelCase__     :Dict											=				max_position_embeddings
         lowerCAmelCase__     :Optional[int]											=				type_vocab_size
         lowerCAmelCase__     :str											=				type_sequence_label_size
         lowerCAmelCase__     :str											=				initializer_range
         lowerCAmelCase__     :Optional[Any]											=				num_labels
         lowerCAmelCase__     :List[Any]											=				num_choices
         lowerCAmelCase__     :str											=				summary_type
         lowerCAmelCase__     :Tuple											=				use_proj
         lowerCAmelCase__     :Tuple											=				scope






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :int											=				ids_tensor([self.batch_size, self.seq_length]       ,					self.vocab_size )
         lowerCAmelCase__     :Union[str, Any]											=				random_attention_mask([self.batch_size, self.seq_length] )

         lowerCAmelCase__     :Union[str, Any]											=				None
         if self.use_input_lengths:
           lowerCAmelCase__     :Any											=				(
               ids_tensor([self.batch_size]       ,					vocab_size=2 ) + self.seq_length - 2
           )  # small variation of seq_length

         lowerCAmelCase__     :str											=				None
         if self.use_token_type_ids:
           lowerCAmelCase__     :str											=				ids_tensor([self.batch_size, self.seq_length]       ,					self.n_langs )

         lowerCAmelCase__     :List[Any]											=				None
         lowerCAmelCase__     :Tuple											=				None
         lowerCAmelCase__     :str											=				None
         if self.use_labels:
           lowerCAmelCase__     :Dict											=				ids_tensor([self.batch_size]       ,					self.type_sequence_label_size )
           lowerCAmelCase__     :Optional[Any]											=				ids_tensor([self.batch_size, self.seq_length]       ,					self.num_labels )
           lowerCAmelCase__     :Tuple											=				ids_tensor([self.batch_size]       ,					2 ).float()
           lowerCAmelCase__     :List[str]											=				ids_tensor([self.batch_size]       ,					self.num_choices )

         lowerCAmelCase__     :Dict											=				self.get_config()

         return (
             config,
             input_ids,
             token_type_ids,
             input_lengths,
             sequence_labels,
             token_labels,
             is_impossible_labels,
             choice_labels,
             input_mask,
         )






       def 	snake_case		(       self ):



         '''simple docstring'''

         return FlaubertConfig(
             vocab_size=self.vocab_size       ,					n_special=self.n_special       ,					emb_dim=self.hidden_size       ,					n_layers=self.num_hidden_layers       ,					n_heads=self.num_attention_heads       ,					dropout=self.hidden_dropout_prob       ,					attention_dropout=self.attention_probs_dropout_prob       ,					gelu_activation=self.gelu_activation       ,					sinusoidal_embeddings=self.sinusoidal_embeddings       ,					asm=self.asm       ,					causal=self.causal       ,					n_langs=self.n_langs       ,					max_position_embeddings=self.max_position_embeddings       ,					initializer_range=self.initializer_range       ,					summary_type=self.summary_type       ,					use_proj=self.use_proj       ,					)






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				FlaubertModel(config=__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()
         lowerCAmelCase__     :Any											=				model(__UpperCAmelCase       ,					lengths=__UpperCAmelCase       ,					langs=__UpperCAmelCase )
         lowerCAmelCase__     :Dict											=				model(__UpperCAmelCase       ,					langs=__UpperCAmelCase )
         lowerCAmelCase__     :Dict											=				model(__UpperCAmelCase )
         self.parent.assertEqual(result.last_hidden_state.shape       ,					(self.batch_size, self.seq_length, self.hidden_size) )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :int											=				FlaubertWithLMHeadModel(__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()

         lowerCAmelCase__     :List[Any]											=				model(__UpperCAmelCase       ,					token_type_ids=__UpperCAmelCase       ,					labels=__UpperCAmelCase )
         self.parent.assertEqual(result.loss.shape       ,					() )
         self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.seq_length, self.vocab_size) )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :str											=				FlaubertForQuestionAnsweringSimple(__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()

         lowerCAmelCase__     :List[Any]											=				model(__UpperCAmelCase )

         lowerCAmelCase__     :int											=				model(__UpperCAmelCase       ,					start_positions=__UpperCAmelCase       ,					end_positions=__UpperCAmelCase )
         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 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				FlaubertForQuestionAnswering(__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()

         lowerCAmelCase__     :Any											=				model(__UpperCAmelCase )

         lowerCAmelCase__     :Optional[int]											=				model(
             __UpperCAmelCase       ,					start_positions=__UpperCAmelCase       ,					end_positions=__UpperCAmelCase       ,					cls_index=__UpperCAmelCase       ,					is_impossible=__UpperCAmelCase       ,					p_mask=__UpperCAmelCase       ,					)

         lowerCAmelCase__     :Union[str, Any]											=				model(
             __UpperCAmelCase       ,					start_positions=__UpperCAmelCase       ,					end_positions=__UpperCAmelCase       ,					cls_index=__UpperCAmelCase       ,					is_impossible=__UpperCAmelCase       ,					)

         ((lowerCAmelCase__)				,							)     :Dict											=				result_with_labels.to_tuple()

         lowerCAmelCase__     :List[Any]											=				model(__UpperCAmelCase       ,					start_positions=__UpperCAmelCase       ,					end_positions=__UpperCAmelCase )

         ((lowerCAmelCase__)				,							)     :int											=				result_with_labels.to_tuple()

         self.parent.assertEqual(result_with_labels.loss.shape       ,					() )
         self.parent.assertEqual(result.start_top_log_probs.shape       ,					(self.batch_size, model.config.start_n_top) )
         self.parent.assertEqual(result.start_top_index.shape       ,					(self.batch_size, model.config.start_n_top) )
         self.parent.assertEqual(
             result.end_top_log_probs.shape       ,					(self.batch_size, model.config.start_n_top * model.config.end_n_top) )
         self.parent.assertEqual(
             result.end_top_index.shape       ,					(self.batch_size, model.config.start_n_top * model.config.end_n_top) )
         self.parent.assertEqual(result.cls_logits.shape       ,					(self.batch_size,) )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				FlaubertForSequenceClassification(__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()

         lowerCAmelCase__     :Dict											=				model(__UpperCAmelCase )
         lowerCAmelCase__     :Optional[Any]											=				model(__UpperCAmelCase       ,					labels=__UpperCAmelCase )

         self.parent.assertEqual(result.loss.shape       ,					() )
         self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.type_sequence_label_size) )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :int											=				self.num_labels
         lowerCAmelCase__     :Dict											=				FlaubertForTokenClassification(__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()

         lowerCAmelCase__     :List[str]											=				model(__UpperCAmelCase       ,					attention_mask=__UpperCAmelCase       ,					labels=__UpperCAmelCase )
         self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.seq_length, self.num_labels) )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				self.num_choices
         lowerCAmelCase__     :Union[str, Any]											=				FlaubertForMultipleChoice(config=__UpperCAmelCase )
         model.to(__UpperCAmelCase )
         model.eval()
         lowerCAmelCase__     :int											=				input_ids.unsqueeze(1 ).expand(-1       ,					self.num_choices       ,					-1 ).contiguous()
         lowerCAmelCase__     :Dict											=				token_type_ids.unsqueeze(1 ).expand(-1       ,					self.num_choices       ,					-1 ).contiguous()
         lowerCAmelCase__     :Optional[int]											=				input_mask.unsqueeze(1 ).expand(-1       ,					self.num_choices       ,					-1 ).contiguous()
         lowerCAmelCase__     :List[Any]											=				model(
             __UpperCAmelCase       ,					attention_mask=__UpperCAmelCase       ,					token_type_ids=__UpperCAmelCase       ,					labels=__UpperCAmelCase       ,					)
         self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.num_choices) )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				self.prepare_config_and_inputs()
         (
             (
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							(
             lowerCAmelCase__
         )				,							
         )     :List[Any]											=				config_and_inputs
         lowerCAmelCase__     :Union[str, Any]											=				{
             'input_ids': input_ids,
             'token_type_ids': token_type_ids,
             'lengths': input_lengths,
             'attention_mask': input_mask,
         }
         return config, inputs_dict






@require_torch
class    _lowerCAmelCase  (	a    ,  a    ,  unittest.TestCase			):
       """simple docstring"""




       __magic_name__	:Optional[int]						    =   (
           (
               FlaubertModel,
               FlaubertWithLMHeadModel,
               FlaubertForQuestionAnswering,
               FlaubertForQuestionAnsweringSimple,
               FlaubertForSequenceClassification,
               FlaubertForTokenClassification,
               FlaubertForMultipleChoice,
           )
           if is_torch_available()
           else ()
       )
       __magic_name__	:List[str]						    =   (
           {
               """feature-extraction""": FlaubertModel,
               """fill-mask""": FlaubertWithLMHeadModel,
               """question-answering""": FlaubertForQuestionAnsweringSimple,
               """text-classification""": FlaubertForSequenceClassification,
               """token-classification""": FlaubertForTokenClassification,
               """zero-shot""": FlaubertForSequenceClassification,
           }
           if is_torch_available()
           else {}
       )






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase ):



         '''simple docstring'''

         if (
             pipeline_test_casse_name == "QAPipelineTests"
             and tokenizer_name is not None
             and not tokenizer_name.endswith('Fast' )
         ):
           # `QAPipelineTests` fails for a few models when the slower tokenizer are used.
           # (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
           # TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
           return True

         return False






       def 	snake_case		(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase       ,					__UpperCAmelCase=False ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[Any]											=				super()._prepare_for_class(__UpperCAmelCase       ,					__UpperCAmelCase       ,					return_labels=__UpperCAmelCase )

         if return_labels:
           if model_class.__name__ == "FlaubertForQuestionAnswering":
             lowerCAmelCase__     :List[Any]											=				torch.zeros(
                 self.model_tester.batch_size       ,					dtype=torch.long       ,					device=__UpperCAmelCase )
             lowerCAmelCase__     :Any											=				torch.zeros(
                 self.model_tester.batch_size       ,					dtype=torch.long       ,					device=__UpperCAmelCase )

         return inputs_dict






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :str											=				FlaubertModelTester(self )
         lowerCAmelCase__     :Dict											=				ConfigTester(self       ,					config_class=__UpperCAmelCase       ,					emb_dim=3_7 )






       def 	snake_case		(       self ):



         '''simple docstring'''

         self.config_tester.run_common_tests()






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Union[str, Any]											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_model(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_lm_head(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Tuple											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_simple_qa(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Tuple											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_qa(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :int											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_sequence_classif(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :List[Any]											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_token_classif(*__UpperCAmelCase )






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_flaubert_multiple_choice(*__UpperCAmelCase )






       @slow
       def 	snake_case		(       self ):



         '''simple docstring'''

         for model_name in FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowerCAmelCase__     :Optional[int]											=				FlaubertModel.from_pretrained(__UpperCAmelCase )
           self.assertIsNotNone(__UpperCAmelCase )






       @slow
       @require_torch_gpu
       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__				,							lowerCAmelCase__     :Optional[Any]											=				self.model_tester.prepare_config_and_inputs_for_common()
         for model_class in self.all_model_classes:
           # FlauBertForMultipleChoice behaves incorrectly in JIT environments.
           if model_class == FlaubertForMultipleChoice:
             return

           lowerCAmelCase__     :List[str]											=				True
           lowerCAmelCase__     :Optional[int]											=				model_class(config=__UpperCAmelCase )

           lowerCAmelCase__     :Dict											=				self._prepare_for_class(__UpperCAmelCase       ,					__UpperCAmelCase )
           lowerCAmelCase__     :Tuple											=				torch.jit.trace(
               __UpperCAmelCase       ,					(inputs_dict['input_ids'].to('cpu' ), inputs_dict['attention_mask'].to('cpu' )) )

           with tempfile.TemporaryDirectory() as tmp:
             torch.jit.save(__UpperCAmelCase       ,					os.path.join(__UpperCAmelCase       ,					'traced_model.pt' ) )
             lowerCAmelCase__     :Optional[Any]											=				torch.jit.load(os.path.join(__UpperCAmelCase       ,					'traced_model.pt' )       ,					map_location=__UpperCAmelCase )
             loaded(inputs_dict['input_ids'].to(__UpperCAmelCase )       ,					inputs_dict['attention_mask'].to(__UpperCAmelCase ) )






@require_torch
class    _lowerCAmelCase  (	unittest.TestCase			):
       """simple docstring"""




       @slow
       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				FlaubertModel.from_pretrained('flaubert/flaubert_base_cased' )
         lowerCAmelCase__     :Optional[int]											=				torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]] )
         with torch.no_grad():
           lowerCAmelCase__     :Optional[int]											=				model(__UpperCAmelCase )[0]
         lowerCAmelCase__     :Union[str, Any]											=				torch.Size((1, 1_1, 7_6_8) )
         self.assertEqual(output.shape       ,					__UpperCAmelCase )
         lowerCAmelCase__     :Tuple											=				torch.tensor(
             [[[-2.62_51, -1.42_98, -0.02_27], [-2.85_10, -1.63_87, 0.22_58], [-2.81_14, -1.18_32, -0.30_66]]] )

         self.assertTrue(torch.allclose(output[:, :3, :3]       ,					__UpperCAmelCase       ,					atol=1E-4 ) )






from sklearn.metrics import matthews_corrcoef

import datasets


UpperCAmelCase_		:					Dict          =  "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true and false positives and negatives and is generally\nregarded as a balanced measure which can be used even if the classes are of\nvery different sizes. The MCC is in essence a correlation coefficient value\nbetween -1 and +1. A coefficient of +1 represents a perfect prediction, 0\nan average random prediction and -1 an inverse prediction.  The statistic\nis also known as the phi coefficient. [source: Wikipedia]\n"

UpperCAmelCase_		:					Any          =  "\nArgs:\n    predictions (list of int): Predicted labels, as returned by a model.\n    references (list of int): Ground truth labels.\n    sample_weight (list of int, float, or bool): Sample weights. Defaults to `None`.\nReturns:\n    matthews_correlation (dict containing float): Matthews correlation.\nExamples:\n    Example 1, a basic example with only predictions and references as inputs:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.54\n\n    Example 2, the same example as above, but also including sample weights:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 3, 1, 1, 1, 2])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.1\n\n    Example 3, the same example as above, but with sample weights that cause a negative correlation:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 1, 0, 0, 0, 1])\n        >>> print(round(results['matthews_correlation'], 2))\n        -0.25\n"

UpperCAmelCase_		:					Dict          =  "\\n@article{scikit-learn,\n  title={Scikit-learn: Machine Learning in {P}ython},\n  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.\n         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and\n         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},\n  journal={Journal of Machine Learning Research},\n  volume={12},\n  pages={2825--2830},\n  year={2011}\n}\n"




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION       ,    _KWARGS_DESCRIPTION      )
class 		__A   (      datasets.Metric      ):

						def      A__    (		self :List[str]			):
										'''simple docstring'''

										return datasets.MetricInfo(
										    description=_DESCRIPTION     ,			citation=_CITATION     ,			inputs_description=_KWARGS_DESCRIPTION     ,			features=datasets.Features(
										        {
										            """predictions""": datasets.Value("""int32"""			),
										            """references""": datasets.Value("""int32"""			),
										        }			)     ,			reference_urls=[
										        """https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html"""
										    ]     ,			)


						def      A__    (		self :Tuple     ,			__snake_case :str     ,			__snake_case :Tuple     ,			__snake_case :List[str]=None			):
										'''simple docstring'''

										return {
										    "matthews_correlation": float(matthews_corrcoef(__snake_case     ,			__snake_case     ,			sample_weight=__snake_case			)			),
										}




