'''simple docstring'''






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 lowercase_       :







   """simple docstring"""

   def __init__(      self      :			List[str], UpperCamelCase__      :			List[str], UpperCamelCase__      :			List[str]=13, UpperCamelCase__      :			str=[30, 30], UpperCamelCase__      :			List[Any]=2, UpperCamelCase__      :			Optional[int]=3, UpperCamelCase__      :			Dict=True, UpperCamelCase__      :			int=True, UpperCamelCase__      :			List[str]=32, UpperCamelCase__      :			List[Any]=5, UpperCamelCase__      :			Tuple=4, UpperCamelCase__      :			Optional[Any]=37, UpperCamelCase__      :			Tuple="gelu", UpperCamelCase__      :			List[Any]=0.1, UpperCamelCase__      :			List[Any]=0.1, UpperCamelCase__      :			Dict=10, UpperCamelCase__      :			List[Any]=0.02, UpperCamelCase__      :			Optional[int]=3, UpperCamelCase__      :			str=None, UpperCamelCase__      :			List[str]=8, UpperCamelCase__      :			Tuple=10, )  ->			Any:
        _A    		=  parent
        _A    		=  batch_size
        _A    		=  image_size
        _A    		=  patch_size
        _A    		=  num_channels
        _A    		=  is_training
        _A    		=  use_labels
        _A    		=  hidden_size
        _A    		=  num_hidden_layers
        _A    		=  num_attention_heads
        _A    		=  intermediate_size
        _A    		=  hidden_act
        _A    		=  hidden_dropout_prob
        _A    		=  attention_probs_dropout_prob
        _A    		=  type_sequence_label_size
        _A    		=  initializer_range
        _A    		=  num_labels
        _A    		=  scope
        _A    		=  n_targets
        _A    		=  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
        _A    		=  (image_size[1] // patch_size) * (image_size[0] // patch_size)
        _A    		=  num_patches + 1 + self.num_detection_tokens
   def 	__UpperCAmelCase   (      self      :			str     )  ->			str:
        _A    		=  floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]]     )

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

        _A    		=  self.get_config()

        return config, pixel_values, labels
   def 	__UpperCAmelCase   (      self      :			int     )  ->			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 	__UpperCAmelCase   (      self      :			Union[str, Any], UpperCamelCase__      :			str, UpperCamelCase__      :			Optional[int], UpperCamelCase__      :			Optional[int]     )  ->			Optional[Any]:
        _A    		=  YolosModel(config=UpperCamelCase__     )
        model.to(UpperCamelCase__     )
        model.eval()
        _A    		=  model(UpperCamelCase__     )
        self.parent.assertEqual(
            result.last_hidden_state.shape, (self.batch_size, self.expected_seq_len, self.hidden_size)     )
   def 	__UpperCAmelCase   (      self      :			Tuple, UpperCamelCase__      :			str, UpperCamelCase__      :			List[Any], UpperCamelCase__      :			Optional[Any]     )  ->			Any:
        _A    		=  YolosForObjectDetection(UpperCamelCase__     )
        model.to(UpperCamelCase__     )
        model.eval()

        _A    		=  model(pixel_values=UpperCamelCase__     )
        _A    		=  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)     )

        _A    		=  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 	__UpperCAmelCase   (      self      :			Tuple     )  ->			Union[str, Any]:
        _A    		=  self.prepare_config_and_inputs()
        _A		,       _A		,       _A    		=  config_and_inputs
        _A    		=  {'pixel_values': pixel_values}
        return config, inputs_dict







@require_torch
class lowercase_       (		_UpperCamelCase    ,    _UpperCamelCase    ,    unittest.TestCase			):







   """simple docstring"""

   __lowerCAmelCase         =   (YolosModel, YolosForObjectDetection) if is_torch_available() else ()
   __lowerCAmelCase         =   (
       {"feature-extraction": YolosModel, "object-detection": YolosForObjectDetection} if is_torch_available() else {}
   )

   __lowerCAmelCase         =   False
   __lowerCAmelCase         =   False
   __lowerCAmelCase         =   False
   __lowerCAmelCase         =   False
   def 	__UpperCAmelCase   (      self      :			str, UpperCamelCase__      :			List[Any], UpperCamelCase__      :			Dict, UpperCamelCase__      :			List[Any]=False     )  ->			Union[str, Any]:
        _A    		=  super()._prepare_for_class(UpperCamelCase__, UpperCamelCase__, return_labels=UpperCamelCase__     )

        if return_labels:
             if model_class.__name__ == "YolosForObjectDetection":
                  _A    		=  []
                  for i in range(self.model_tester.batch_size     ):
                       _A    		=  {}
                       _A    		=  torch.ones(
                           size=(self.model_tester.n_targets,), device=UpperCamelCase__, dtype=torch.long     )
                       _A    		=  torch.ones(
                           self.model_tester.n_targets, 4, device=UpperCamelCase__, dtype=torch.float     )
                       labels.append(UpperCamelCase__     )
                  _A    		=  labels

        return inputs_dict
   def 	__UpperCAmelCase   (      self      :			Any     )  ->			Dict:
        _A    		=  YolosModelTester(self     )
        _A    		=  ConfigTester(self, config_class=UpperCamelCase__, has_text_modality=UpperCamelCase__, hidden_size=37     )
   def 	__UpperCAmelCase   (      self      :			Optional[int]     )  ->			Optional[int]:
        self.config_tester.run_common_tests()
   def 	__UpperCAmelCase   (      self      :			str     )  ->			int:
        # YOLOS does not use inputs_embeds
        pass
   def 	__UpperCAmelCase   (      self      :			str     )  ->			str:
        _A		,       _A    		=  self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _A    		=  model_class(UpperCamelCase__     )
             self.assertIsInstance(model.get_input_embeddings(), (nn.Module)     )
             _A    		=  model.get_output_embeddings()
             self.assertTrue(x is None or isinstance(UpperCamelCase__, nn.Linear     )     )
   def 	__UpperCAmelCase   (      self      :			List[str]     )  ->			int:
        _A		,       _A    		=  self.model_tester.prepare_config_and_inputs_for_common()

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

             _A    		=  ['pixel_values']
             self.assertListEqual(arg_names[:1], UpperCamelCase__     )
   def 	__UpperCAmelCase   (      self      :			Optional[int]     )  ->			Any:
        _A    		=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*UpperCamelCase__     )
   def 	__UpperCAmelCase   (      self      :			Optional[Any]     )  ->			List[str]:
        _A		,       _A    		=  self.model_tester.prepare_config_and_inputs_for_common()
        _A    		=  True

        # in YOLOS, the seq_len is different
        _A    		=  self.model_tester.expected_seq_len
        for model_class in self.all_model_classes:
             _A    		=  True
             _A    		=  False
             _A    		=  True
             _A    		=  model_class(UpperCamelCase__     )
             model.to(UpperCamelCase__     )
             model.eval()
             with torch.no_grad():
                  _A    		=  model(**self._prepare_for_class(UpperCamelCase__, UpperCamelCase__     )     )
             _A    		=  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"]
             _A    		=  True
             _A    		=  model_class(UpperCamelCase__     )
             model.to(UpperCamelCase__     )
             model.eval()
             with torch.no_grad():
                  _A    		=  model(**self._prepare_for_class(UpperCamelCase__, UpperCamelCase__     )     )
             _A    		=  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], )
             _A    		=  len(UpperCamelCase__     )

             # Check attention is always last and order is fine
             _A    		=  True
             _A    		=  True
             _A    		=  model_class(UpperCamelCase__     )
             model.to(UpperCamelCase__     )
             model.eval()
             with torch.no_grad():
                  _A    		=  model(**self._prepare_for_class(UpperCamelCase__, UpperCamelCase__     )     )

             _A    		=  1
             self.assertEqual(out_len + added_hidden_states, len(UpperCamelCase__     )     )

             _A    		=  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 	__UpperCAmelCase   (      self      :			Dict     )  ->			Dict:
        def check_hidden_states_output(UpperCamelCase__      :			int, UpperCamelCase__      :			Tuple, UpperCamelCase__      :			str     ):
             _A    		=  model_class(UpperCamelCase__     )
             model.to(UpperCamelCase__     )
             model.eval()

             with torch.no_grad():
                  _A    		=  model(**self._prepare_for_class(UpperCamelCase__, UpperCamelCase__     )     )

             _A    		=  outputs.hidden_states

             _A    		=  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
             _A    		=  self.model_tester.expected_seq_len

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

        _A		,       _A    		=  self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _A    		=  True
             check_hidden_states_output(UpperCamelCase__, UpperCamelCase__, UpperCamelCase__     )

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             _A    		=  True

             check_hidden_states_output(UpperCamelCase__, UpperCamelCase__, UpperCamelCase__     )
   def 	__UpperCAmelCase   (      self      :			str     )  ->			Optional[Any]:
        _A    		=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_object_detection(*UpperCamelCase__     )

   @slow
   def 	__UpperCAmelCase   (      self      :			Optional[int]     )  ->			str:
        for model_name in YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             _A    		=  YolosModel.from_pretrained(UpperCamelCase__     )
             self.assertIsNotNone(UpperCamelCase__     )






def  _SCREAMING_SNAKE_CASE		(      ):
     _A    		=  Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'				)
     return image







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







   """simple docstring"""

   @cached_property
   def 	__UpperCAmelCase   (      self      :			Dict     )  ->			Any:
        return AutoImageProcessor.from_pretrained('hustvl/yolos-small'     ) if is_vision_available() else None

   @slow
   def 	__UpperCAmelCase   (      self      :			List[Any]     )  ->			int:
        _A    		=  YolosForObjectDetection.from_pretrained('hustvl/yolos-small'     ).to(UpperCamelCase__     )

        _A    		=  self.default_image_processor
        _A    		=  prepare_img()
        _A    		=  image_processor(images=UpperCamelCase__, return_tensors='pt'     ).to(UpperCamelCase__     )

        # forward pass
        with torch.no_grad():
             _A    		=  model(inputs.pixel_values     )

        # verify outputs
        _A    		=  torch.Size((1, 1_00, 92)     )
        self.assertEqual(outputs.logits.shape, UpperCamelCase__     )

        _A    		=  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__, )
        _A    		=  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
        _A    		=  image_processor.post_process_object_detection(
            UpperCamelCase__, threshold=0.3, target_sizes=[image.size[::-1]]     )[0]
        _A    		=  torch.tensor([0.9_994, 0.9_790, 0.9_964, 0.9_972, 0.9_861]     ).to(UpperCamelCase__     )
        _A    		=  [75, 75, 17, 63, 17]
        _A    		=  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__     )     )




'''simple docstring'''






from typing import Dict, List

from nltk.translate import gleu_score

import datasets
from datasets import MetricInfo


_UpperCAmelCase    :     Any         =       '''\
@misc{wu2016googles,
      title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},
      author={Yonghui Wu and Mike Schuster and Zhifeng Chen and Quoc V. Le and Mohammad Norouzi and Wolfgang Macherey
              and Maxim Krikun and Yuan Cao and Qin Gao and Klaus Macherey and Jeff Klingner and Apurva Shah and Melvin
              Johnson and Xiaobing Liu and Łukasz Kaiser and Stephan Gouws and Yoshikiyo Kato and Taku Kudo and Hideto
              Kazawa and Keith Stevens and George Kurian and Nishant Patil and Wei Wang and Cliff Young and
              Jason Smith and Jason Riesa and Alex Rudnick and Oriol Vinyals and Greg Corrado and Macduff Hughes
              and Jeffrey Dean},
      year={2016},
      eprint={1609.08144},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
'''

_UpperCAmelCase    :     str         =       '''\
The BLEU score has some undesirable properties when used for single
sentences, as it was designed to be a corpus measure. We therefore
use a slightly different score for our RL experiments which we call
the \'GLEU score\'. For the GLEU score, we record all sub-sequences of
1, 2, 3 or 4 tokens in output and target sequence (n-grams). We then
compute a recall, which is the ratio of the number of matching n-grams
to the number of total n-grams in the target (ground truth) sequence,
and a precision, which is the ratio of the number of matching n-grams
to the number of total n-grams in the generated output sequence. Then
GLEU score is simply the minimum of recall and precision. This GLEU
score\'s range is always between 0 (no matches) and 1 (all match) and
it is symmetrical when switching output and target. According to
our experiments, GLEU score correlates quite well with the BLEU
metric on a corpus level but does not have its drawbacks for our per
sentence reward objective.
'''

_UpperCAmelCase    :     Union[str, Any]         =       '''\
Computes corpus-level Google BLEU (GLEU) score of translated segments against one or more references.
Instead of averaging the sentence level GLEU scores (i.e. macro-average precision), Wu et al. (2016) sum up the matching
tokens and the max of hypothesis and reference tokens for each sentence, then compute using the aggregate values.

Args:
    predictions (list of str): list of translations to score.
        Each translation should be tokenized into a list of tokens.
    references (list of list of str): list of lists of references for each translation.
        Each reference should be tokenized into a list of tokens.
    min_len (int): The minimum order of n-gram this function should extract. Defaults to 1.
    max_len (int): The maximum order of n-gram this function should extract. Defaults to 4.

Returns:
    \'google_bleu\': google_bleu score

Examples:
    Example 1:
        >>> hyp1 = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'which\',
        ...         \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'always\',
        ...         \'disobeys\', \'the\', \'commands\', \'of\', \'the\', \'cat\']
        >>> ref1a = [\'It\', \'is\', \'the\', \'guiding\', \'principle\', \'which\',
        ...          \'guarantees\', \'the\', \'rubber\', \'duck\', \'forces\', \'never\',
        ...          \'being\', \'under\', \'the\', \'command\', \'of\', \'the\', \'cat\']

        >>> hyp2 = [\'he\', \'read\', \'the\', \'book\', \'because\', \'he\', \'was\',
        ...         \'interested\', \'in\', \'world\', \'history\']
        >>> ref2a = [\'he\', \'was\', \'interested\', \'in\', \'world\', \'history\',
        ...          \'because\', \'he\', \'read\', \'the\', \'book\']

        >>> list_of_references = [[ref1a], [ref2a]]
        >>> hypotheses = [hyp1, hyp2]
        >>> google_bleu = datasets.load_metric("google_bleu")
        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references)
        >>> print(round(results["google_bleu"], 2))
        0.44

    Example 2:
        >>> hyp1 = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'which\',
        ...         \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'always\',
        ...         \'disobeys\', \'the\', \'commands\', \'of\', \'the\', \'cat\']
        >>> ref1a = [\'It\', \'is\', \'the\', \'guiding\', \'principle\', \'which\',
        ...          \'guarantees\', \'the\', \'rubber\', \'duck\', \'forces\', \'never\',
        ...          \'being\', \'under\', \'the\', \'command\', \'of\', \'the\', \'cat\']
        >>> ref1b = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'that\',
        ...          \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'will\', \'never\',
        ...          \'heed\', \'the\', \'cat\', \'commands\']
        >>> ref1c = [\'It\', \'is\', \'the\', \'practical\', \'guide\', \'for\', \'the\',
        ...          \'rubber\', \'duck\', \'army\', \'never\', \'to\', \'heed\', \'the\', \'directions\',
        ...          \'of\', \'the\', \'cat\']

        >>> hyp2 = [\'he\', \'read\', \'the\', \'book\', \'because\', \'he\', \'was\',
        ...         \'interested\', \'in\', \'world\', \'history\']
        >>> ref2a = [\'he\', \'was\', \'interested\', \'in\', \'world\', \'history\',
        ...          \'because\', \'he\', \'read\', \'the\', \'book\']

        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]
        >>> hypotheses = [hyp1, hyp2]
        >>> google_bleu = datasets.load_metric("google_bleu")
        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references)
        >>> print(round(results["google_bleu"], 2))
        0.61

    Example 3:
        >>> hyp1 = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'which\',
        ...         \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'always\',
        ...         \'disobeys\', \'the\', \'commands\', \'of\', \'the\', \'cat\']
        >>> ref1a = [\'It\', \'is\', \'the\', \'guiding\', \'principle\', \'which\',
        ...          \'guarantees\', \'the\', \'rubber\', \'duck\', \'forces\', \'never\',
        ...          \'being\', \'under\', \'the\', \'command\', \'of\', \'the\', \'cat\']
        >>> ref1b = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'that\',
        ...          \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'will\', \'never\',
        ...          \'heed\', \'the\', \'cat\', \'commands\']
        >>> ref1c = [\'It\', \'is\', \'the\', \'practical\', \'guide\', \'for\', \'the\',
        ...          \'rubber\', \'duck\', \'army\', \'never\', \'to\', \'heed\', \'the\', \'directions\',
        ...          \'of\', \'the\', \'cat\']

        >>> hyp2 = [\'he\', \'read\', \'the\', \'book\', \'because\', \'he\', \'was\',
        ...         \'interested\', \'in\', \'world\', \'history\']
        >>> ref2a = [\'he\', \'was\', \'interested\', \'in\', \'world\', \'history\',
        ...          \'because\', \'he\', \'read\', \'the\', \'book\']

        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]
        >>> hypotheses = [hyp1, hyp2]
        >>> google_bleu = datasets.load_metric("google_bleu")
        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references, min_len=2)
        >>> print(round(results["google_bleu"], 2))
        0.53

    Example 4:
        >>> hyp1 = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'which\',
        ...         \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'always\',
        ...         \'disobeys\', \'the\', \'commands\', \'of\', \'the\', \'cat\']
        >>> ref1a = [\'It\', \'is\', \'the\', \'guiding\', \'principle\', \'which\',
        ...          \'guarantees\', \'the\', \'rubber\', \'duck\', \'forces\', \'never\',
        ...          \'being\', \'under\', \'the\', \'command\', \'of\', \'the\', \'cat\']
        >>> ref1b = [\'It\', \'is\', \'a\', \'guide\', \'to\', \'action\', \'that\',
        ...          \'ensures\', \'that\', \'the\', \'rubber\', \'duck\', \'will\', \'never\',
        ...          \'heed\', \'the\', \'cat\', \'commands\']
        >>> ref1c = [\'It\', \'is\', \'the\', \'practical\', \'guide\', \'for\', \'the\',
        ...          \'rubber\', \'duck\', \'army\', \'never\', \'to\', \'heed\', \'the\', \'directions\',
        ...          \'of\', \'the\', \'cat\']

        >>> hyp2 = [\'he\', \'read\', \'the\', \'book\', \'because\', \'he\', \'was\',
        ...         \'interested\', \'in\', \'world\', \'history\']
        >>> ref2a = [\'he\', \'was\', \'interested\', \'in\', \'world\', \'history\',
        ...          \'because\', \'he\', \'read\', \'the\', \'book\']

        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]
        >>> hypotheses = [hyp1, hyp2]
        >>> google_bleu = datasets.load_metric("google_bleu")
        >>> results = google_bleu.compute(predictions=hypotheses,references=list_of_references, min_len=2, max_len=6)
        >>> print(round(results["google_bleu"], 2))
        0.4
'''







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







   """simple docstring"""

   def 	__UpperCAmelCase   (      self      :			List[Any]     )  ->			MetricInfo:
        return datasets.MetricInfo(
            description=_DESCRIPTION, citation=_CITATION, inputs_description=_KWARGS_DESCRIPTION, features=datasets.Features(
                {
                    'predictions': datasets.Sequence(datasets.Value('string', id='token'     ), id='sequence'     ),
                    'references': datasets.Sequence(
                        datasets.Sequence(datasets.Value('string', id='token'     ), id='sequence'     ), id='references'     ),
                }     ), )

   def 	__UpperCAmelCase   (      self      :			Dict, UpperCamelCase__      :			List[List[List[str]]], UpperCamelCase__      :			List[List[str]], UpperCamelCase__      :			int = 1, UpperCamelCase__      :			int = 4, )  ->			Dict[str, float]:
        return {
            "google_bleu": gleu_score.corpus_gleu(
                list_of_references=UpperCamelCase__, hypotheses=UpperCamelCase__, min_len=UpperCamelCase__, max_len=UpperCamelCase__     )
        }



