import inspect
import unittest

from transformers import YolosConfig
from transformers.testing_utils import require_torch, require_vision, 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
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch
	from torch import nn

	from transformers import YolosForObjectDetection, YolosModel
	from transformers.models.yolos.modeling_yolos import YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import AutoImageProcessor

class        UpperCamelCase						:





						def __init__(self			,     __UpperCamelCase			,     __UpperCamelCase=13			,     __UpperCamelCase=[30, 30]			,     __UpperCamelCase=2			,     __UpperCamelCase=3			,     __UpperCamelCase=True			,     __UpperCamelCase=True			,     __UpperCamelCase=32			,     __UpperCamelCase=5			,     __UpperCamelCase=4			,     __UpperCamelCase=37			,     __UpperCamelCase="gelu"			,     __UpperCamelCase=0.1			,     __UpperCamelCase=0.1			,     __UpperCamelCase=10			,     __UpperCamelCase=0.02			,     __UpperCamelCase=3			,     __UpperCamelCase=None			,     __UpperCamelCase=8			,     __UpperCamelCase=10			,     )				->				Optional[Any]:
												UpperCamelCase_		:							Union[str, Any]  =		parent
												UpperCamelCase_		:							Dict  =		batch_size
												UpperCamelCase_		:							Dict  =		image_size
												UpperCamelCase_		:							str  =		patch_size
												UpperCamelCase_		:							List[Any]  =		num_channels
												UpperCamelCase_		:							Dict  =		is_training
												UpperCamelCase_		:							Any  =		use_labels
												UpperCamelCase_		:							List[Any]  =		hidden_size
												UpperCamelCase_		:							Dict  =		num_hidden_layers
												UpperCamelCase_		:							int  =		num_attention_heads
												UpperCamelCase_		:							Optional[int]  =		intermediate_size
												UpperCamelCase_		:							int  =		hidden_act
												UpperCamelCase_		:							Tuple  =		hidden_dropout_prob
												UpperCamelCase_		:							Union[str, Any]  =		attention_probs_dropout_prob
												UpperCamelCase_		:							int  =		type_sequence_label_size
												UpperCamelCase_		:							Union[str, Any]  =		initializer_range
												UpperCamelCase_		:							Union[str, Any]  =		num_labels
												UpperCamelCase_		:							Tuple  =		scope
												UpperCamelCase_		:							Tuple  =		n_targets
												UpperCamelCase_		:							Dict  =		num_detection_tokens
												# we set the expected sequence length (which is used in several tests)
												# expected sequence length = num_patches + 1 (we add 1 for the [CLS] token) + num_detection_tokens
												UpperCamelCase_		:							Tuple  =		(image_size[1] // patch_size) * (image_size[0] // patch_size)
												UpperCamelCase_		:							Dict  =		num_patches + 1 + self.num_detection_tokens





						def        A_							(self						)				->				Optional[Any]:
												UpperCamelCase_		:							Optional[int]  =		floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]]						)

												UpperCamelCase_		:							Union[str, Any]  =		None
												if self.use_labels:
																		# labels is a list of Dict (each Dict being the labels for a given example in the batch)
																		UpperCamelCase_		:							List[Any]  =		[]
																		for i in range(self.batch_size						):
																								UpperCamelCase_		:							str  =		{}
																								UpperCamelCase_		:							Union[str, Any]  =		torch.randint(
																								    high=self.num_labels			,     size=(self.n_targets,)			,     device=__UpperCamelCase						)
																								UpperCamelCase_		:							Tuple  =		torch.rand(self.n_targets			,     4			,     device=__UpperCamelCase						)
																								labels.append(__UpperCamelCase						)

												UpperCamelCase_		:							Tuple  =		self.get_config()

												return config, pixel_values, labels





						def        A_							(self						)				->				List[Any]:
												return YolosConfig(
												    image_size=self.image_size			,     patch_size=self.patch_size			,     num_channels=self.num_channels			,     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			,     is_decoder=__UpperCamelCase			,     initializer_range=self.initializer_range			,     num_detection_tokens=self.num_detection_tokens			,     num_labels=self.num_labels			,     )





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)				->				Union[str, Any]:
												UpperCamelCase_		:							Dict  =		YolosModel(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												UpperCamelCase_		:							Union[str, Any]  =		model(__UpperCamelCase						)
												self.parent.assertEqual(
												    result.last_hidden_state.shape			,     (self.batch_size, self.expected_seq_len, self.hidden_size)						)





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)				->				Tuple:
												UpperCamelCase_		:							Union[str, Any]  =		YolosForObjectDetection(__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()

												UpperCamelCase_		:							Tuple  =		model(pixel_values=__UpperCamelCase						)
												UpperCamelCase_		:							str  =		model(__UpperCamelCase						)

												self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.num_detection_tokens, self.num_labels + 1)						)
												self.parent.assertEqual(result.pred_boxes.shape			,     (self.batch_size, self.num_detection_tokens, 4)						)

												UpperCamelCase_		:							Dict  =		model(pixel_values=__UpperCamelCase			,     labels=__UpperCamelCase						)

												self.parent.assertEqual(result.loss.shape			,     ()						)
												self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.num_detection_tokens, self.num_labels + 1)						)
												self.parent.assertEqual(result.pred_boxes.shape			,     (self.batch_size, self.num_detection_tokens, 4)						)





						def        A_							(self						)				->				Any:
												UpperCamelCase_		:							Any  =		self.prepare_config_and_inputs()
												UpperCamelCase_,UpperCamelCase_,UpperCamelCase_		:							Tuple  =		config_and_inputs
												UpperCamelCase_		:							str  =		{"""pixel_values""": pixel_values}
												return config, inputs_dict


@require_torch
class        UpperCamelCase						(				__a	,	__a	,	unittest.TestCase				):
						a__		:str      =			(YolosModel, YolosForObjectDetection) if is_torch_available() else ()
						a__		:List[Any]      =			(
						    {'''feature-extraction''': YolosModel, '''object-detection''': YolosForObjectDetection} if is_torch_available() else {}
						)

						a__		:Optional[Any]      =			False
						a__		:Union[str, Any]      =			False
						a__		:Any      =			False
						a__		:List[Any]      =			False





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase=False						)				->				Union[str, Any]:
												UpperCamelCase_		:							str  =		super()._prepare_for_class(__UpperCamelCase			,     __UpperCamelCase			,     return_labels=__UpperCamelCase						)

												if return_labels:
																		if model_class.__name__ == "YolosForObjectDetection":
																								UpperCamelCase_		:							str  =		[]
																								for i in range(self.model_tester.batch_size						):
																														UpperCamelCase_		:							Optional[int]  =		{}
																														UpperCamelCase_		:							Tuple  =		torch.ones(
																														    size=(self.model_tester.n_targets,)			,     device=__UpperCamelCase			,     dtype=torch.long						)
																														UpperCamelCase_		:							List[Any]  =		torch.ones(
																														    self.model_tester.n_targets			,     4			,     device=__UpperCamelCase			,     dtype=torch.float						)
																														labels.append(__UpperCamelCase						)
																								UpperCamelCase_		:							Dict  =		labels

												return inputs_dict





						def        A_							(self						)				->				Optional[Any]:
												UpperCamelCase_		:							List[Any]  =		YolosModelTester(self						)
												UpperCamelCase_		:							str  =		ConfigTester(self			,     config_class=__UpperCamelCase			,     has_text_modality=__UpperCamelCase			,     hidden_size=37						)





						def        A_							(self						)				->				List[str]:
												self.config_tester.run_common_tests()





						def        A_							(self						)				->				Optional[int]:
												# YOLOS does not use inputs_embeds
												pass





						def        A_							(self						)				->				Optional[Any]:
												UpperCamelCase_,UpperCamelCase_		:							str  =		self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																		UpperCamelCase_		:							Optional[int]  =		model_class(__UpperCamelCase						)
																		self.assertIsInstance(model.get_input_embeddings()			,     (nn.Module)						)
																		UpperCamelCase_		:							Optional[Any]  =		model.get_output_embeddings()
																		self.assertTrue(x is None or isinstance(__UpperCamelCase			,     nn.Linear						)						)





						def        A_							(self						)				->				int:
												UpperCamelCase_,UpperCamelCase_		:							List[str]  =		self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																		UpperCamelCase_		:							Dict  =		model_class(__UpperCamelCase						)
																		UpperCamelCase_		:							List[Any]  =		inspect.signature(model.forward						)
																		# signature.parameters is an OrderedDict => so arg_names order is deterministic
																		UpperCamelCase_		:							Optional[int]  =		[*signature.parameters.keys()]

																		UpperCamelCase_		:							str  =		["""pixel_values"""]
																		self.assertListEqual(arg_names[:1]			,     __UpperCamelCase						)





						def        A_							(self						)				->				List[Any]:
												UpperCamelCase_		:							Dict  =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*__UpperCamelCase						)





						def        A_							(self						)				->				Optional[Any]:
												UpperCamelCase_,UpperCamelCase_		:							Optional[int]  =		self.model_tester.prepare_config_and_inputs_for_common()
												UpperCamelCase_		:							Dict  =		True

												# in YOLOS, the seq_len is different
												UpperCamelCase_		:							List[Any]  =		self.model_tester.expected_seq_len
												for model_class in self.all_model_classes:
																		UpperCamelCase_		:							int  =		True
																		UpperCamelCase_		:							Any  =		False
																		UpperCamelCase_		:							Tuple  =		True
																		UpperCamelCase_		:							int  =		model_class(__UpperCamelCase						)
																		model.to(__UpperCamelCase						)
																		model.eval()
																		with torch.no_grad():
																								UpperCamelCase_		:							Tuple  =		model(**self._prepare_for_class(__UpperCamelCase			,     __UpperCamelCase						)						)
																		UpperCamelCase_		:							str  =		outputs.attentions
																		self.assertEqual(len(__UpperCamelCase						)			,     self.model_tester.num_hidden_layers						)

																		# check that output_attentions also work using config
																		del inputs_dict["output_attentions"]
																		UpperCamelCase_		:							List[Any]  =		True
																		UpperCamelCase_		:							List[Any]  =		model_class(__UpperCamelCase						)
																		model.to(__UpperCamelCase						)
																		model.eval()
																		with torch.no_grad():
																								UpperCamelCase_		:							Dict  =		model(**self._prepare_for_class(__UpperCamelCase			,     __UpperCamelCase						)						)
																		UpperCamelCase_		:							Optional[int]  =		outputs.attentions
																		self.assertEqual(len(__UpperCamelCase						)			,     self.model_tester.num_hidden_layers						)

																		self.assertListEqual(
																		    list(attentions[0].shape[-3:]						)			,     [self.model_tester.num_attention_heads, seq_len, seq_len]			,     )
																		UpperCamelCase_		:							Union[str, Any]  =		len(__UpperCamelCase						)

																		# Check attention is always last and order is fine
																		UpperCamelCase_		:							int  =		True
																		UpperCamelCase_		:							Any  =		True
																		UpperCamelCase_		:							int  =		model_class(__UpperCamelCase						)
																		model.to(__UpperCamelCase						)
																		model.eval()
																		with torch.no_grad():
																								UpperCamelCase_		:							List[str]  =		model(**self._prepare_for_class(__UpperCamelCase			,     __UpperCamelCase						)						)

																		UpperCamelCase_		:							int  =		1
																		self.assertEqual(out_len + added_hidden_states			,     len(__UpperCamelCase						)						)

																		UpperCamelCase_		:							Union[str, Any]  =		outputs.attentions

																		self.assertEqual(len(__UpperCamelCase						)			,     self.model_tester.num_hidden_layers						)
																		self.assertListEqual(
																		    list(self_attentions[0].shape[-3:]						)			,     [self.model_tester.num_attention_heads, seq_len, seq_len]			,     )





						def        A_							(self						)				->				List[Any]:
												def check_hidden_states_output(__UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						):
																		UpperCamelCase_		:							List[Any]  =		model_class(__UpperCamelCase						)
																		model.to(__UpperCamelCase						)
																		model.eval()

																		with torch.no_grad():
																								UpperCamelCase_		:							Tuple  =		model(**self._prepare_for_class(__UpperCamelCase			,     __UpperCamelCase						)						)

																		UpperCamelCase_		:							Any  =		outputs.hidden_states

																		UpperCamelCase_		:							Any  =		getattr(
																		    self.model_tester			,     """expected_num_hidden_layers"""			,     self.model_tester.num_hidden_layers + 1						)
																		self.assertEqual(len(__UpperCamelCase						)			,     __UpperCamelCase						)

																		# YOLOS has a different seq_length
																		UpperCamelCase_		:							List[Any]  =		self.model_tester.expected_seq_len

																		self.assertListEqual(
																		    list(hidden_states[0].shape[-2:]						)			,     [seq_length, self.model_tester.hidden_size]			,     )

												UpperCamelCase_,UpperCamelCase_		:							Union[str, Any]  =		self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																		UpperCamelCase_		:							Optional[int]  =		True
																		check_hidden_states_output(__UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)

																		# check that output_hidden_states also work using config
																		del inputs_dict["output_hidden_states"]
																		UpperCamelCase_		:							str  =		True

																		check_hidden_states_output(__UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)





						def        A_							(self						)				->				Optional[int]:
												UpperCamelCase_		:							Union[str, Any]  =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_object_detection(*__UpperCamelCase						)





						@slow
						def        A_							(self						)				->				Union[str, Any]:
												for model_name in YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		UpperCamelCase_		:							List[str]  =		YolosModel.from_pretrained(__UpperCamelCase						)
																		self.assertIsNotNone(__UpperCamelCase						)






def     lowerCAmelCase_			(   ):
						UpperCamelCase_		:							Union[str, Any]  =		Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			)
						return image







@require_torch
@require_vision
class        UpperCamelCase						(				unittest.TestCase				):





						@cached_property
						def        A_							(self						)				->				Optional[Any]:
												return AutoImageProcessor.from_pretrained("""hustvl/yolos-small"""						) if is_vision_available() else None





						@slow
						def        A_							(self						)				->				Tuple:
												UpperCamelCase_		:							Optional[int]  =		YolosForObjectDetection.from_pretrained("""hustvl/yolos-small"""						).to(__UpperCamelCase						)

												UpperCamelCase_		:							Any  =		self.default_image_processor
												UpperCamelCase_		:							List[str]  =		prepare_img()
												UpperCamelCase_		:							Dict  =		image_processor(images=__UpperCamelCase			,     return_tensors="""pt"""						).to(__UpperCamelCase						)

												# forward pass
												with torch.no_grad():
																		UpperCamelCase_		:							Union[str, Any]  =		model(inputs.pixel_values						)

												# verify outputs
												UpperCamelCase_		:							Union[str, Any]  =		torch.Size((1, 100, 92)						)
												self.assertEqual(outputs.logits.shape			,     __UpperCamelCase						)

												UpperCamelCase_		:							str  =		torch.tensor(
												    [[-24.0_248, -10.3_024, -14.8_290], [-42.0_392, -16.8_200, -27.4_334], [-27.2_743, -11.8_154, -18.7_148]]			,     device=__UpperCamelCase			,     )
												UpperCamelCase_		:							Any  =		torch.tensor(
												    [[0.2_559, 0.5_455, 0.4_706], [0.2_989, 0.7_279, 0.1_875], [0.7_732, 0.4_017, 0.4_462]]			,     device=__UpperCamelCase						)
												self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]			,     __UpperCamelCase			,     atol=1E-4						)						)
												self.assertTrue(torch.allclose(outputs.pred_boxes[0, :3, :3]			,     __UpperCamelCase			,     atol=1E-4						)						)

												# verify postprocessing
												UpperCamelCase_		:							Optional[int]  =		image_processor.post_process_object_detection(
												    __UpperCamelCase			,     threshold=0.3			,     target_sizes=[image.size[::-1]]						)[0]
												UpperCamelCase_		:							List[str]  =		torch.tensor([0.9_994, 0.9_790, 0.9_964, 0.9_972, 0.9_861]						).to(__UpperCamelCase						)
												UpperCamelCase_		:							List[Any]  =		[75, 75, 17, 63, 17]
												UpperCamelCase_		:							Optional[Any]  =		torch.tensor([335.0_609, 79.3_848, 375.4_216, 187.2_495]						).to(__UpperCamelCase						)

												self.assertEqual(len(results["""scores"""]						)			,     5						)
												self.assertTrue(torch.allclose(results["""scores"""]			,     __UpperCamelCase			,     atol=1E-4						)						)
												self.assertSequenceEqual(results["""labels"""].tolist()			,     __UpperCamelCase						)
												self.assertTrue(torch.allclose(results["""boxes"""][0, :]			,     __UpperCamelCase						)						)







import sacrebleu as scb
from packaging import version
from sacrebleu import CHRF

import datasets


SCREAMING_SNAKE_CASE		:     Tuple         =	"\\n@inproceedings{popovic-2015-chrf,\n    title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",\n    author = \"Popovi{\'c}, Maja\",\n    booktitle = \"Proceedings of the Tenth Workshop on Statistical Machine Translation\",\n    month = sep,\n    year = \"2015\",\n    address = \"Lisbon, Portugal\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://aclanthology.org/W15-3049\",\n    doi = \"10.18653/v1/W15-3049\",\n    pages = \"392--395\",\n}\n@inproceedings{popovic-2017-chrf,\n    title = \"chr{F}++: words helping character n-grams\",\n    author = \"Popovi{\'c}, Maja\",\n    booktitle = \"Proceedings of the Second Conference on Machine Translation\",\n    month = sep,\n    year = \"2017\",\n    address = \"Copenhagen, Denmark\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://aclanthology.org/W17-4770\",\n    doi = \"10.18653/v1/W17-4770\",\n    pages = \"612--618\",\n}\n@inproceedings{post-2018-call,\n    title = \"A Call for Clarity in Reporting {BLEU} Scores\",\n    author = \"Post, Matt\",\n    booktitle = \"Proceedings of the Third Conference on Machine Translation: Research Papers\",\n    month = oct,\n    year = \"2018\",\n    address = \"Belgium, Brussels\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://www.aclweb.org/anthology/W18-6319\",\n    pages = \"186--191\",\n}\n"

SCREAMING_SNAKE_CASE		:     Tuple         =	"\\nChrF and ChrF++ are two MT evaluation metrics. They both use the F-score statistic for character n-gram matches,\nand ChrF++ adds word n-grams as well which correlates more strongly with direct assessment. We use the implementation\nthat is already present in sacrebleu.\n\nThe implementation here is slightly different from sacrebleu in terms of the required input format. The length of\nthe references and hypotheses lists need to be the same, so you may need to transpose your references compared to\nsacrebleu's required input format. See https://github.com/huggingface/datasets/issues/3154#issuecomment-950746534\n\nSee the README.md file at https://github.com/mjpost/sacreBLEU#chrf--chrf for more information.\n"

SCREAMING_SNAKE_CASE		:     Optional[int]         =	"\nProduces ChrF(++) scores for hypotheses given reference translations.\n\nArgs:\n    predictions (list of str): The predicted sentences.\n    references (list of list of str): The references. There should be one reference sub-list for each prediction sentence.\n    char_order (int): Character n-gram order. Defaults to `6`.\n    word_order (int): Word n-gram order. If equals to `2`, the metric is referred to as chrF++. Defaults to `0`.\n    beta (int): Determine the importance of recall w.r.t precision. Defaults to `2`.\n    lowercase (bool): if `True`, enables case-insensitivity. Defaults to `False`.\n    whitespace (bool): If `True`, include whitespaces when extracting character n-grams.\n    eps_smoothing (bool): If `True`, applies epsilon smoothing similar\n    to reference chrF++.py, NLTK and Moses implementations. If `False`,\n    it takes into account effective match order similar to sacreBLEU < 2.0.0. Defaults to `False`.\n\nReturns:\n    'score' (float): The chrF (chrF++) score,\n    'char_order' (int): The character n-gram order,\n    'word_order' (int): The word n-gram order. If equals to 2, the metric is referred to as chrF++,\n    'beta' (int): Determine the importance of recall w.r.t precision\n\nExamples:\n    Example 1--a simple example of calculating chrF:\n        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]\n        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]\n        >>> chrf = datasets.load_metric(\"chrf\")\n        >>> results = chrf.compute(predictions=prediction, references=reference)\n        >>> print(results)\n        {'score': 84.64214891738334, 'char_order': 6, 'word_order': 0, 'beta': 2}\n\n    Example 2--the same example, but with the argument word_order=2, to calculate chrF++ instead of chrF:\n        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]\n        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]\n        >>> chrf = datasets.load_metric(\"chrf\")\n        >>> results = chrf.compute(predictions=prediction,\n        ...                         references=reference,\n        ...                         word_order=2)\n        >>> print(results)\n        {'score': 82.87263732906315, 'char_order': 6, 'word_order': 2, 'beta': 2}\n\n    Example 3--the same chrF++ example as above, but with `lowercase=True` to normalize all case:\n        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]\n        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]\n        >>> chrf = datasets.load_metric(\"chrf\")\n        >>> results = chrf.compute(predictions=prediction,\n        ...                         references=reference,\n        ...                         word_order=2,\n        ...                         lowercase=True)\n        >>> print(results)\n        {'score': 92.12853119829202, 'char_order': 6, 'word_order': 2, 'beta': 2}\n"

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





						def        A_							(self						)				->				Dict:
												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\"`."""						)
												return datasets.MetricInfo(
												    description=_DESCRIPTION			,     citation=_CITATION			,     homepage="""https://github.com/mjpost/sacreBLEU#chrf--chrf"""			,     inputs_description=_KWARGS_DESCRIPTION			,     features=datasets.Features(
												        {
												            """predictions""": datasets.Value("""string"""			,     id="""sequence"""						),
												            """references""": datasets.Sequence(datasets.Value("""string"""			,     id="""sequence"""						)			,     id="""references"""						),
												        }						)			,     codebase_urls=["""https://github.com/mjpost/sacreBLEU#chrf--chrf"""]			,     reference_urls=[
												        """https://github.com/m-popovic/chrF""",
												    ]			,     )





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase = CHRF.CHAR_ORDER			,     __UpperCamelCase = CHRF.WORD_ORDER			,     __UpperCamelCase = CHRF.BETA			,     __UpperCamelCase = False			,     __UpperCamelCase = False			,     __UpperCamelCase = False			,     )				->				List[Any]:
												UpperCamelCase_		:							List[str]  =		len(references[0]						)
												if any(len(__UpperCamelCase						) != references_per_prediction for refs in references						):
																		raise ValueError("""Sacrebleu requires the same number of references for each prediction"""						)
												UpperCamelCase_		:							Optional[Any]  =		[[refs[i] for refs in references] for i in range(__UpperCamelCase						)]

												UpperCamelCase_		:							List[Any]  =		CHRF(__UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)
												UpperCamelCase_		:							int  =		sb_chrf.corpus_score(__UpperCamelCase			,     __UpperCamelCase						)

												return {
												    "score": output.score,
												    "char_order": output.char_order,
												    "word_order": output.word_order,
												    "beta": output.beta,
												}






