



from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
	import tensorflow as tf

	from transformers import (
	    TFFunnelBaseModel,
	    TFFunnelForMaskedLM,
	    TFFunnelForMultipleChoice,
	    TFFunnelForPreTraining,
	    TFFunnelForQuestionAnswering,
	    TFFunnelForSequenceClassification,
	    TFFunnelForTokenClassification,
	    TFFunnelModel,
	)






class 		lowercase						:






	"""simple docstring"""


	def __init__(     self     :						List[str]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Optional[Any]=13						,  __UpperCAmelCase     :						int=7						,  __UpperCAmelCase     :						int=True						,  __UpperCAmelCase     :						int=True						,  __UpperCAmelCase     :						Union[str, Any]=True						,  __UpperCAmelCase     :						Union[str, Any]=True						,  __UpperCAmelCase     :						Optional[Any]=99						,  __UpperCAmelCase     :						List[str]=[1, 1, 2]						,  __UpperCAmelCase     :						Optional[Any]=1						,  __UpperCAmelCase     :						Union[str, Any]=32						,  __UpperCAmelCase     :						Dict=4						,  __UpperCAmelCase     :						List[Any]=8						,  __UpperCAmelCase     :						Optional[Any]=37						,  __UpperCAmelCase     :						Tuple="gelu_new"						,  __UpperCAmelCase     :						Any=0.1						,  __UpperCAmelCase     :						List[str]=0.1						,  __UpperCAmelCase     :						Dict=0.0						,  __UpperCAmelCase     :						Tuple=512						,  __UpperCAmelCase     :						List[Any]=3						,  __UpperCAmelCase     :						Tuple=0.02						,  __UpperCAmelCase     :						str=3						,  __UpperCAmelCase     :						Tuple=4						,  __UpperCAmelCase     :						Dict=None						,  __UpperCAmelCase     :						int=False						,  )      ->			int:
							UpperCAmelCase_=       parent
							UpperCAmelCase_=       batch_size
							UpperCAmelCase_=       seq_length
							UpperCAmelCase_=       is_training
							UpperCAmelCase_=       use_input_mask
							UpperCAmelCase_=       use_token_type_ids
							UpperCAmelCase_=       use_labels
							UpperCAmelCase_=       vocab_size
							UpperCAmelCase_=       block_sizes
							UpperCAmelCase_=       num_decoder_layers
							UpperCAmelCase_=       d_model
							UpperCAmelCase_=       n_head
							UpperCAmelCase_=       d_head
							UpperCAmelCase_=       d_inner
							UpperCAmelCase_=       hidden_act
							UpperCAmelCase_=       hidden_dropout
							UpperCAmelCase_=       attention_dropout
							UpperCAmelCase_=       activation_dropout
							UpperCAmelCase_=       max_position_embeddings
							UpperCAmelCase_=       type_vocab_size
							UpperCAmelCase_=       2
							UpperCAmelCase_=       num_labels
							UpperCAmelCase_=       num_choices
							UpperCAmelCase_=       scope
							UpperCAmelCase_=       initializer_std

							# Used in the tests to check the size of the first attention layer
							UpperCAmelCase_=       n_head
							# Used in the tests to check the size of the first hidden state
							UpperCAmelCase_=       self.d_model
							# Used in the tests to check the number of output hidden states/attentions
							UpperCAmelCase_=       sum(self.block_sizes					) + (0 if base else self.num_decoder_layers)
							# FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
							# the last hidden state of the first block (which is the first hidden state of the decoder).
							if not base:
													UpperCAmelCase_=       self.num_hidden_layers + 2




	def   _SCREAMING_SNAKE_CASE		(     self     :						int					)      ->			Any:
							UpperCAmelCase_=       ids_tensor([self.batch_size, self.seq_length]						,  self.vocab_size					)

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

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

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

							UpperCAmelCase_=       FunnelConfig(
							    vocab_size=self.vocab_size						,  block_sizes=self.block_sizes						,  num_decoder_layers=self.num_decoder_layers						,  d_model=self.d_model						,  n_head=self.n_head						,  d_head=self.d_head						,  d_inner=self.d_inner						,  hidden_act=self.hidden_act						,  hidden_dropout=self.hidden_dropout						,  attention_dropout=self.attention_dropout						,  activation_dropout=self.activation_dropout						,  max_position_embeddings=self.max_position_embeddings						,  type_vocab_size=self.type_vocab_size						,  initializer_std=self.initializer_std						,  )

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




	def   _SCREAMING_SNAKE_CASE		(     self     :						str						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						int						,  )      ->			List[str]:
							UpperCAmelCase_=       TFFunnelModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)

							UpperCAmelCase_=       [input_ids, input_mask]
							UpperCAmelCase_=       model(__UpperCAmelCase					)

							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.d_model)					)

							UpperCAmelCase_=       False
							UpperCAmelCase_=       TFFunnelModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.d_model)					)

							UpperCAmelCase_=       False
							UpperCAmelCase_=       TFFunnelModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, self.seq_length, self.d_model)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						int						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Any						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						int						,  )      ->			int:
							UpperCAmelCase_=       TFFunnelBaseModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)

							UpperCAmelCase_=       [input_ids, input_mask]
							UpperCAmelCase_=       model(__UpperCAmelCase					)

							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, 2, self.d_model)					)

							UpperCAmelCase_=       False
							UpperCAmelCase_=       TFFunnelBaseModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, 3, self.d_model)					)

							UpperCAmelCase_=       False
							UpperCAmelCase_=       TFFunnelBaseModel(config=__UpperCAmelCase					)
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.last_hidden_state.shape						,  (self.batch_size, 2, self.d_model)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						int						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						Any						,  __UpperCAmelCase     :						Optional[int]						,  )      ->			str:
							UpperCAmelCase_=       TFFunnelForPreTraining(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Dict						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Dict						,  )      ->			Union[str, Any]:
							UpperCAmelCase_=       TFFunnelForMaskedLM(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length, self.vocab_size)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						int						,  )      ->			int:
							UpperCAmelCase_=       self.num_labels
							UpperCAmelCase_=       TFFunnelForSequenceClassification(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.num_labels)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Tuple						,  )      ->			int:
							UpperCAmelCase_=       self.num_choices
							UpperCAmelCase_=       TFFunnelForMultipleChoice(config=__UpperCAmelCase					)
							UpperCAmelCase_=       tf.tile(tf.expand_dims(__UpperCAmelCase						,  1					)						,  (1, self.num_choices, 1)					)
							UpperCAmelCase_=       tf.tile(tf.expand_dims(__UpperCAmelCase						,  1					)						,  (1, self.num_choices, 1)					)
							UpperCAmelCase_=       tf.tile(tf.expand_dims(__UpperCAmelCase						,  1					)						,  (1, self.num_choices, 1)					)
							UpperCAmelCase_=       {
							    """input_ids""": multiple_choice_inputs_ids,
							    """attention_mask""": multiple_choice_input_mask,
							    """token_type_ids""": multiple_choice_token_type_ids,
							}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.num_choices)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Any						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Dict						,  )      ->			str:
							UpperCAmelCase_=       self.num_labels
							UpperCAmelCase_=       TFFunnelForTokenClassification(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							self.parent.assertEqual(result.logits.shape						,  (self.batch_size, self.seq_length, self.num_labels)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						str						,  )      ->			Tuple:
							UpperCAmelCase_=       TFFunnelForQuestionAnswering(config=__UpperCAmelCase					)
							UpperCAmelCase_=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
							UpperCAmelCase_=       model(__UpperCAmelCase					)
							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)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			Optional[int]:
							UpperCAmelCase_=       self.prepare_config_and_inputs()
							(
							    (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       (
							    UpperCAmelCase_
							),       
							)=       config_and_inputs
							UpperCAmelCase_=       {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
							return config, inputs_dict






@require_tf
class 		lowercase						(			snake_case__			,   snake_case__			,   unittest.TestCase):






	"""simple docstring"""


	a__				: int		       =							(
	    (
	        TFFunnelModel,
	        TFFunnelForMaskedLM,
	        TFFunnelForPreTraining,
	        TFFunnelForQuestionAnswering,
	        TFFunnelForTokenClassification,
	    )
	    if is_tf_available()
	    else ()
	)
	a__				: str		       =							(
	    {
	        "feature-extraction": (TFFunnelBaseModel, TFFunnelModel),
	        "fill-mask": TFFunnelForMaskedLM,
	        "question-answering": TFFunnelForQuestionAnswering,
	        "text-classification": TFFunnelForSequenceClassification,
	        "token-classification": TFFunnelForTokenClassification,
	        "zero-shot": TFFunnelForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	a__				: List[str]		       =							False
	a__				: List[Any]		       =							False




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]					)      ->			str:
							UpperCAmelCase_=       TFFunnelModelTester(self					)
							UpperCAmelCase_=       ConfigTester(self						,  config_class=__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						int					)      ->			str:
							self.config_tester.run_common_tests()




	def   _SCREAMING_SNAKE_CASE		(     self     :						List[str]					)      ->			List[Any]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						int					)      ->			Union[str, Any]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_pretraining(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any					)      ->			int:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_masked_lm(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Dict					)      ->			int:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						List[str]					)      ->			Dict:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*__UpperCAmelCase					)






@require_tf
class 		lowercase						(			snake_case__			,   unittest.TestCase):






	"""simple docstring"""


	a__				: Any		       =							(
	    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
	)
	a__				: Any		       =							False
	a__				: Union[str, Any]		       =							False




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			Optional[int]:
							UpperCAmelCase_=       TFFunnelModelTester(self						,  base=__UpperCAmelCase					)
							UpperCAmelCase_=       ConfigTester(self						,  config_class=__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						str					)      ->			Any:
							self.config_tester.run_common_tests()




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Optional[Any]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_base_model(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]					)      ->			Any:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			List[str]:
							UpperCAmelCase_=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_multiple_choice(*__UpperCAmelCase					)









from typing import Dict, List

from nltk.translate import gleu_score

import datasets
from datasets import MetricInfo


__A       =						'''\
@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}
}
'''

__A       =						'''\
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.
'''

__A       =						'''\
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   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, 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   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __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					)
							}




