





'''simple docstring'''



import tempfile
import unittest

from transformers import DPRConfig, is_torch_available
from transformers.testing_utils import require_torch, 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 DPRContextEncoder, DPRQuestionEncoder, DPRReader, DPRReaderTokenizer
	from transformers.models.dpr.modeling_dpr import (
	    DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
	    DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
	    DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
	)






class 							__lowercase				:







	'''simple docstring'''

	def __init__(self   ,_lowerCamelCase   ,_lowerCamelCase=13   ,_lowerCamelCase=7   ,_lowerCamelCase=False   ,_lowerCamelCase=True   ,_lowerCamelCase=True   ,_lowerCamelCase=True   ,_lowerCamelCase=99   ,_lowerCamelCase=32   ,_lowerCamelCase=5   ,_lowerCamelCase=4   ,_lowerCamelCase=37   ,_lowerCamelCase="gelu"   ,_lowerCamelCase=0.1   ,_lowerCamelCase=0.1   ,_lowerCamelCase=512   ,_lowerCamelCase=16   ,_lowerCamelCase=2   ,_lowerCamelCase=0.0_2   ,_lowerCamelCase=3   ,_lowerCamelCase=4   ,_lowerCamelCase=None   ,_lowerCamelCase=0   ,)							->							List[Any]:







				'''simple docstring'''





				__lowercase   =							parent
				__lowercase   =							batch_size
				__lowercase   =							seq_length
				__lowercase   =							is_training
				__lowercase   =							use_input_mask
				__lowercase   =							use_token_type_ids
				__lowercase   =							use_labels
				__lowercase   =							vocab_size
				__lowercase   =							hidden_size
				__lowercase   =							num_hidden_layers
				__lowercase   =							num_attention_heads
				__lowercase   =							intermediate_size
				__lowercase   =							hidden_act
				__lowercase   =							hidden_dropout_prob
				__lowercase   =							attention_probs_dropout_prob
				__lowercase   =							max_position_embeddings
				__lowercase   =							type_vocab_size
				__lowercase   =							type_sequence_label_size
				__lowercase   =							initializer_range
				__lowercase   =							num_labels
				__lowercase   =							num_choices
				__lowercase   =							scope
				__lowercase   =							projection_dim


	def   _UpperCAmelCase   (self       )							->							Optional[int]:







				'''simple docstring'''





				__lowercase   =							ids_tensor([self.batch_size, self.seq_length]   ,self.vocab_size       )

				__lowercase   =							None
				if self.use_input_mask:
							__lowercase   =							random_attention_mask([self.batch_size, self.seq_length]       )

				__lowercase   =							None
				if self.use_token_type_ids:
							__lowercase   =							ids_tensor([self.batch_size, self.seq_length]   ,self.type_vocab_size       )

				__lowercase   =							None
				__lowercase   =							None
				__lowercase   =							None
				if self.use_labels:
							__lowercase   =							ids_tensor([self.batch_size]   ,self.type_sequence_label_size       )
							__lowercase   =							ids_tensor([self.batch_size, self.seq_length]   ,self.num_labels       )
							__lowercase   =							ids_tensor([self.batch_size]   ,self.num_choices       )

				__lowercase   =							self.get_config()

				return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


	def   _UpperCAmelCase   (self       )							->							int:







				'''simple docstring'''





				return DPRConfig(
				    projection_dim=self.projection_dim   ,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   ,)


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )							->							Tuple:







				'''simple docstring'''





				__lowercase   =							DPRContextEncoder(config=_lowerCamelCase       )
				model.to(_lowerCamelCase       )
				model.eval()
				__lowercase   =							model(_lowerCamelCase   ,attention_mask=_lowerCamelCase   ,token_type_ids=_lowerCamelCase       )
				__lowercase   =							model(_lowerCamelCase   ,token_type_ids=_lowerCamelCase       )
				__lowercase   =							model(_lowerCamelCase       )
				self.parent.assertEqual(result.pooler_output.shape   ,(self.batch_size, self.projection_dim or self.hidden_size)       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )							->							Any:







				'''simple docstring'''





				__lowercase   =							DPRQuestionEncoder(config=_lowerCamelCase       )
				model.to(_lowerCamelCase       )
				model.eval()
				__lowercase   =							model(_lowerCamelCase   ,attention_mask=_lowerCamelCase   ,token_type_ids=_lowerCamelCase       )
				__lowercase   =							model(_lowerCamelCase   ,token_type_ids=_lowerCamelCase       )
				__lowercase   =							model(_lowerCamelCase       )
				self.parent.assertEqual(result.pooler_output.shape   ,(self.batch_size, self.projection_dim or self.hidden_size)       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )							->							List[str]:







				'''simple docstring'''





				__lowercase   =							DPRReader(config=_lowerCamelCase       )
				model.to(_lowerCamelCase       )
				model.eval()
				__lowercase   =							model(
				    _lowerCamelCase   ,attention_mask=_lowerCamelCase   ,)

				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)       )
				self.parent.assertEqual(result.relevance_logits.shape   ,(self.batch_size,)       )


	def   _UpperCAmelCase   (self       )							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase   =							self.prepare_config_and_inputs()
				(
				    (
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						(
				    __lowercase
				)  ,						
				)   =							config_and_inputs
				__lowercase   =							{'''input_ids''': input_ids}
				return config, inputs_dict






@require_torch
class 							__lowercase				(					lowerCAmelCase__       ,					lowerCAmelCase__       ,					unittest.TestCase  ):







	'''simple docstring'''

	a			: Union[str, Any]      =				(
	    (
	        DPRContextEncoder,
	        DPRQuestionEncoder,
	        DPRReader,
	    )
	    if is_torch_available()
	    else ()
	)
	a			: Optional[Any]      =				{"feature-extraction": DPRQuestionEncoder} if is_torch_available() else {}

	a			: int      =				False
	a			: Dict      =				False  # why?
	a			: Union[str, Any]      =				False
	a			: Tuple      =				False


	def   _UpperCAmelCase   (self       )							->							List[Any]:







				'''simple docstring'''





				__lowercase   =							DPRModelTester(self       )
				__lowercase   =							ConfigTester(self   ,config_class=_lowerCamelCase   ,hidden_size=37       )


	def   _UpperCAmelCase   (self       )							->							Optional[int]:







				'''simple docstring'''





				self.config_tester.run_common_tests()


	def   _UpperCAmelCase   (self       )							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase   =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_context_encoder(*_lowerCamelCase       )


	def   _UpperCAmelCase   (self       )							->							Tuple:







				'''simple docstring'''





				__lowercase   =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_question_encoder(*_lowerCamelCase       )


	def   _UpperCAmelCase   (self       )							->							Tuple:







				'''simple docstring'''





				__lowercase   =							self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_reader(*_lowerCamelCase       )


	def   _UpperCAmelCase   (self       )							->							str:







				'''simple docstring'''





				__lowercase   =							self.model_tester.prepare_config_and_inputs()[0]

				__lowercase   =							DPRQuestionEncoder(config=_lowerCamelCase       )
				model.to(_lowerCamelCase       )
				model.eval()

				with tempfile.TemporaryDirectory() as tmp_dirname:
							model.save_pretrained(_lowerCamelCase       )
							__lowercase   =							DPRQuestionEncoder.from_pretrained(_lowerCamelCase   ,projection_dim=512       )

				self.assertIsNotNone(_lowerCamelCase       )


	@slow
	def   _UpperCAmelCase   (self       )							->							List[Any]:







				'''simple docstring'''





				for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowercase   =							DPRContextEncoder.from_pretrained(_lowerCamelCase       )
							self.assertIsNotNone(_lowerCamelCase       )

				for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowercase   =							DPRContextEncoder.from_pretrained(_lowerCamelCase       )
							self.assertIsNotNone(_lowerCamelCase       )

				for model_name in DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowercase   =							DPRQuestionEncoder.from_pretrained(_lowerCamelCase       )
							self.assertIsNotNone(_lowerCamelCase       )

				for model_name in DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowercase   =							DPRReader.from_pretrained(_lowerCamelCase       )
							self.assertIsNotNone(_lowerCamelCase       )






@require_torch
class 							__lowercase				(					unittest.TestCase  ):







	'''simple docstring'''

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







				'''simple docstring'''





				__lowercase   =							DPRQuestionEncoder.from_pretrained('''facebook/dpr-question_encoder-single-nq-base'''   ,return_dict=_lowerCamelCase       )
				model.to(_lowerCamelCase       )

				__lowercase   =							torch.tensor(
				    [[101, 7592, 1010, 2003, 2026, 3899, 10140, 1029, 102]]   ,dtype=torch.long   ,device=_lowerCamelCase       )  # [CLS] hello, is my dog cute? [SEP]
				__lowercase   =							model(_lowerCamelCase       )[0]  # embedding shape = (1, 768)
				# compare the actual values for a slice.
				__lowercase   =							torch.tensor(
				    [
				        [
				            0.0_3_2_3_6_2_5_3,
				            0.1_2_7_5_3_3_3_5,
				            0.1_6_8_1_8_5_0_9,
				            0.0_0_2_7_9_7_8_6,
				            0.3_8_9_6_9_3_3,
				            0.2_4_2_6_4_9_4_5,
				            0.2_1_7_8_9_7_1,
				            -0.0_2_3_3_5_2_2_7,
				            -0.0_8_4_8_1_9_5_9,
				            -0.1_4_3_2_4_1_1_7,
				        ]
				    ]   ,dtype=torch.float   ,device=_lowerCamelCase   ,)
				self.assertTrue(torch.allclose(output[:, :10]   ,_lowerCamelCase   ,atol=1E-4       )       )


	@slow
	def   _UpperCAmelCase   (self       )							->							List[str]:







				'''simple docstring'''





				__lowercase   =							DPRReaderTokenizer.from_pretrained('''facebook/dpr-reader-single-nq-base'''       )
				__lowercase   =							DPRReader.from_pretrained('''facebook/dpr-reader-single-nq-base'''       )
				model.to(_lowerCamelCase       )

				__lowercase   =							tokenizer(
				    questions='''What is love ?'''   ,titles='''Haddaway'''   ,texts='''What Is Love is a song recorded by the artist Haddaway'''   ,padding=_lowerCamelCase   ,return_tensors='''pt'''   ,)
				encoded_inputs.to(_lowerCamelCase       )

				__lowercase   =							model(**_lowerCamelCase       )

				# compare the actual values for a slice.
				__lowercase   =							torch.tensor(
				    [[-1_0.3_0_0_5, -1_0.7_7_6_5, -1_1.4_8_7_2, -1_1.6_8_4_1, -1_1.9_3_1_2, -1_0.3_0_0_2, -9.8_5_4_4, -1_1.7_3_7_8, -1_2.0_8_2_1, -1_0.2_9_7_5]]   ,dtype=torch.float   ,device=_lowerCamelCase   ,)

				__lowercase   =							torch.tensor(
				    [[-1_1.0_6_8_4, -1_1.7_0_4_1, -1_1.5_3_9_7, -1_0.3_4_6_5, -1_0.8_7_9_1, -6.8_4_4_3, -1_1.9_9_5_9, -1_1.0_3_6_4, -1_0.0_0_9_6, -6.8_4_0_5]]   ,dtype=torch.float   ,device=_lowerCamelCase   ,)
				self.assertTrue(torch.allclose(outputs.start_logits[:, :10]   ,_lowerCamelCase   ,atol=1E-4       )       )
				self.assertTrue(torch.allclose(outputs.end_logits[:, :10]   ,_lowerCamelCase   ,atol=1E-4       )       )











'''simple docstring'''


from typing import List

from packaging import version
from sklearn.metrics import fa_score

import datasets
from datasets.config import PY_VERSION


if PY_VERSION < version.parse('3.8'):
				import importlib_metadata
else:
				import importlib.metadata as importlib_metadata


# TODO(Patrick/Anton)
_snake_case      :      Optional[int]   							=		'\\n'

_snake_case      :      Optional[Any]   							=		'\\n    XTREME-S is a benchmark to evaluate universal cross-lingual speech representations in many languages.\n    XTREME-S covers four task families: speech recognition, classification, speech-to-text translation and retrieval.\n'

_snake_case      :      Union[str, Any]   							=		'\nCompute XTREME-S evaluation metric associated to each XTREME-S 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.\n    bleu_kwargs: optional dict of keywords to be passed when computing \'bleu\'.\n        Keywords include Dict can be one of \'smooth_method\', \'smooth_value\', \'force\', \'lowercase\',\n        \'tokenize\', \'use_effective_order\'.\n    wer_kwargs: optional dict of keywords to be passed when computing \'wer\' and \'cer\'.\n        Keywords include \'concatenate_texts\'.\nReturns: depending on the XTREME-S task, one or several of:\n    "accuracy": Accuracy - for \'fleurs-lang_id\', \'minds14\'\n    "f1": F1 score - for \'minds14\'\n    "wer": Word error rate - for \'mls\', \'fleurs-asr\', \'voxpopuli\', \'babel\'\n    "cer": Character error rate - for \'mls\', \'fleurs-asr\', \'voxpopuli\', \'babel\'\n    "bleu": BLEU score according to the `sacrebleu` metric - for \'covost2\'\nExamples:\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'mls\')  # \'mls\', \'voxpopuli\', \'fleurs-asr\' or \'babel\'\n    >>> references = ["it is sunny here", "paper and pen are essentials"]\n    >>> predictions = ["it\'s sunny", "paper pen are essential"]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'wer\': 0.56, \'cer\': 0.27}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'covost2\')\n    >>> references = ["bonjour paris", "il est necessaire de faire du sport de temps en temp"]\n    >>> predictions = ["bonjour paris", "il est important de faire du sport souvent"]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'bleu\': 31.65}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'fleurs-lang_id\')\n    >>> references = [0, 1, 0, 0, 1]\n    >>> predictions = [0, 1, 1, 0, 0]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'accuracy\': 0.6}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'minds14\')\n    >>> references = [0, 1, 0, 0, 1]\n    >>> predictions = [0, 1, 1, 0, 0]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'f1\': 0.58, \'accuracy\': 0.6}\n'

_snake_case      :      Dict   							=		['fleurs-asr', 'mls', 'voxpopuli', 'babel', 'covost2', 'fleurs-lang_id', 'minds14']
_snake_case      :      List[str]   							=		''

try:
				from jiwer import transforms as tr

				_snake_case      :      Optional[Any]   							=		True
except ImportError:
				_snake_case      :      Any   							=		False

if _jiwer_available and version.parse(importlib_metadata.version('jiwer')) < version.parse('2.3.0'):

				class 			A    (		tr.AbstractTransform    ):







											def __init__(  self       :  Any							,			lowerCAmelCase_       :  str = " "					)			->							Dict:


																		"""simple docstring"""


																		_a	     =				sentence_delimiter







											def    __lowerCAmelCase			(  self       :  Union[str, Any]							,			lowerCAmelCase_       :  str					)			->							Tuple:


																		"""simple docstring"""


																		return list(lowerCAmelCase_					)







											def    __lowerCAmelCase			(  self       :  Optional[int]							,			lowerCAmelCase_       :  List[str]					)			->							List[str]:


																		"""simple docstring"""


																		_a	     =				[]
																		for sent_idx, sentence in enumerate(lowerCAmelCase_					):
																									chars.extend(self.process_string(lowerCAmelCase_					)					)
																									if self.sentence_delimiter is not None and self.sentence_delimiter != "" and sent_idx < len(lowerCAmelCase_					) - 1:
																																chars.append(self.sentence_delimiter					)
																		return chars



				_snake_case      :      List[Any]   							=		tr.Compose(
				    [tr.RemoveMultipleSpaces(), tr.Strip(), SentencesToListOfCharacters(SENTENCE_DELIMITER)]
				)
elif _jiwer_available:
				_snake_case      :      Dict   							=		tr.Compose(
				    [
				        tr.RemoveMultipleSpaces(),
				        tr.Strip(),
				        tr.ReduceToSingleSentence(SENTENCE_DELIMITER),
				        tr.ReduceToListOfListOfChars(),
				    ]
				)
else:
				_snake_case      :      Dict   							=		None
def 		snake_case_    (UpperCamelCase       :  Optional[Any] ,						UpperCamelCase       :  List[str]      ):





							'''simple docstring'''


							return float((preds == labels).mean()      )
def 		snake_case_    (UpperCamelCase       :  Optional[int] ,						UpperCamelCase       :  Optional[int]      ):





							'''simple docstring'''


							return {
							    "f1": float(fa_score(y_true=UpperCamelCase ,						y_pred=UpperCamelCase ,						average='''macro'''      )      ),
							    "accuracy": simple_accuracy(UpperCamelCase ,						UpperCamelCase      ),
							}
def 		snake_case_    (UpperCamelCase       :  Optional[int] ,						UpperCamelCase       :  Any ,						UpperCamelCase       :  Optional[Any]="exp" ,						UpperCamelCase       :  Optional[int]=None ,						UpperCamelCase       :  Tuple=False ,						UpperCamelCase       :  Dict=False ,						UpperCamelCase       :  List[str]=None ,						UpperCamelCase       :  Tuple=False ,						):





							'''simple docstring'''


							_a	     =				[[label] for label in labels]
							_a	     =				list(UpperCamelCase      )
							try:
														import sacrebleu as scb
							except ImportError:
														raise ValueError(
														    '''sacrebleu has to be installed in order to apply the bleu metric for covost2.'''
														    '''You can install it via `pip install sacrebleu`.'''      )

							if version.parse(scb.__version__      ) < version.parse('''1.4.12'''      ):
														raise ImportWarning(
														    '''To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn\'t match this condition.\n'''
														    '''You can install it with `pip install "sacrebleu>=1.4.12"`.'''      )

							_a	     =				len(labels[0]      )
							if any(len(UpperCamelCase      ) != references_per_prediction for refs in labels      ):
														raise ValueError('''Sacrebleu requires the same number of references for each prediction'''      )
							_a	     =				[[refs[i] for refs in labels] for i in range(UpperCamelCase      )]
							_a	     =				scb.corpus_bleu(
							    UpperCamelCase ,						UpperCamelCase ,						smooth_method=UpperCamelCase ,						smooth_value=UpperCamelCase ,						force=UpperCamelCase ,						lowercase=UpperCamelCase ,						use_effective_order=UpperCamelCase ,						**({'''tokenize''': tokenize} if tokenize else {}) ,						)
							return {"bleu": output.score}
def 		snake_case_    (UpperCamelCase       :  Optional[Any] ,						UpperCamelCase       :  Dict ,						UpperCamelCase       :  str ,						UpperCamelCase       :  List[Any]      ):





							'''simple docstring'''


							try:
														from jiwer import compute_measures
							except ImportError:
														raise ValueError(
														    f'jiwer has to be installed in order to apply the wer metric for {config_name}.'
														    '''You can install it via `pip install jiwer`.'''      )

							if concatenate_texts:
														_a	     =				compute_measures(UpperCamelCase ,						UpperCamelCase      )['''wer''']

														_a	     =				compute_measures(UpperCamelCase ,						UpperCamelCase ,						truth_transform=UpperCamelCase ,						hypothesis_transform=UpperCamelCase      )['''wer''']
														return {"wer": wer, "cer": cer}
							else:

														def compute_score(UpperCamelCase       :  Tuple ,						UpperCamelCase       :  Optional[int] ,						UpperCamelCase       :  Dict="wer"      ):
																					_a	     =				0
																					_a	     =				0
																					for prediction, reference in zip(UpperCamelCase ,						UpperCamelCase      ):
																												if score_type == "wer":
																																			_a	     =				compute_measures(UpperCamelCase ,						UpperCamelCase      )
																												elif score_type == "cer":
																																			_a	     =				compute_measures(
																																			    UpperCamelCase ,						UpperCamelCase ,						truth_transform=UpperCamelCase ,						hypothesis_transform=UpperCamelCase      )
																												incorrect += measures["substitutions"] + measures["deletions"] + measures["insertions"]
																												total += measures["substitutions"] + measures["deletions"] + measures["hits"]
																					return incorrect / total

														return {"wer": compute_score(UpperCamelCase ,						UpperCamelCase ,						'''wer'''      ), "cer": compute_score(UpperCamelCase ,						UpperCamelCase ,						'''cer'''      )}

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







							def    __lowerCAmelCase			(  self       :  Tuple					)			->							Dict:


														"""simple docstring"""


														if self.config_name not in _CONFIG_NAMES:
																					raise KeyError(F'You should supply a configuration name selected in {_CONFIG_NAMES}'					)

														_a	     =				'''int64''' if self.config_name in ['''fleurs-lang_id''', '''minds14'''] else '''string'''

														return datasets.MetricInfo(
														    description=_DESCRIPTION							,			citation=_CITATION							,			inputs_description=_KWARGS_DESCRIPTION							,			features=datasets.Features(
														        {'''predictions''': datasets.Value(lowerCAmelCase_					), '''references''': datasets.Value(lowerCAmelCase_					)}					)							,			codebase_urls=[]							,			reference_urls=[]							,			format='''numpy'''							,			)







							def    __lowerCAmelCase			(  self       :  Optional[int]							,			lowerCAmelCase_       :  Union[str, Any]							,			lowerCAmelCase_       :  Optional[Any]							,			lowerCAmelCase_       :  List[Any]=None							,			lowerCAmelCase_       :  int=None					)			->							Tuple:


														"""simple docstring"""


														_a	     =				bleu_kwargs if bleu_kwargs is not None else {}
														_a	     =				wer_kwargs if wer_kwargs is not None else {}

														if self.config_name == "fleurs-lang_id":
																					return {"accuracy": simple_accuracy(lowerCAmelCase_							,			lowerCAmelCase_					)}
														elif self.config_name == "minds14":
																					return fa_and_simple_accuracy(lowerCAmelCase_							,			lowerCAmelCase_					)
														elif self.config_name == "covost2":
																					_a	     =				bleu_kwargs.pop('''smooth_method'''							,			'''exp'''					)
																					_a	     =				bleu_kwargs.pop('''smooth_value'''							,			lowerCAmelCase_					)
																					_a	     =				bleu_kwargs.pop('''force'''							,			lowerCAmelCase_					)
																					_a	     =				bleu_kwargs.pop('''lowercase'''							,			lowerCAmelCase_					)
																					_a	     =				bleu_kwargs.pop('''tokenize'''							,			lowerCAmelCase_					)
																					_a	     =				bleu_kwargs.pop('''use_effective_order'''							,			lowerCAmelCase_					)
																					return bleu(
																					    preds=lowerCAmelCase_							,			labels=lowerCAmelCase_							,			smooth_method=lowerCAmelCase_							,			smooth_value=lowerCAmelCase_							,			force=lowerCAmelCase_							,			lowercase=lowerCAmelCase_							,			tokenize=lowerCAmelCase_							,			use_effective_order=lowerCAmelCase_							,			)
														elif self.config_name in ["fleurs-asr", "mls", "voxpopuli", "babel"]:
																					_a	     =				wer_kwargs.pop('''concatenate_texts'''							,			lowerCAmelCase_					)
																					return wer_and_cer(lowerCAmelCase_							,			lowerCAmelCase_							,			lowerCAmelCase_							,			self.config_name					)
														else:
																					raise KeyError(F'You should supply a configuration name selected in {_CONFIG_NAMES}'					)

