






import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
		import jax
		import jax.numpy as jnp

		from transformers.modeling_flax_pytorch_utils import (
		    convert_pytorch_state_dict_to_flax,
		    load_flax_weights_in_pytorch_model,
		)
		from transformers.models.gptj.modeling_flax_gptj import FlaxGPTJForCausalLM, FlaxGPTJModel

if is_torch_available():
		import torch





class   snake_case__ :
	def __init__(    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__=14      ,       lowerCAmelCase__=7      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=False      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=99      ,       lowerCAmelCase__=32      ,       lowerCAmelCase__=4      ,       lowerCAmelCase__=4      ,       lowerCAmelCase__=4      ,       lowerCAmelCase__=37      ,       lowerCAmelCase__="gelu"      ,       lowerCAmelCase__=0.1      ,       lowerCAmelCase__=0.1      ,       lowerCAmelCase__=5_12      ,       lowerCAmelCase__=0.0_2      ,       )							->				Union[str, Any]:
							__magic_name__      :       List[Any]       						= parent
							__magic_name__      :       Union[str, Any]       						= batch_size
							__magic_name__      :       Dict       						= seq_length
							__magic_name__      :       Optional[Any]       						= is_training
							__magic_name__      :       Optional[int]       						= use_input_mask
							__magic_name__      :       Optional[Any]       						= use_token_type_ids
							__magic_name__      :       Optional[Any]       						= use_labels
							__magic_name__      :       Any       						= vocab_size
							__magic_name__      :       Tuple       						= hidden_size
							__magic_name__      :       Any       						= rotary_dim
							__magic_name__      :       str       						= num_hidden_layers
							__magic_name__      :       int       						= num_attention_heads
							__magic_name__      :       Any       						= intermediate_size
							__magic_name__      :       Dict       						= hidden_act
							__magic_name__      :       Optional[Any]       						= hidden_dropout_prob
							__magic_name__      :       Optional[int]       						= attention_probs_dropout_prob
							__magic_name__      :       Optional[Any]       						= max_position_embeddings
							__magic_name__      :       Union[str, Any]       						= initializer_range
							__magic_name__      :       int       						= None
							__magic_name__      :       Union[str, Any]       						= vocab_size - 1
							__magic_name__      :       str       						= vocab_size - 1
							__magic_name__      :       Optional[int]       						= vocab_size - 1
	def       __magic_name__    (    self			)							->				Optional[int]:
							__magic_name__      :       str       						= ids_tensor([self.batch_size, self.seq_length]      ,       self.vocab_size			)

							__magic_name__      :       Optional[int]       						= None
							if self.use_input_mask:
													__magic_name__      :       Union[str, Any]       						= random_attention_mask([self.batch_size, self.seq_length]			)

							__magic_name__      :       Optional[int]       						= GPTJConfig(
							    vocab_size=self.vocab_size      ,       n_embd=self.hidden_size      ,       n_layer=self.num_hidden_layers      ,       n_head=self.num_attention_heads      ,       n_positions=self.max_position_embeddings      ,       use_cache=lowerCAmelCase__      ,       bos_token_id=self.bos_token_id      ,       eos_token_id=self.eos_token_id      ,       pad_token_id=self.pad_token_id      ,       rotary_dim=self.rotary_dim      ,       )

							return (config, input_ids, input_mask)
	def       __magic_name__    (    self			)							->				Optional[Any]:
							__magic_name__      :       Optional[int]       						= self.prepare_config_and_inputs()
							__magic_name__      :       List[str]       						= config_and_inputs
							__magic_name__      :       int       						= {"""input_ids""": input_ids, """attention_mask""": attention_mask}
							return config, inputs_dict
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)							->				Optional[int]:
							__magic_name__      :       str       						= 20
							__magic_name__      :       Dict       						= model_class_name(lowerCAmelCase__			)

							__magic_name__      :       Optional[int]       						= model.init_cache(input_ids.shape[0]      ,       lowerCAmelCase__			)
							__magic_name__      :       Dict       						= jnp.ones((input_ids.shape[0], max_decoder_length)      ,       dtype="""i4"""			)

							__magic_name__      :       Tuple       						= jnp.broadcast_to(
							    jnp.arange(input_ids.shape[-1] - 1			)[None, :]      ,       (input_ids.shape[0], input_ids.shape[-1] - 1)			)
							__magic_name__      :       Dict       						= model(
							    input_ids[:, :-1]      ,       attention_mask=lowerCAmelCase__      ,       past_key_values=lowerCAmelCase__      ,       position_ids=lowerCAmelCase__      ,       )

							__magic_name__      :       Union[str, Any]       						= jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]      ,       dtype="""i4"""			)
							__magic_name__      :       List[str]       						= model(
							    input_ids[:, -1:]      ,       attention_mask=lowerCAmelCase__      ,       past_key_values=outputs_cache.past_key_values      ,       position_ids=lowerCAmelCase__      ,       )

							__magic_name__      :       Any       						= model(lowerCAmelCase__			)

							__magic_name__      :       Tuple       						= np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])			)			)
							self.parent.assertTrue(diff < 1e-3      ,       msg=F'Max diff is {diff}'			)







	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)							->				Tuple:
							__magic_name__      :       int       						= 20
							__magic_name__      :       List[Any]       						= model_class_name(lowerCAmelCase__			)

							__magic_name__      :       Tuple       						= jnp.concatenate(
							    [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])			)]      ,       axis=-1      ,       )

							__magic_name__      :       Optional[int]       						= model.init_cache(input_ids.shape[0]      ,       lowerCAmelCase__			)
							__magic_name__      :       Dict       						= jnp.broadcast_to(
							    jnp.arange(input_ids.shape[-1] - 1			)[None, :]      ,       (input_ids.shape[0], input_ids.shape[-1] - 1)			)

							__magic_name__      :       Tuple       						= model(
							    input_ids[:, :-1]      ,       attention_mask=lowerCAmelCase__      ,       past_key_values=lowerCAmelCase__      ,       position_ids=lowerCAmelCase__      ,       )
							__magic_name__      :       List[str]       						= jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]      ,       dtype="""i4"""			)
							__magic_name__      :       Tuple       						= model(
							    input_ids[:, -1:]      ,       past_key_values=outputs_cache.past_key_values      ,       attention_mask=lowerCAmelCase__      ,       position_ids=lowerCAmelCase__      ,       )

							__magic_name__      :       Union[str, Any]       						= model(lowerCAmelCase__      ,       attention_mask=lowerCAmelCase__			)

							__magic_name__      :       str       						= np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])			)			)
							self.parent.assertTrue(diff < 1e-3      ,       msg=F'Max diff is {diff}'			)





@require_flax
class   snake_case__ (							__UpperCamelCase						,  __UpperCamelCase						,  unittest.TestCase				):
	lowercase__						:					Union[str, Any]											=   (FlaxGPTJModel, FlaxGPTJForCausalLM) if is_flax_available() else ()
	lowercase__						:					Any											=   (FlaxGPTJForCausalLM,) if is_flax_available() else ()
	def       __magic_name__    (    self			)							->				List[Any]:
							__magic_name__      :       List[str]       						= FlaxGPTJModelTester(self			)
	def       __magic_name__    (    self			)							->				Dict:
							for model_class_name in self.all_model_classes:
													__magic_name__      :       str       						= self.model_tester.prepare_config_and_inputs()
													self.model_tester.check_use_cache_forward(lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)
	def       __magic_name__    (    self			)							->				Tuple:
							for model_class_name in self.all_model_classes:
													__magic_name__      :       Optional[int]       						= self.model_tester.prepare_config_and_inputs()
													self.model_tester.check_use_cache_forward_with_attn_mask(
													    lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)
	@tooslow
	def       __magic_name__    (    self			)							->				List[str]:
							__magic_name__      :       Optional[int]       						= GPTaTokenizer.from_pretrained("""gpt2"""      ,       pad_token="""<|endoftext|>"""      ,       padding_side="""left"""			)
							__magic_name__      :       Tuple       						= tokenizer(["""Hello this is a long string""", """Hey"""]      ,       return_tensors="""np"""      ,       padding=lowerCAmelCase__      ,       truncation=lowerCAmelCase__			)

							__magic_name__      :       Optional[Any]       						= FlaxGPTJForCausalLM.from_pretrained("""EleutherAI/gpt-j-6B"""			)
							__magic_name__      :       List[str]       						= False
							__magic_name__      :       Optional[Any]       						= model.config.eos_token_id

							__magic_name__      :       List[Any]       						= jax.jit(model.generate			)

							__magic_name__      :       Any       						= jit_generate(
							    inputs["""input_ids"""]      ,       attention_mask=inputs["""attention_mask"""]      ,       pad_token_id=tokenizer.pad_token_id			).sequences

							__magic_name__      :       str       						= tokenizer.batch_decode(lowerCAmelCase__      ,       skip_special_tokens=lowerCAmelCase__			)

							__magic_name__      :       Optional[int]       						= [
							    """Hello this is a long string of text.\n\nI'm trying to get the text of the""",
							    """Hey, I'm a little late to the party. I'm going to""",
							]

							self.assertListEqual(lowerCAmelCase__      ,       lowerCAmelCase__			)
	@is_pt_flax_cross_test
	def       __magic_name__    (    self			)							->				str:
							__magic_name__      :       int       						= self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
													with self.subTest(model_class.__name__			):
																			# prepare inputs
																			__magic_name__      :       int       						= self._prepare_for_class(lowerCAmelCase__      ,       lowerCAmelCase__			)
																			__magic_name__      :       List[Any]       						= {k: torch.tensor(v.tolist()			) for k, v in prepared_inputs_dict.items()}

																			# load corresponding PyTorch class
																			__magic_name__      :       List[str]       						= model_class.__name__[4:]  # Skip the "Flax" at the beginning
																			__magic_name__      :       Dict       						= getattr(lowerCAmelCase__      ,       lowerCAmelCase__			)

																			__magic_name__      :       Optional[Any]       						= pt_inputs["""input_ids"""].shape
																			__magic_name__      :       str       						= np.random.randint(0      ,       seq_length - 1      ,       size=(batch_size,)			)
																			for batch_idx, start_index in enumerate(lowerCAmelCase__			):
																									__magic_name__      :       Optional[Any]       						= 0
																									__magic_name__      :       Any       						= 1
																									__magic_name__      :       Tuple       						= 0
																									__magic_name__      :       List[Any]       						= 1
																			__magic_name__      :       Tuple       						= pt_model_class(lowerCAmelCase__			).eval()
																			__magic_name__      :       List[str]       						= model_class(lowerCAmelCase__      ,       dtype=jnp.floataa			)

																			__magic_name__      :       List[str]       						= convert_pytorch_state_dict_to_flax(pt_model.state_dict()      ,       lowerCAmelCase__			)
																			__magic_name__      :       List[str]       						= fx_state

																			with torch.no_grad():
																									__magic_name__      :       List[str]       						= pt_model(**lowerCAmelCase__			).to_tuple()

																			__magic_name__      :       int       						= fx_model(**lowerCAmelCase__			).to_tuple()
																			self.assertEqual(len(lowerCAmelCase__			)      ,       len(lowerCAmelCase__			)      ,       """Output lengths differ between Flax and PyTorch"""			)
																			for fx_output, pt_output in zip(lowerCAmelCase__      ,       lowerCAmelCase__			):
																									self.assert_almost_equals(fx_output[:, -1]      ,       pt_output[:, -1].numpy()      ,       4e-2			)

																			with tempfile.TemporaryDirectory() as tmpdirname:
																									pt_model.save_pretrained(lowerCAmelCase__			)
																									__magic_name__      :       Optional[int]       						= model_class.from_pretrained(lowerCAmelCase__      ,       from_pt=lowerCAmelCase__			)

																			__magic_name__      :       Union[str, Any]       						= fx_model_loaded(**lowerCAmelCase__			).to_tuple()
																			self.assertEqual(
																			    len(lowerCAmelCase__			)      ,       len(lowerCAmelCase__			)      ,       """Output lengths differ between Flax and PyTorch"""			)
																			for fx_output_loaded, pt_output in zip(lowerCAmelCase__      ,       lowerCAmelCase__			):
																									self.assert_almost_equals(fx_output_loaded[:, -1]      ,       pt_output[:, -1].numpy()      ,       4e-2			)
	@is_pt_flax_cross_test
	def       __magic_name__    (    self			)							->				Union[str, Any]:
							__magic_name__      :       Optional[int]       						= self.model_tester.prepare_config_and_inputs_for_common()
							for model_class in self.all_model_classes:
													with self.subTest(model_class.__name__			):
																			# prepare inputs
																			__magic_name__      :       str       						= self._prepare_for_class(lowerCAmelCase__      ,       lowerCAmelCase__			)
																			__magic_name__      :       int       						= {k: torch.tensor(v.tolist()			) for k, v in prepared_inputs_dict.items()}

																			# load corresponding PyTorch class
																			__magic_name__      :       Optional[int]       						= model_class.__name__[4:]  # Skip the "Flax" at the beginning
																			__magic_name__      :       Any       						= getattr(lowerCAmelCase__      ,       lowerCAmelCase__			)

																			__magic_name__      :       str       						= pt_model_class(lowerCAmelCase__			).eval()
																			__magic_name__      :       Any       						= model_class(lowerCAmelCase__      ,       dtype=jnp.floataa			)

																			__magic_name__      :       Union[str, Any]       						= load_flax_weights_in_pytorch_model(lowerCAmelCase__      ,       fx_model.params			)
																			__magic_name__      :       List[Any]       						= pt_inputs["""input_ids"""].shape
																			__magic_name__      :       str       						= np.random.randint(0      ,       seq_length - 1      ,       size=(batch_size,)			)
																			for batch_idx, start_index in enumerate(lowerCAmelCase__			):
																									__magic_name__      :       Any       						= 0
																									__magic_name__      :       Optional[int]       						= 1
																									__magic_name__      :       Tuple       						= 0
																									__magic_name__      :       str       						= 1

																			# make sure weights are tied in PyTorch
																			pt_model.tie_weights()

																			with torch.no_grad():
																									__magic_name__      :       List[str]       						= pt_model(**lowerCAmelCase__			).to_tuple()

																			__magic_name__      :       Tuple       						= fx_model(**lowerCAmelCase__			).to_tuple()
																			self.assertEqual(len(lowerCAmelCase__			)      ,       len(lowerCAmelCase__			)      ,       """Output lengths differ between Flax and PyTorch"""			)
																			for fx_output, pt_output in zip(lowerCAmelCase__      ,       lowerCAmelCase__			):
																									self.assert_almost_equals(fx_output[:, -1]      ,       pt_output[:, -1].numpy()      ,       4e-2			)

																			with tempfile.TemporaryDirectory() as tmpdirname:
																									fx_model.save_pretrained(lowerCAmelCase__			)
																									__magic_name__      :       Optional[Any]       						= pt_model_class.from_pretrained(lowerCAmelCase__      ,       from_flax=lowerCAmelCase__			)

																			with torch.no_grad():
																									__magic_name__      :       Dict       						= pt_model_loaded(**lowerCAmelCase__			).to_tuple()

																			self.assertEqual(
																			    len(lowerCAmelCase__			)      ,       len(lowerCAmelCase__			)      ,       """Output lengths differ between Flax and PyTorch"""			)
																			for fx_output, pt_output in zip(lowerCAmelCase__      ,       lowerCAmelCase__			):
																									self.assert_almost_equals(fx_output[:, -1]      ,       pt_output[:, -1].numpy()      ,       4e-2			)







	@tooslow
	def       __magic_name__    (    self			)							->				Any:
							for model_class_name in self.all_model_classes:
													__magic_name__      :       Optional[Any]       						= model_class_name.from_pretrained("""EleutherAI/gpt-j-6B"""			)
													__magic_name__      :       Optional[Any]       						= model(np.ones((1, 1)			)			)
													self.assertIsNotNone(lowerCAmelCase__			)








from typing import Dict, List

from nltk.translate import gleu_score

import datasets
from datasets import MetricInfo


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

__magic_name__:					List[Any]							=     "\\nThe BLEU score has some undesirable properties when used for single\nsentences, as it was designed to be a corpus measure. We therefore\nuse a slightly different score for our RL experiments which we call\nthe 'GLEU score'. For the GLEU score, we record all sub-sequences of\n1, 2, 3 or 4 tokens in output and target sequence (n-grams). We then\ncompute a recall, which is the ratio of the number of matching n-grams\nto the number of total n-grams in the target (ground truth) sequence,\nand a precision, which is the ratio of the number of matching n-grams\nto the number of total n-grams in the generated output sequence. Then\nGLEU score is simply the minimum of recall and precision. This GLEU\nscore's range is always between 0 (no matches) and 1 (all match) and\nit is symmetrical when switching output and target. According to\nour experiments, GLEU score correlates quite well with the BLEU\nmetric on a corpus level but does not have its drawbacks for our per\nsentence reward objective.\n"

__magic_name__:					Union[str, Any]							=     "\\nComputes corpus-level Google BLEU (GLEU) score of translated segments against one or more references.\nInstead of averaging the sentence level GLEU scores (i.e. macro-average precision), Wu et al. (2016) sum up the matching\ntokens and the max of hypothesis and reference tokens for each sentence, then compute using the aggregate values.\n\nArgs:\n    predictions (list of str): list of translations to score.\n        Each translation should be tokenized into a list of tokens.\n    references (list of list of str): list of lists of references for each translation.\n        Each reference should be tokenized into a list of tokens.\n    min_len (int): The minimum order of n-gram this function should extract. Defaults to 1.\n    max_len (int): The maximum order of n-gram this function should extract. Defaults to 4.\n\nReturns:\n    'google_bleu': google_bleu score\n\nExamples:\n    Example 1:\n        >>> hyp1 = ['It', 'is', 'a', 'guide', 'to', 'action', 'which',\n        ...         'ensures', 'that', 'the', 'rubber', 'duck', 'always',\n        ...         'disobeys', 'the', 'commands', 'of', 'the', 'cat']\n        >>> ref1a = ['It', 'is', 'the', 'guiding', 'principle', 'which',\n        ...          'guarantees', 'the', 'rubber', 'duck', 'forces', 'never',\n        ...          'being', 'under', 'the', 'command', 'of', 'the', 'cat']\n\n        >>> hyp2 = ['he', 'read', 'the', 'book', 'because', 'he', 'was',\n        ...         'interested', 'in', 'world', 'history']\n        >>> ref2a = ['he', 'was', 'interested', 'in', 'world', 'history',\n        ...          'because', 'he', 'read', 'the', 'book']\n\n        >>> list_of_references = [[ref1a], [ref2a]]\n        >>> hypotheses = [hyp1, hyp2]\n        >>> google_bleu = datasets.load_metric(\"google_bleu\")\n        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references)\n        >>> print(round(results[\"google_bleu\"], 2))\n        0.44\n\n    Example 2:\n        >>> hyp1 = ['It', 'is', 'a', 'guide', 'to', 'action', 'which',\n        ...         'ensures', 'that', 'the', 'rubber', 'duck', 'always',\n        ...         'disobeys', 'the', 'commands', 'of', 'the', 'cat']\n        >>> ref1a = ['It', 'is', 'the', 'guiding', 'principle', 'which',\n        ...          'guarantees', 'the', 'rubber', 'duck', 'forces', 'never',\n        ...          'being', 'under', 'the', 'command', 'of', 'the', 'cat']\n        >>> ref1b = ['It', 'is', 'a', 'guide', 'to', 'action', 'that',\n        ...          'ensures', 'that', 'the', 'rubber', 'duck', 'will', 'never',\n        ...          'heed', 'the', 'cat', 'commands']\n        >>> ref1c = ['It', 'is', 'the', 'practical', 'guide', 'for', 'the',\n        ...          'rubber', 'duck', 'army', 'never', 'to', 'heed', 'the', 'directions',\n        ...          'of', 'the', 'cat']\n\n        >>> hyp2 = ['he', 'read', 'the', 'book', 'because', 'he', 'was',\n        ...         'interested', 'in', 'world', 'history']\n        >>> ref2a = ['he', 'was', 'interested', 'in', 'world', 'history',\n        ...          'because', 'he', 'read', 'the', 'book']\n\n        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]\n        >>> hypotheses = [hyp1, hyp2]\n        >>> google_bleu = datasets.load_metric(\"google_bleu\")\n        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references)\n        >>> print(round(results[\"google_bleu\"], 2))\n        0.61\n\n    Example 3:\n        >>> hyp1 = ['It', 'is', 'a', 'guide', 'to', 'action', 'which',\n        ...         'ensures', 'that', 'the', 'rubber', 'duck', 'always',\n        ...         'disobeys', 'the', 'commands', 'of', 'the', 'cat']\n        >>> ref1a = ['It', 'is', 'the', 'guiding', 'principle', 'which',\n        ...          'guarantees', 'the', 'rubber', 'duck', 'forces', 'never',\n        ...          'being', 'under', 'the', 'command', 'of', 'the', 'cat']\n        >>> ref1b = ['It', 'is', 'a', 'guide', 'to', 'action', 'that',\n        ...          'ensures', 'that', 'the', 'rubber', 'duck', 'will', 'never',\n        ...          'heed', 'the', 'cat', 'commands']\n        >>> ref1c = ['It', 'is', 'the', 'practical', 'guide', 'for', 'the',\n        ...          'rubber', 'duck', 'army', 'never', 'to', 'heed', 'the', 'directions',\n        ...          'of', 'the', 'cat']\n\n        >>> hyp2 = ['he', 'read', 'the', 'book', 'because', 'he', 'was',\n        ...         'interested', 'in', 'world', 'history']\n        >>> ref2a = ['he', 'was', 'interested', 'in', 'world', 'history',\n        ...          'because', 'he', 'read', 'the', 'book']\n\n        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]\n        >>> hypotheses = [hyp1, hyp2]\n        >>> google_bleu = datasets.load_metric(\"google_bleu\")\n        >>> results = google_bleu.compute(predictions=hypotheses, references=list_of_references, min_len=2)\n        >>> print(round(results[\"google_bleu\"], 2))\n        0.53\n\n    Example 4:\n        >>> hyp1 = ['It', 'is', 'a', 'guide', 'to', 'action', 'which',\n        ...         'ensures', 'that', 'the', 'rubber', 'duck', 'always',\n        ...         'disobeys', 'the', 'commands', 'of', 'the', 'cat']\n        >>> ref1a = ['It', 'is', 'the', 'guiding', 'principle', 'which',\n        ...          'guarantees', 'the', 'rubber', 'duck', 'forces', 'never',\n        ...          'being', 'under', 'the', 'command', 'of', 'the', 'cat']\n        >>> ref1b = ['It', 'is', 'a', 'guide', 'to', 'action', 'that',\n        ...          'ensures', 'that', 'the', 'rubber', 'duck', 'will', 'never',\n        ...          'heed', 'the', 'cat', 'commands']\n        >>> ref1c = ['It', 'is', 'the', 'practical', 'guide', 'for', 'the',\n        ...          'rubber', 'duck', 'army', 'never', 'to', 'heed', 'the', 'directions',\n        ...          'of', 'the', 'cat']\n\n        >>> hyp2 = ['he', 'read', 'the', 'book', 'because', 'he', 'was',\n        ...         'interested', 'in', 'world', 'history']\n        >>> ref2a = ['he', 'was', 'interested', 'in', 'world', 'history',\n        ...          'because', 'he', 'read', 'the', 'book']\n\n        >>> list_of_references = [[ref1a, ref1b, ref1c], [ref2a]]\n        >>> hypotheses = [hyp1, hyp2]\n        >>> google_bleu = datasets.load_metric(\"google_bleu\")\n        >>> results = google_bleu.compute(predictions=hypotheses,references=list_of_references, min_len=2, max_len=6)\n        >>> print(round(results[\"google_bleu\"], 2))\n        0.4\n"





@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION						,  _KWARGS_DESCRIPTION				)
class 	snake_case__ (							datasets.Metric				):
	def       __magic_name__    (    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       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__ = 1      ,       lowerCAmelCase__ = 4      ,       )							->				Dict[str, float]:
							return {
							    "google_bleu": gleu_score.corpus_gleu(
							        list_of_references=lowerCAmelCase__      ,       hypotheses=lowerCAmelCase__      ,       min_len=lowerCAmelCase__      ,       max_len=lowerCAmelCase__			)
							}
