
import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

					if is_vision_available():
										from transformers import MaskaFormerImageProcessor

if is_vision_available():
					from PIL import Image


class        lowercase      :



		def __init__(				self       ,   A_       ,   A_=2       ,   A_=True       ,   A_=False       ,   A_=10       ,   A_=3       ,   A_=32 * 8       ,   A_=32 * 8       ,   A_=4       ,   A_=64       ,   )						->      Any:
				"""simple docstring"""
				UpperCamelCase						=  parent
				UpperCamelCase						=  batch_size
				UpperCamelCase						=  is_training
				UpperCamelCase						=  use_auxiliary_loss
				UpperCamelCase						=  num_queries
				UpperCamelCase						=  num_channels
				UpperCamelCase						=  min_size
				UpperCamelCase						=  max_size
				UpperCamelCase						=  num_labels
				UpperCamelCase						=  hidden_dim
				UpperCamelCase						=  hidden_dim



		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				UpperCamelCase						=  floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size] ).to(
				    __lowercase )

				UpperCamelCase						=  torch.ones([self.batch_size, self.min_size, self.max_size]       ,   device=__lowercase )

				UpperCamelCase						=  (
				    torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]       ,   device=__lowercase ) > 0.5
				).float()
				UpperCamelCase						=  (torch.rand((self.batch_size, self.num_labels)       ,   device=__lowercase ) > 0.5).long()

				UpperCamelCase						=  self.get_config()
				return config, pixel_values, pixel_mask, mask_labels, class_labels



		def __UpperCamelCase				(				self )						->      Optional[Any]:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerConfig(
				    hidden_size=self.hidden_dim       ,   )
				UpperCamelCase						=  self.num_queries
				UpperCamelCase						=  self.num_labels

				UpperCamelCase						=  [1, 1, 1, 1]
				UpperCamelCase						=  self.num_channels

				UpperCamelCase						=  64
				UpperCamelCase						=  128
				UpperCamelCase						=  self.hidden_dim
				UpperCamelCase						=  self.hidden_dim
				UpperCamelCase						=  self.hidden_dim
				return config



		def __UpperCamelCase				(				self )						->      Union[str, Any]:
				"""simple docstring"""
				UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase						=  self.prepare_config_and_inputs()
				UpperCamelCase						=  {'pixel_values': pixel_values, 'pixel_mask': pixel_mask}
				return config, inputs_dict



		def __UpperCamelCase				(				self       ,   A_       ,   A_ )						->      List[Any]:
				"""simple docstring"""
				UpperCamelCase						=  output.encoder_hidden_states
				UpperCamelCase						=  output.pixel_decoder_hidden_states
				UpperCamelCase						=  output.transformer_decoder_hidden_states

				self.parent.assertTrue(len(__lowercase )       ,   len(config.backbone_config.depths ) )
				self.parent.assertTrue(len(__lowercase )       ,   len(config.backbone_config.depths ) )
				self.parent.assertTrue(len(__lowercase )       ,   config.decoder_layers )



		def __UpperCamelCase				(				self       ,   A_       ,   A_       ,   A_       ,   A_=False )						->      Optional[Any]:
				"""simple docstring"""
				with torch.no_grad():
						UpperCamelCase						=  MaskaFormerModel(config=__lowercase )
						model.to(__lowercase )
						model.eval()

						UpperCamelCase						=  model(pixel_values=__lowercase       ,   pixel_mask=__lowercase )
						UpperCamelCase						=  model(__lowercase       ,   output_hidden_states=__lowercase )

				self.parent.assertEqual(
				    output.transformer_decoder_last_hidden_state.shape       ,   (self.batch_size, self.num_queries, self.hidden_dim)       ,   )
				# let's ensure the other two hidden state exists
				self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None )
				self.parent.assertTrue(output.encoder_last_hidden_state is not None )

				if output_hidden_states:
						self.check_output_hidden_state(__lowercase       ,   __lowercase )



		def __UpperCamelCase				(				self       ,   A_       ,   A_       ,   A_       ,   A_       ,   A_ )						->      Tuple:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerForUniversalSegmentation(config=__lowercase )
				model.to(__lowercase )
				model.eval()

				def comm_check_on_output(A_ ):
						# let's still check that all the required stuff is there
						self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None )
						self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None )
						self.parent.assertTrue(result.encoder_last_hidden_state is not None )
						# okay, now we need to check the logits shape
						# due to the encoder compression, masks have a //4 spatial size
						self.parent.assertEqual(
						    result.masks_queries_logits.shape       ,   (self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)       ,   )
						# + 1 for null class
						self.parent.assertEqual(
						    result.class_queries_logits.shape       ,   (self.batch_size, self.num_queries, self.num_labels + 1) )

				with torch.no_grad():
						UpperCamelCase						=  model(pixel_values=__lowercase       ,   pixel_mask=__lowercase )
						UpperCamelCase						=  model(__lowercase )

						comm_check_on_output(__lowercase )

						UpperCamelCase						=  model(
						    pixel_values=__lowercase       ,   pixel_mask=__lowercase       ,   mask_labels=__lowercase       ,   class_labels=__lowercase )

				comm_check_on_output(__lowercase )

				self.parent.assertTrue(result.loss is not None )
				self.parent.assertEqual(result.loss.shape       ,   torch.Size([1] ) )






@require_torch
class        lowercase      (	lowercase__						,     lowercase__						,     unittest.TestCase     ):
		__lowercase : Any			  =       (MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
		__lowercase : Tuple			  =       {"""feature-extraction""": MaskaFormerModel} if is_torch_available() else {}

		__lowercase : int			  =       False
		__lowercase : Optional[int]			  =       False
		__lowercase : Optional[int]			  =       False
		__lowercase : List[str]			  =       False



		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerModelTester(self )
				UpperCamelCase						=  ConfigTester(self       ,   config_class=__lowercase       ,   has_text_modality=__lowercase )



		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				self.config_tester.run_common_tests()



		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs_for_common()
				self.model_tester.create_and_check_maskaformer_model(__lowercase       ,   **__lowercase       ,   output_hidden_states=__lowercase )



		def __UpperCamelCase				(				self )						->      Dict:
				"""simple docstring"""
				UpperCamelCase						=  self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*__lowercase )



		@unittest.skip(reason='Mask2Former does not use inputs_embeds' )
		def __UpperCamelCase				(				self )						->      Tuple:
				"""simple docstring"""
				pass



		@unittest.skip(reason='Mask2Former does not have a get_input_embeddings method' )
		def __UpperCamelCase				(				self )						->      List[Any]:
				"""simple docstring"""
				pass



		@unittest.skip(reason='Mask2Former is not a generative model' )
		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				pass



		@unittest.skip(reason='Mask2Former does not use token embeddings' )
		def __UpperCamelCase				(				self )						->      int:
				"""simple docstring"""
				pass



		@require_torch_multi_gpu
		@unittest.skip(
		    reason='Mask2Former has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`' )
		def __UpperCamelCase				(				self )						->      Any:
				"""simple docstring"""
				pass



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



		def __UpperCamelCase				(				self )						->      Optional[int]:
				"""simple docstring"""
				UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs_for_common()

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

						UpperCamelCase						=  ['pixel_values']
						self.assertListEqual(arg_names[:1]       ,   __lowercase )



		@slow
		def __UpperCamelCase				(				self )						->      Tuple:
				"""simple docstring"""
				for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
						UpperCamelCase						=  MaskaFormerModel.from_pretrained(__lowercase )
						self.assertIsNotNone(__lowercase )



		def __UpperCamelCase				(				self )						->      Dict:
				"""simple docstring"""
				UpperCamelCase						=  (self.model_tester.min_size,) * 2
				UpperCamelCase						=  {
				    'pixel_values': torch.randn((2, 3, *size)       ,   device=__lowercase ),
				    'mask_labels': torch.randn((2, 10, *size)       ,   device=__lowercase ),
				    'class_labels': torch.zeros(2       ,   10       ,   device=__lowercase ).long(),
				}
				UpperCamelCase						=  self.model_tester.get_config()

				UpperCamelCase						=  MaskaFormerForUniversalSegmentation(__lowercase ).to(__lowercase )
				UpperCamelCase						=  model(**__lowercase )
				self.assertTrue(outputs.loss is not None )



		def __UpperCamelCase				(				self )						->      Optional[Any]:
				"""simple docstring"""
				UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs_for_common()
				self.model_tester.create_and_check_maskaformer_model(__lowercase       ,   **__lowercase       ,   output_hidden_states=__lowercase )



		def __UpperCamelCase				(				self )						->      Any:
				"""simple docstring"""
				UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in self.all_model_classes:
						UpperCamelCase						=  model_class(__lowercase ).to(__lowercase )
						UpperCamelCase						=  model(**__lowercase       ,   output_attentions=__lowercase )
						self.assertTrue(outputs.attentions is not None )



		def __UpperCamelCase				(				self )						->      Optional[int]:
				"""simple docstring"""
				if not self.model_tester.is_training:
						return

				UpperCamelCase						=  self.all_model_classes[1]
				UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs()

				UpperCamelCase						=  model_class(__lowercase )
				model.to(__lowercase )
				model.train()

				UpperCamelCase						=  model(__lowercase       ,   mask_labels=__lowercase       ,   class_labels=__lowercase ).loss
				loss.backward()



		def __UpperCamelCase				(				self )						->      Tuple:
				"""simple docstring"""
				UpperCamelCase						=  self.all_model_classes[1]
				UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase						=  self.model_tester.prepare_config_and_inputs()
				UpperCamelCase						=  True
				UpperCamelCase						=  True

				UpperCamelCase						=  model_class(__lowercase ).to(__lowercase )
				model.train()

				UpperCamelCase						=  model(__lowercase       ,   mask_labels=__lowercase       ,   class_labels=__lowercase )

				UpperCamelCase						=  outputs.encoder_hidden_states[0]
				encoder_hidden_states.retain_grad()

				UpperCamelCase						=  outputs.pixel_decoder_hidden_states[0]
				pixel_decoder_hidden_states.retain_grad()

				UpperCamelCase						=  outputs.transformer_decoder_hidden_states[0]
				transformer_decoder_hidden_states.retain_grad()

				UpperCamelCase						=  outputs.attentions[0]
				attentions.retain_grad()

				outputs.loss.backward(retain_graph=__lowercase )

				self.assertIsNotNone(encoder_hidden_states.grad )
				self.assertIsNotNone(pixel_decoder_hidden_states.grad )
				self.assertIsNotNone(transformer_decoder_hidden_states.grad )
				self.assertIsNotNone(attentions.grad )






_UpperCAmelCase      :				int          = 1e-4


def    A (      )     ->						int:
		'''simple docstring'''

		UpperCamelCase						=  Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'				)
		return image


@require_vision
@slow
class        lowercase      (	unittest.TestCase     ):



		@cached_property
		def __UpperCamelCase				(				self )						->      List[Any]:
				"""simple docstring"""
				return "facebook/mask2former-swin-small-coco-instance"



		@cached_property
		def __UpperCamelCase				(				self )						->      Dict:
				"""simple docstring"""
				return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints ) if is_vision_available() else None



		def __UpperCamelCase				(				self )						->      List[Any]:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerModel.from_pretrained(self.model_checkpoints ).to(__lowercase )
				UpperCamelCase						=  self.default_image_processor
				UpperCamelCase						=  prepare_img()
				UpperCamelCase						=  image_processor(__lowercase       ,   return_tensors='pt' ).to(__lowercase )
				UpperCamelCase						=  inputs['pixel_values'].shape
				# check size is divisible by 32
				self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0 )
				# check size
				self.assertEqual(__lowercase       ,   (1, 3, 384, 384) )

				with torch.no_grad():
						UpperCamelCase						=  model(**__lowercase )

				UpperCamelCase						=  torch.tensor(
				    [[-0.2790, -1.0717, -1.1668], [-0.5128, -0.3128, -0.4987], [-0.5832, 0.1971, -0.0197]] ).to(__lowercase )
				self.assertTrue(
				    torch.allclose(
				        outputs.encoder_last_hidden_state[0, 0, :3, :3]       ,   __lowercase       ,   atol=__lowercase ) )

				UpperCamelCase						=  torch.tensor(
				    [[0.8973, 1.1847, 1.1776], [1.1934, 1.5040, 1.5128], [1.1153, 1.4486, 1.4951]] ).to(__lowercase )
				self.assertTrue(
				    torch.allclose(
				        outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]       ,   __lowercase       ,   atol=__lowercase ) )

				UpperCamelCase						=  torch.tensor(
				    [[2.1152, 1.7000, -0.8603], [1.5808, 1.8004, -0.9353], [1.6043, 1.7495, -0.5999]] ).to(__lowercase )
				self.assertTrue(
				    torch.allclose(
				        outputs.transformer_decoder_last_hidden_state[0, :3, :3]       ,   __lowercase       ,   atol=__lowercase ) )



		def __UpperCamelCase				(				self )						->      Tuple:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints ).to(__lowercase ).eval()
				UpperCamelCase						=  self.default_image_processor
				UpperCamelCase						=  prepare_img()
				UpperCamelCase						=  image_processor(__lowercase       ,   return_tensors='pt' ).to(__lowercase )
				UpperCamelCase						=  inputs['pixel_values'].shape
				# check size is divisible by 32
				self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0 )
				# check size
				self.assertEqual(__lowercase       ,   (1, 3, 384, 384) )

				with torch.no_grad():
						UpperCamelCase						=  model(**__lowercase )
				# masks_queries_logits
				UpperCamelCase						=  outputs.masks_queries_logits
				self.assertEqual(
				    masks_queries_logits.shape       ,   (1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4) )
				UpperCamelCase						=  [
				    [-8.7839, -9.0056, -8.8121],
				    [-7.4104, -7.0313, -6.5401],
				    [-6.6105, -6.3427, -6.4675],
				]
				UpperCamelCase						=  torch.tensor(__lowercase ).to(__lowercase )
				self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]       ,   __lowercase       ,   atol=__lowercase ) )
				# class_queries_logits
				UpperCamelCase						=  outputs.class_queries_logits
				self.assertEqual(class_queries_logits.shape       ,   (1, model.config.num_queries, model.config.num_labels + 1) )
				UpperCamelCase						=  torch.tensor(
				    [
				        [1.8324, -8.0835, -4.1922],
				        [0.8450, -9.0050, -3.6053],
				        [0.3045, -7.7293, -3.0275],
				    ] ).to(__lowercase )
				self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]       ,   __lowercase       ,   atol=__lowercase ) )



		def __UpperCamelCase				(				self )						->      List[str]:
				"""simple docstring"""
				UpperCamelCase						=  MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints ).to(__lowercase ).eval()
				UpperCamelCase						=  self.default_image_processor

				UpperCamelCase						=  image_processor(
				    [np.zeros((3, 800, 1_333) ), np.zeros((3, 800, 1_333) )]       ,   segmentation_maps=[np.zeros((384, 384) ).astype(np.floataa ), np.zeros((384, 384) ).astype(np.floataa )]       ,   return_tensors='pt'       ,   )

				UpperCamelCase						=  inputs['pixel_values'].to(__lowercase )
				UpperCamelCase						=  [el.to(__lowercase ) for el in inputs['mask_labels']]
				UpperCamelCase						=  [el.to(__lowercase ) for el in inputs['class_labels']]

				with torch.no_grad():
						UpperCamelCase						=  model(**__lowercase )

				self.assertTrue(outputs.loss is not None )


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

import datasets


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

_UpperCAmelCase      :				str          = "\\nGLUE, the General Language Understanding Evaluation benchmark\n(https://gluebenchmark.com/) is a collection of resources for training,\nevaluating, and analyzing natural language understanding systems.\n"

_UpperCAmelCase      :				List[str]          = "\nCompute GLUE evaluation metric associated to each GLUE dataset.\nArgs:\n    predictions: list of predictions to score.\n        Each translation should be tokenized into a list of tokens.\n    references: list of lists of references for each translation.\n        Each reference should be tokenized into a list of tokens.\nReturns: depending on the GLUE subset, one or several of:\n    \"accuracy\": Accuracy\n    \"f1\": F1 score\n    \"pearson\": Pearson Correlation\n    \"spearmanr\": Spearman Correlation\n    \"matthews_correlation\": Matthew Correlation\nExamples:\n\n    >>> glue_metric = datasets.load_metric('glue', 'sst2')  # 'sst2' or any of [\"mnli\", \"mnli_mismatched\", \"mnli_matched\", \"qnli\", \"rte\", \"wnli\", \"hans\"]\n    >>> references = [0, 1]\n    >>> predictions = [0, 1]\n    >>> results = glue_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'accuracy': 1.0}\n\n    >>> glue_metric = datasets.load_metric('glue', 'mrpc')  # 'mrpc' or 'qqp'\n    >>> references = [0, 1]\n    >>> predictions = [0, 1]\n    >>> results = glue_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'accuracy': 1.0, 'f1': 1.0}\n\n    >>> glue_metric = datasets.load_metric('glue', 'stsb')\n    >>> references = [0., 1., 2., 3., 4., 5.]\n    >>> predictions = [0., 1., 2., 3., 4., 5.]\n    >>> results = glue_metric.compute(predictions=predictions, references=references)\n    >>> print({\"pearson\": round(results[\"pearson\"], 2), \"spearmanr\": round(results[\"spearmanr\"], 2)})\n    {'pearson': 1.0, 'spearmanr': 1.0}\n\n    >>> glue_metric = datasets.load_metric('glue', 'cola')\n    >>> references = [0, 1]\n    >>> predictions = [0, 1]\n    >>> results = glue_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'matthews_correlation': 1.0}\n"


def    A (      lowercase					, lowercase				)     ->						List[str]:
		'''simple docstring'''

		return float((preds == labels).mean()				)


def    A (      lowercase					, lowercase				)     ->						Tuple:
		'''simple docstring'''

		UpperCamelCase						=  simple_accuracy(lowercase					, lowercase				)
		UpperCamelCase						=  float(fa_score(y_true=lowercase					, y_pred=lowercase				)				)
		return {
		    "accuracy": acc,
		    "f1": fa,
		}


def    A (      lowercase					, lowercase				)     ->						Optional[int]:
		'''simple docstring'''

		UpperCamelCase						=  float(pearsonr(lowercase					, lowercase				)[0]				)
		UpperCamelCase						=  float(spearmanr(lowercase					, lowercase				)[0]				)
		return {
		    "pearson": pearson_corr,
		    "spearmanr": spearman_corr,
		}


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



		def __UpperCamelCase				(				self )						->      Optional[Any]:
				"""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 __UpperCamelCase				(				self       ,   A_       ,   A_ )						->      Any:
				"""simple docstring"""
				if self.config_name == "cola":
						return {"matthews_correlation": matthews_corrcoef(A_       ,   A_ )}
				elif self.config_name == "stsb":
						return pearson_and_spearman(A_       ,   A_ )
				elif self.config_name in ["mrpc", "qqp"]:
						return acc_and_fa(A_       ,   A_ )
				elif self.config_name in ["sst2", "mnli", "mnli_mismatched", "mnli_matched", "qnli", "rte", "wnli", "hans"]:
						return {"accuracy": simple_accuracy(A_       ,   A_ )}
				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"]' )
