
import copy
import unittest

from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, 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, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
        MODEL_FOR_QUESTION_ANSWERING_MAPPING,
        MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
        MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
        LayoutLMvaConfig,
        LayoutLMvaForQuestionAnswering,
        LayoutLMvaForSequenceClassification,
        LayoutLMvaForTokenClassification,
        LayoutLMvaModel,
    )
    from transformers.models.layoutlmva.modeling_layoutlmva import LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
    from PIL import Image

    from transformers import LayoutLMvaImageProcessor




class        UpperCAmelCase_			:


  '''simple docstring'''







  def __init__( self			: Any			,							UpperCamelCase__			: Any			,							UpperCamelCase__			: List[str]=2			,							UpperCamelCase__			: Tuple=3			,							UpperCamelCase__			: Optional[Any]=4			,							UpperCamelCase__			: Tuple=2			,							UpperCamelCase__			: Dict=7			,							UpperCamelCase__			: Union[str, Any]=True			,							UpperCamelCase__			: Dict=True			,							UpperCamelCase__			: List[Any]=True			,							UpperCamelCase__			: Optional[int]=True			,							UpperCamelCase__			: List[Any]=99			,							UpperCamelCase__			: Dict=36			,							UpperCamelCase__			: Dict=3			,							UpperCamelCase__			: Optional[Any]=4			,							UpperCamelCase__			: Union[str, Any]=37			,							UpperCamelCase__			: List[str]="gelu"			,							UpperCamelCase__			: List[Any]=0.1			,							UpperCamelCase__			: List[Any]=0.1			,							UpperCamelCase__			: Optional[Any]=512			,							UpperCamelCase__			: List[str]=16			,							UpperCamelCase__			: Union[str, Any]=2			,							UpperCamelCase__			: str=0.02			,							UpperCamelCase__			: Dict=6			,							UpperCamelCase__			: Optional[Any]=6			,							UpperCamelCase__			: Optional[Any]=3			,							UpperCamelCase__			: Optional[Any]=4			,							UpperCamelCase__			: Any=None			,							UpperCamelCase__			: Tuple=1000			,							)			->	Optional[int]:







    """simple docstring"""






    __magic_name__				     =       parent
    __magic_name__				     =       batch_size
    __magic_name__				     =       num_channels
    __magic_name__				     =       image_size
    __magic_name__				     =       patch_size
    __magic_name__				     =       text_seq_length
    __magic_name__				     =       is_training
    __magic_name__				     =       use_input_mask
    __magic_name__				     =       use_token_type_ids
    __magic_name__				     =       use_labels
    __magic_name__				     =       vocab_size
    __magic_name__				     =       hidden_size
    __magic_name__				     =       num_hidden_layers
    __magic_name__				     =       num_attention_heads
    __magic_name__				     =       intermediate_size
    __magic_name__				     =       hidden_act
    __magic_name__				     =       hidden_dropout_prob
    __magic_name__				     =       attention_probs_dropout_prob
    __magic_name__				     =       max_position_embeddings
    __magic_name__				     =       type_vocab_size
    __magic_name__				     =       type_sequence_label_size
    __magic_name__				     =       initializer_range
    __magic_name__				     =       coordinate_size
    __magic_name__				     =       shape_size
    __magic_name__				     =       num_labels
    __magic_name__				     =       num_choices
    __magic_name__				     =       scope
    __magic_name__				     =       range_bbox

    # LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
    __magic_name__				     =       text_seq_length
    __magic_name__				     =       (image_size // patch_size) ** 2 + 1
    __magic_name__				     =       self.text_seq_length + self.image_seq_length
  def 							_lowercase							( self			: int    )			->	Union[str, Any]:







    """simple docstring"""






    __magic_name__				     =       ids_tensor([self.batch_size, self.text_seq_length]			,							self.vocab_size    )

    __magic_name__				     =       ids_tensor([self.batch_size, self.text_seq_length, 4]			,							self.range_bbox    )
    # Ensure that bbox is legal
    for i in range(bbox.shape[0]    ):
      for j in range(bbox.shape[1]    ):
        if bbox[i, j, 3] < bbox[i, j, 1]:
          __magic_name__				     =       bbox[i, j, 3]
          __magic_name__				     =       bbox[i, j, 1]
          __magic_name__				     =       t
        if bbox[i, j, 2] < bbox[i, j, 0]:
          __magic_name__				     =       bbox[i, j, 2]
          __magic_name__				     =       bbox[i, j, 0]
          __magic_name__				     =       t

    __magic_name__				     =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

    __magic_name__				     =       None
    if self.use_input_mask:
      __magic_name__				     =       random_attention_mask([self.batch_size, self.text_seq_length]    )

    __magic_name__				     =       None
    if self.use_token_type_ids:
      __magic_name__				     =       ids_tensor([self.batch_size, self.text_seq_length]			,							self.type_vocab_size    )

    __magic_name__				     =       None
    __magic_name__				     =       None
    if self.use_labels:
      __magic_name__				     =       ids_tensor([self.batch_size]			,							self.type_sequence_label_size    )
      __magic_name__				     =       ids_tensor([self.batch_size, self.text_seq_length]			,							self.num_labels    )

    __magic_name__				     =       LayoutLMvaConfig(
        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			,							type_vocab_size=self.type_vocab_size			,							initializer_range=self.initializer_range			,							coordinate_size=self.coordinate_size			,							shape_size=self.shape_size			,							input_size=self.image_size			,							patch_size=self.patch_size			,							)

    return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels
  def 							_lowercase							( self			: List[Any]			,							UpperCamelCase__			: Optional[Any]			,							UpperCamelCase__			: Union[str, Any]			,							UpperCamelCase__			: Dict			,							UpperCamelCase__			: List[Any]			,							UpperCamelCase__			: Optional[Any]			,							UpperCamelCase__			: Optional[int]			,							UpperCamelCase__			: int			,							UpperCamelCase__			: Dict    )			->	Optional[int]:







    """simple docstring"""






    __magic_name__				     =       LayoutLMvaModel(config=UpperCamelCase__    )
    model.to(UpperCamelCase__    )
    model.eval()

    # text + image
    __magic_name__				     =       model(UpperCamelCase__			,							pixel_values=UpperCamelCase__    )
    __magic_name__				     =       model(
        UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__			,							attention_mask=UpperCamelCase__			,							token_type_ids=UpperCamelCase__    )
    __magic_name__				     =       model(UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__			,							token_type_ids=UpperCamelCase__    )
    __magic_name__				     =       model(UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__    )

    self.parent.assertEqual(result.last_hidden_state.shape			,							(self.batch_size, self.seq_length, self.hidden_size)    )

    # text only
    __magic_name__				     =       model(UpperCamelCase__    )
    self.parent.assertEqual(
        result.last_hidden_state.shape			,							(self.batch_size, self.text_seq_length, self.hidden_size)    )

    # image only
    __magic_name__				     =       model(pixel_values=UpperCamelCase__    )
    self.parent.assertEqual(
        result.last_hidden_state.shape			,							(self.batch_size, self.image_seq_length, self.hidden_size)    )
  def 							_lowercase							( self			: Union[str, Any]			,							UpperCamelCase__			: Dict			,							UpperCamelCase__			: Optional[Any]			,							UpperCamelCase__			: Optional[int]			,							UpperCamelCase__			: str			,							UpperCamelCase__			: Any			,							UpperCamelCase__			: Tuple			,							UpperCamelCase__			: List[str]			,							UpperCamelCase__			: Dict    )			->	Tuple:







    """simple docstring"""






    __magic_name__				     =       self.num_labels
    __magic_name__				     =       LayoutLMvaForSequenceClassification(UpperCamelCase__    )
    model.to(UpperCamelCase__    )
    model.eval()
    __magic_name__				     =       model(
        UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__			,							attention_mask=UpperCamelCase__			,							token_type_ids=UpperCamelCase__			,							labels=UpperCamelCase__			,							)
    self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.num_labels)    )
  def 							_lowercase							( self			: List[str]			,							UpperCamelCase__			: Union[str, Any]			,							UpperCamelCase__			: Any			,							UpperCamelCase__			: Optional[int]			,							UpperCamelCase__			: List[Any]			,							UpperCamelCase__			: List[str]			,							UpperCamelCase__			: str			,							UpperCamelCase__			: List[str]			,							UpperCamelCase__			: Tuple    )			->	List[Any]:







    """simple docstring"""






    __magic_name__				     =       self.num_labels
    __magic_name__				     =       LayoutLMvaForTokenClassification(config=UpperCamelCase__    )
    model.to(UpperCamelCase__    )
    model.eval()
    __magic_name__				     =       model(
        UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__			,							attention_mask=UpperCamelCase__			,							token_type_ids=UpperCamelCase__			,							labels=UpperCamelCase__			,							)
    self.parent.assertEqual(result.logits.shape			,							(self.batch_size, self.text_seq_length, self.num_labels)    )
  def 							_lowercase							( self			: Any			,							UpperCamelCase__			: Union[str, Any]			,							UpperCamelCase__			: int			,							UpperCamelCase__			: List[Any]			,							UpperCamelCase__			: int			,							UpperCamelCase__			: Tuple			,							UpperCamelCase__			: int			,							UpperCamelCase__			: str			,							UpperCamelCase__			: Optional[int]    )			->	List[Any]:







    """simple docstring"""






    __magic_name__				     =       LayoutLMvaForQuestionAnswering(config=UpperCamelCase__    )
    model.to(UpperCamelCase__    )
    model.eval()
    __magic_name__				     =       model(
        UpperCamelCase__			,							bbox=UpperCamelCase__			,							pixel_values=UpperCamelCase__			,							attention_mask=UpperCamelCase__			,							token_type_ids=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 							_lowercase							( self			: int    )			->	List[str]:







    """simple docstring"""






    __magic_name__				     =       self.prepare_config_and_inputs()
    (
        (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    (
        __magic_name__
    )     ,    
    )				     =       config_and_inputs
    __magic_name__				     =       {
        """input_ids""": input_ids,
        """bbox""": bbox,
        """pixel_values""": pixel_values,
        """token_type_ids""": token_type_ids,
        """attention_mask""": input_mask,
    }
    return config, inputs_dict







@require_torch
class        UpperCAmelCase_			( _A  ,       _A  ,       unittest.TestCase     ):


  '''simple docstring'''







  a__           =		False
  a__           =		False
  a__           =		False

  a__           =		(
      (
          LayoutLMvaModel,
          LayoutLMvaForSequenceClassification,
          LayoutLMvaForTokenClassification,
          LayoutLMvaForQuestionAnswering,
      )
      if is_torch_available()
      else ()
  )
  a__           =		(
      {"""document-question-answering""": LayoutLMvaForQuestionAnswering, """feature-extraction""": LayoutLMvaModel}
      if is_torch_available()
      else {}
  )
  def 							_lowercase							( self			: Any			,							UpperCamelCase__			: List[str]			,							UpperCamelCase__			: List[Any]			,							UpperCamelCase__			: Any			,							UpperCamelCase__			: List[Any]			,							UpperCamelCase__			: Optional[int]    )			->	List[str]:







    """simple docstring"""






    return True
  def 							_lowercase							( self			: Optional[Any]    )			->	Optional[Any]:







    """simple docstring"""






    __magic_name__				     =       LayoutLMvaModelTester(self    )
    __magic_name__				     =       ConfigTester(self			,							config_class=UpperCamelCase__			,							hidden_size=37    )
  def 							_lowercase							( self			: Tuple			,							UpperCamelCase__			: List[str]			,							UpperCamelCase__			: Any			,							UpperCamelCase__			: Union[str, Any]=False    )			->	Optional[Any]:







    """simple docstring"""






    __magic_name__				     =       copy.deepcopy(UpperCamelCase__    )
    if model_class in get_values(UpperCamelCase__    ):
      __magic_name__				     =       {
          k: v.unsqueeze(1    ).expand(-1			,							self.model_tester.num_choices			,							-1    ).contiguous()
          if isinstance(UpperCamelCase__			,							torch.Tensor    ) and v.ndim > 1
          else v
          for k, v in inputs_dict.items()
      }
    if return_labels:
      if model_class in get_values(UpperCamelCase__    ):
        __magic_name__				     =       torch.ones(self.model_tester.batch_size			,							dtype=torch.long			,							device=UpperCamelCase__    )
      elif model_class in get_values(UpperCamelCase__    ):
        __magic_name__				     =       torch.zeros(
            self.model_tester.batch_size			,							dtype=torch.long			,							device=UpperCamelCase__    )
        __magic_name__				     =       torch.zeros(
            self.model_tester.batch_size			,							dtype=torch.long			,							device=UpperCamelCase__    )
      elif model_class in [
          *get_values(UpperCamelCase__    ),
      ]:
        __magic_name__				     =       torch.zeros(
            self.model_tester.batch_size			,							dtype=torch.long			,							device=UpperCamelCase__    )
      elif model_class in [
          *get_values(UpperCamelCase__    ),
      ]:
        __magic_name__				     =       torch.zeros(
            (self.model_tester.batch_size, self.model_tester.text_seq_length)			,							dtype=torch.long			,							device=UpperCamelCase__			,							)

    return inputs_dict
  def 							_lowercase							( self			: Dict    )			->	Union[str, Any]:







    """simple docstring"""






    self.config_tester.run_common_tests()
  def 							_lowercase							( self			: Any    )			->	Optional[int]:







    """simple docstring"""






    __magic_name__				     =       self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*UpperCamelCase__    )
  def 							_lowercase							( self			: Optional[Any]    )			->	List[str]:







    """simple docstring"""






    __magic_name__				     =       self.model_tester.prepare_config_and_inputs()
    for type in ["absolute", "relative_key", "relative_key_query"]:
      __magic_name__				     =       type
      self.model_tester.create_and_check_model(*UpperCamelCase__    )
  def 							_lowercase							( self			: Optional[Any]    )			->	Optional[Any]:







    """simple docstring"""






    __magic_name__				     =       self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase__    )
  def 							_lowercase							( self			: str    )			->	Tuple:







    """simple docstring"""






    __magic_name__				     =       self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_token_classification(*UpperCamelCase__    )
  def 							_lowercase							( self			: Tuple    )			->	Any:







    """simple docstring"""






    __magic_name__				     =       self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_question_answering(*UpperCamelCase__    )





  @slow
  def 							_lowercase							( self			: int    )			->	Optional[Any]:







    """simple docstring"""






    for model_name in LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
      __magic_name__				     =       LayoutLMvaModel.from_pretrained(UpperCamelCase__    )
      self.assertIsNotNone(UpperCamelCase__    )







def a__    (       ):






  '''simple docstring'''





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





@require_torch
class        UpperCAmelCase_			( unittest.TestCase     ):


  '''simple docstring'''







  @cached_property
  def 							_lowercase							( self			: Dict    )			->	int:







    """simple docstring"""






    return LayoutLMvaImageProcessor(apply_ocr=UpperCamelCase__    ) if is_vision_available() else None





  @slow
  def 							_lowercase							( self			: str    )			->	Optional[Any]:







    """simple docstring"""






    __magic_name__				     =       LayoutLMvaModel.from_pretrained("""microsoft/layoutlmv3-base"""    ).to(UpperCamelCase__    )

    __magic_name__				     =       self.default_image_processor
    __magic_name__				     =       prepare_img()
    __magic_name__				     =       image_processor(images=UpperCamelCase__			,							return_tensors="""pt"""    ).pixel_values.to(UpperCamelCase__    )

    __magic_name__				     =       torch.tensor([[1, 2]]    )
    __magic_name__				     =       torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]    ).unsqueeze(0    )

    # forward pass
    __magic_name__				     =       model(
        input_ids=input_ids.to(UpperCamelCase__    )			,							bbox=bbox.to(UpperCamelCase__    )			,							pixel_values=pixel_values.to(UpperCamelCase__    )			,							)

    # verify the logits
    __magic_name__				     =       torch.Size((1, 199, 768)    )
    self.assertEqual(outputs.last_hidden_state.shape			,							UpperCamelCase__    )

    __magic_name__				     =       torch.tensor(
        [[-0.0529, 0.3618, 0.1632], [-0.1587, -0.1667, -0.0400], [-0.1557, -0.1671, -0.0505]]    ).to(UpperCamelCase__    )

    self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]			,							UpperCamelCase__			,							atol=1E-4    )    )



from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import fa_score, matthews_corrcoef

import datasets


lowercase  :					str						    =							"""\
@inproceedings{wang2019glue,
  title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},
  author={Wang, Alex and Singh, Amanpreet and Michael, Julian and Hill, Felix and Levy, Omer and Bowman, Samuel R.},
  note={In the Proceedings of ICLR.},
  year={2019}
}
"""

lowercase  :					Dict						    =							"""\
GLUE, the General Language Understanding Evaluation benchmark
(https://gluebenchmark.com/) is a collection of resources for training,
evaluating, and analyzing natural language understanding systems.
"""

lowercase  :					int						    =							"""
Compute GLUE evaluation metric associated to each GLUE dataset.
Args:
    predictions: list of predictions to score.
        Each translation should be tokenized into a list of tokens.
    references: list of lists of references for each translation.
        Each reference should be tokenized into a list of tokens.
Returns: depending on the GLUE subset, one or several of:
    \"accuracy\": Accuracy
    \"f1\": F1 score
    \"pearson\": Pearson Correlation
    \"spearmanr\": Spearman Correlation
    \"matthews_correlation\": Matthew Correlation
Examples:

    >>> glue_metric = datasets.load_metric('glue', 'sst2')  # 'sst2' or any of [\"mnli\", \"mnli_mismatched\", \"mnli_matched\", \"qnli\", \"rte\", \"wnli\", \"hans\"]
    >>> references = [0, 1]
    >>> predictions = [0, 1]
    >>> results = glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0}

    >>> glue_metric = datasets.load_metric('glue', 'mrpc')  # 'mrpc' or 'qqp'
    >>> references = [0, 1]
    >>> predictions = [0, 1]
    >>> results = glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0, 'f1': 1.0}

    >>> glue_metric = datasets.load_metric('glue', 'stsb')
    >>> references = [0., 1., 2., 3., 4., 5.]
    >>> predictions = [0., 1., 2., 3., 4., 5.]
    >>> results = glue_metric.compute(predictions=predictions, references=references)
    >>> print({\"pearson\": round(results[\"pearson\"], 2), \"spearmanr\": round(results[\"spearmanr\"], 2)})
    {'pearson': 1.0, 'spearmanr': 1.0}

    >>> glue_metric = datasets.load_metric('glue', 'cola')
    >>> references = [0, 1]
    >>> predictions = [0, 1]
    >>> results = glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'matthews_correlation': 1.0}
"""







def 						_snake_case(  SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				) ->    Optional[int]:
       return float((preds == labels).mean()				)







def 						_snake_case(  SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				) ->    Optional[Any]:
       lowercase							:     Any       	=      simple_accuracy(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				)
       lowercase							:     Union[str, Any]       	=      float(fa_score(y_true=SCREAMING_SNAKE_CASE__					,	y_pred=SCREAMING_SNAKE_CASE__				)				)
       return {
           "accuracy": acc,
           "f1": fa,
       }







def 						_snake_case(  SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				) ->    List[Any]:
       lowercase							:     Union[str, Any]       	=      float(pearsonr(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				)[0]				)
       lowercase							:     Dict       	=      float(spearmanr(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__				)[0]				)
       return {
           "pearson": pearson_corr,
           "spearmanr": spearman_corr,
       }




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION					,	_KWARGS_DESCRIPTION     )
class __snake_case		(      datasets.Metric     ):
    def       _SCREAMING_SNAKE_CASE       (  self      ):



           '''simple docstring'''







           if self.config_name not in [
               "sst2",
               "mnli",
               "mnli_mismatched",
               "mnli_matched",
               "cola",
               "stsb",
               "mrpc",
               "qqp",
               "qnli",
               "rte",
               "wnli",
               "hans",
           ]:
                  raise KeyError(
                      """You should supply a configuration name selected in """
                      """[\"sst2\", \"mnli\", \"mnli_mismatched\", \"mnli_matched\", """
                      """\"cola\", \"stsb\", \"mrpc\", \"qqp\", \"qnli\", \"rte\", \"wnli\", \"hans\"]"""      )
           return datasets.MetricInfo(
               description=_DESCRIPTION		,citation=_CITATION		,inputs_description=_KWARGS_DESCRIPTION		,features=datasets.Features(
                   {
                       """predictions""": datasets.Value("""int64""" if self.config_name != """stsb""" else """float32"""      ),
                       """references""": datasets.Value("""int64""" if self.config_name != """stsb""" else """float32"""      ),
                   }      )		,codebase_urls=[]		,reference_urls=[]		,format="""numpy"""		,)
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case      ):



           '''simple docstring'''







           if self.config_name == "cola":
                  return {"matthews_correlation": matthews_corrcoef(snake_case		,snake_case      )}
           elif self.config_name == "stsb":
                  return pearson_and_spearman(snake_case		,snake_case      )
           elif self.config_name in ["mrpc", "qqp"]:
                  return acc_and_fa(snake_case		,snake_case      )
           elif self.config_name in ["sst2", "mnli", "mnli_mismatched", "mnli_matched", "qnli", "rte", "wnli", "hans"]:
                  return {"accuracy": simple_accuracy(snake_case		,snake_case      )}
           else:
                  raise KeyError(
                      """You should supply a configuration name selected in """
                      """[\"sst2\", \"mnli\", \"mnli_mismatched\", \"mnli_matched\", """
                      """\"cola\", \"stsb\", \"mrpc\", \"qqp\", \"qnli\", \"rte\", \"wnli\", \"hans\"]"""      )
