






import inspect

import jax
import jax.lax as lax
import jax.numpy as jnp

from ..utils import add_start_docstrings
from ..utils.logging import get_logger


lowerCamelCase			:					int					      =	get_logger(__name__)


lowerCamelCase			:					Optional[int]					      =	R'''
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary.

            Indices can be obtained using [`PreTrainedTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        scores (`jnp.ndarray` of shape `(batch_size, config.vocab_size)`):
            Prediction scores of a language modeling head. These can be logits for each vocabulary when not using beam
            search or log softmax for each vocabulary token when using beam search
        kwargs (`Dict[str, Any]`, *optional*):
            Additional logits processor specific kwargs.

    Return:
        `jnp.ndarray` of shape `(batch_size, config.vocab_size)`: The processed prediction scores.

'''



class 							_UpperCamelCase			:


      @add_start_docstrings(lowercase_	)
      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           raise NotImplementedError(
               F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""	)



class 							_UpperCamelCase			:


      @add_start_docstrings(lowercase_	)
      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           raise NotImplementedError(
               F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""	)



class 							_UpperCamelCase			(a_			):


      @add_start_docstrings(lowercase_	)
      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						**__UpperCamelCase	)->	jnp.ndarray:







           for processor in self:
                __lowerCAmelCase								=					inspect.signature(processor.__call__	).parameters
                if len(lowercase_	) > 3:
                     if not all(arg in kwargs for arg in list(function_args.keys()	)[2:]	):
                          raise ValueError(
                              F"""Make sure that all the required parameters: {list(function_args.keys()	)} for """
                              F"""{processor.__class__} are passed to the logits processor."""	)
                     __lowerCAmelCase								=					processor(lowercase_					,						lowercase_					,						lowercase_					,						**lowercase_	)
                else:
                     __lowerCAmelCase								=					processor(lowercase_					,						lowercase_					,						lowercase_	)
           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase	)->	Tuple:







           if not isinstance(lowercase_					,						lowercase_	) or not (temperature > 0):
                raise ValueError(F"""`temperature` has to be a strictly positive float, but is {temperature}"""	)

           __lowerCAmelCase								=					temperature


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase								=					scores / self.temperature
           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase = -float("Inf"	)					,						__UpperCamelCase = 1	)->	Optional[Any]:







           if not isinstance(lowercase_					,						lowercase_	) or (top_p < 0 or top_p > 1.0):
                raise ValueError(F"""`top_p` has to be a float > 0 and < 1, but is {top_p}"""	)
           if not isinstance(lowercase_					,						lowercase_	) or (min_tokens_to_keep < 1):
                raise ValueError(F"""`min_tokens_to_keep` has to be a positive integer, but is {min_tokens_to_keep}"""	)

           __lowerCAmelCase								=					top_p
           __lowerCAmelCase								=					filter_value
           __lowerCAmelCase								=					min_tokens_to_keep


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase			, __lowerCAmelCase								=					lax.top_k(lowercase_					,						scores.shape[-1]	)

           __lowerCAmelCase								=					jnp.full_like(lowercase_					,						self.filter_value	)
           __lowerCAmelCase								=					jax.nn.softmax(lowercase_					,						axis=-1	).cumsum(axis=-1	)
           __lowerCAmelCase								=					cumulative_probs < self.top_p

           # include the token that is higher than top_p as well
           __lowerCAmelCase								=					jnp.roll(lowercase_					,						1	)
           score_mask |= score_mask.at[:, 0].set(lowercase_	)

           # min tokens to keep
           __lowerCAmelCase								=					score_mask.at[:, : self.min_tokens_to_keep].set(lowercase_	)

           __lowerCAmelCase								=					jnp.where(lowercase_					,						lowercase_					,						lowercase_	)
           __lowerCAmelCase								=					jax.lax.sort_key_val(lowercase_					,						lowercase_	)[-1]

           return next_scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase = -float("Inf"	)					,						__UpperCamelCase = 1	)->	Any:







           if not isinstance(lowercase_					,						lowercase_	) or top_k <= 0:
                raise ValueError(F"""`top_k` has to be a strictly positive integer, but is {top_k}"""	)

           __lowerCAmelCase								=					max(lowercase_					,						lowercase_	)
           __lowerCAmelCase								=					filter_value


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase			, __lowerCAmelCase								=					scores.shape
           __lowerCAmelCase								=					jnp.full(batch_size * vocab_size					,						self.filter_value	)

           __lowerCAmelCase								=					min(self.top_k					,						scores.shape[-1]	)  # Safety check
           __lowerCAmelCase			, __lowerCAmelCase								=					lax.top_k(lowercase_					,						lowercase_	)
           __lowerCAmelCase								=					jnp.broadcast_to((jnp.arange(lowercase_	) * vocab_size)[:, None]					,						(batch_size, topk)	).flatten()
           __lowerCAmelCase								=					topk_scores.flatten()
           __lowerCAmelCase								=					topk_indices.flatten() + shift

           __lowerCAmelCase								=					next_scores_flat.at[topk_indices_flat].set(lowercase_	)
           __lowerCAmelCase								=					next_scores_flat.reshape(lowercase_					,						lowercase_	)
           return next_scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase	)->	Optional[Any]:
           __lowerCAmelCase								=					bos_token_id


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase								=					jnp.full(scores.shape					,						-float("inf"	)	)

           __lowerCAmelCase								=					1 - jnp.bool_(cur_len - 1	)

           __lowerCAmelCase								=					jnp.where(lowercase_					,						new_scores.at[:, self.bos_token_id].set(0	)					,						lowercase_	)

           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase	)->	Tuple:
           __lowerCAmelCase								=					max_length
           __lowerCAmelCase								=					eos_token_id


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase								=					jnp.full(scores.shape					,						-float("inf"	)	)

           __lowerCAmelCase								=					1 - jnp.bool_(cur_len - self.max_length + 1	)

           __lowerCAmelCase								=					jnp.where(lowercase_					,						new_scores.at[:, self.eos_token_id].set(0	)					,						lowercase_	)

           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase	)->	Dict:







           if not isinstance(lowercase_					,						lowercase_	) or min_length < 0:
                raise ValueError(F"""`min_length` has to be a positive integer, but is {min_length}"""	)

           if not isinstance(lowercase_					,						lowercase_	) or eos_token_id < 0:
                raise ValueError(F"""`eos_token_id` has to be a positive integer, but is {eos_token_id}"""	)

           __lowerCAmelCase								=					min_length
           __lowerCAmelCase								=					eos_token_id


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase								=					1 - jnp.clip(cur_len - self.min_length					,						0					,						1	)

           __lowerCAmelCase								=					jnp.where(lowercase_					,						scores.at[:, self.eos_token_id].set(-float("inf"	)	)					,						lowercase_	)

           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase	)->	Tuple:
           __lowerCAmelCase								=					list(lowercase_	)
           __lowerCAmelCase								=					begin_index


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	Optional[Any]:
           __lowerCAmelCase								=					1 - jnp.bool_(cur_len - self.begin_index	)

           __lowerCAmelCase								=					jnp.where(lowercase_					,						scores.at[:, self.begin_suppress_tokens].set(-float("inf"	)	)					,						lowercase_	)

           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase	)->	Optional[Any]:
           __lowerCAmelCase								=					list(lowercase_	)


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:
           __lowerCAmelCase								=					scores.at[..., self.suppress_tokens].set(-float("inf"	)	)

           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase	)->	Any:
           __lowerCAmelCase								=					dict(lowercase_	)
           # Converts the dictionary of format {index: token} containing the tokens to be forced to an array, where the
           # index of the array corresponds to the index of the token to be forced, for XLA compatibility.
           # Indexes without forced tokens will have a negative value.
           __lowerCAmelCase								=					jnp.ones((max(force_token_map.keys()	) + 1)					,						dtype=jnp.intaa	) * -1
           for index, token in force_token_map.items():
                if token is not None:
                     __lowerCAmelCase								=					force_token_array.at[index].set(lowercase_	)
           __lowerCAmelCase								=					jnp.intaa(lowercase_	)


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	jnp.ndarray:







           def _force_token(__UpperCamelCase	):
                __lowerCAmelCase								=					scores.shape[0]
                __lowerCAmelCase								=					self.force_token_array[generation_idx]

                __lowerCAmelCase								=					jnp.ones_like(lowercase_					,						dtype=scores.dtype	) * -float("inf"	)
                __lowerCAmelCase								=					jnp.zeros((batch_size, 1)					,						dtype=scores.dtype	)
                __lowerCAmelCase								=					lax.dynamic_update_slice(lowercase_					,						lowercase_					,						(0, current_token)	)
                return new_scores

           __lowerCAmelCase								=					lax.cond(
               cur_len >= self.force_token_array.shape[0]					,						lambda: scores					,						lambda: lax.cond(
                   self.force_token_array[cur_len] >= 0					,						lambda: _force_token(lowercase_	)					,						lambda: scores					,						)					,						)
           return scores



class 							_UpperCamelCase			(a_			):


      def __init__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	Optional[Any]:
           __lowerCAmelCase								=					generate_config.eos_token_id
           __lowerCAmelCase								=					generate_config.no_timestamps_token_id
           __lowerCAmelCase								=					generate_config.no_timestamps_token_id + 1

           __lowerCAmelCase								=					decoder_input_length + 1

           if generate_config.is_multilingual:
                # room for language token and task token
                self.begin_index += 2
           if hasattr(lowercase_					,						"max_initial_timestamp_index"	):
                __lowerCAmelCase								=					generate_config.max_initial_timestamp_index
           else:
                __lowerCAmelCase								=					model_config.vocab_size
           if self.max_initial_timestamp_index is None:
                __lowerCAmelCase								=					model_config.vocab_size


      def __call__(	self					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase	)->	List[str]:
           __lowerCAmelCase								=					scores.at[:, self.no_timestamps_token_id].set(-float("inf"	)	)

           def handle_pairs(__UpperCamelCase					,						__UpperCamelCase	):
                __lowerCAmelCase								=					jnp.where((cur_len - self.begin_index) >= 1					,						lowercase_					,						lowercase_	)
                __lowerCAmelCase								=					jnp.where(
                    input_ids_k[cur_len - 1] >= self.timestamp_begin					,						True and last_was_timestamp					,						lowercase_					,						)

                __lowerCAmelCase								=					jnp.where((cur_len - self.begin_index) < 2					,						lowercase_					,						lowercase_	)
                __lowerCAmelCase								=					jnp.where(
                    input_ids_k[cur_len - 2] >= self.timestamp_begin					,						lowercase_					,						lowercase_					,						)

                return jnp.where(
                    lowercase_					,						jnp.where(
                        penultimate_was_timestamp > 0					,						scores_k.at[self.timestamp_begin :].set(-float("inf"	)	)					,						scores_k.at[: self.eos_token_id].set(-float("inf"	)	)					,						)					,						lowercase_					,						)

           __lowerCAmelCase								=					jax.vmap(lowercase_	)(lowercase_					,						lowercase_	)

           __lowerCAmelCase								=					jnp.where(cur_len == self.begin_index					,						lowercase_					,						lowercase_	)
           __lowerCAmelCase								=					jnp.where(
               self.max_initial_timestamp_index is not None					,						True and apply_max_initial_timestamp					,						lowercase_					,						)

           __lowerCAmelCase								=					self.timestamp_begin + self.max_initial_timestamp_index

           __lowerCAmelCase								=					jnp.where(
               lowercase_					,						scores.at[:, last_allowed + 1 :].set(-float("inf"	)	)					,						lowercase_					,						)

           # if sum of probability over timestamps is above any other token, sample timestamp
           __lowerCAmelCase								=					jax.nn.log_softmax(lowercase_					,						axis=-1	)

           def handle_cumulative_probs(__UpperCamelCase					,						__UpperCamelCase	):
                __lowerCAmelCase								=					jax.nn.logsumexp(logprobs_k[self.timestamp_begin :]					,						axis=-1	)
                __lowerCAmelCase								=					jnp.max(logprobs_k[: self.timestamp_begin]	)
                return jnp.where(
                    timestamp_logprob > max_text_token_logprob					,						scores_k.at[: self.timestamp_begin].set(-float("inf"	)	)					,						lowercase_					,						)

           __lowerCAmelCase								=					jax.vmap(lowercase_	)(lowercase_					,						lowercase_	)

           return scores














from typing import Dict, List

from nltk.translate import gleu_score

import datasets
from datasets import MetricInfo


lowerCamelCase			:					Tuple         =	'''\
@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}
}
'''

lowerCamelCase			:					int         =	'''\
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.
'''

lowerCamelCase			:					List[str]         =	'''\
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 							_UpperCamelCase			(datasets.Metric			):


      def  __UpperCAmelCase		(	self	)->	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					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase = 1					,						__UpperCamelCase = 4					,						)->	Dict[str, float]:
           return {
               "google_bleu": gleu_score.corpus_gleu(
                   list_of_references=__UpperCamelCase					,						hypotheses=__UpperCamelCase					,						min_len=__UpperCamelCase					,						max_len=__UpperCamelCase	)
           }






