




"""simple docstring"""






import gc
import random
import tempfile
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMInverseScheduler,
    DDIMScheduler,
    DPMSolverMultistepInverseScheduler,
    DPMSolverMultistepScheduler,
    StableDiffusionDiffEditPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import load_image, slow
from diffusers.utils.testing_utils import enable_full_determinism, floats_tensor, require_torch_gpu, torch_device

from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()






class lowerCAmelCase__			(  lowercase,			lowercase,			unittest.TestCase		):






			'''simple docstring'''



			lowerCamelCase__   =    StableDiffusionDiffEditPipeline
			lowerCamelCase__   =    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {"""height""", """width""", """image"""} | {"""image_latents"""}
			lowerCamelCase__   =    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS - {"""image"""} | {"""image_latents"""}
			lowerCamelCase__   =    frozenset(
			    []		)  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
			lowerCamelCase__   =    frozenset([]		)
			def       A_					(						self						):
							torch.manual_seed(0						)
							_lowerCamelCase  :    Optional[int]					=					UNetaDConditionModel(
							    block_out_channels=(32, 64)						,   layers_per_block=2						,   sample_size=32						,   in_channels=4						,   out_channels=4						,   down_block_types=('DownBlock2D', 'CrossAttnDownBlock2D')						,   up_block_types=('CrossAttnUpBlock2D', 'UpBlock2D')						,   cross_attention_dim=32						,   attention_head_dim=(2, 4)						,   use_linear_projection=lowercase						,   )
							_lowerCamelCase  :    Optional[int]					=					DDIMScheduler(
							    beta_start=0.0_00_85						,   beta_end=0.0_12						,   beta_schedule='scaled_linear'						,   clip_sample=lowercase						,   set_alpha_to_one=lowercase						,   )
							_lowerCamelCase  :    Dict					=					DDIMInverseScheduler(
							    beta_start=0.0_00_85						,   beta_end=0.0_12						,   beta_schedule='scaled_linear'						,   clip_sample=lowercase						,   set_alpha_to_zero=lowercase						,   )
							torch.manual_seed(0						)
							_lowerCamelCase  :    List[Any]					=					AutoencoderKL(
							    block_out_channels=[32, 64]						,   in_channels=3						,   out_channels=3						,   down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D']						,   up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D']						,   latent_channels=4						,   sample_size=128						,   )
							torch.manual_seed(0						)
							_lowerCamelCase  :    Optional[Any]					=					CLIPTextConfig(
							    bos_token_id=0						,   eos_token_id=2						,   hidden_size=32						,   intermediate_size=37						,   layer_norm_eps=1E-05						,   num_attention_heads=4						,   num_hidden_layers=5						,   pad_token_id=1						,   vocab_size=1000						,   hidden_act='gelu'						,   projection_dim=512						,   )
							_lowerCamelCase  :    Any					=					CLIPTextModel(lowercase						)
							_lowerCamelCase  :    List[Any]					=					CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'						)

							_lowerCamelCase  :    Dict					=					{
							    'unet': unet,
							    'scheduler': scheduler,
							    'inverse_scheduler': inverse_scheduler,
							    'vae': vae,
							    'text_encoder': text_encoder,
							    'tokenizer': tokenizer,
							    'safety_checker': None,
							    'feature_extractor': None,
							}

							return components
			def       A_					(						self						,   lowercase						,   lowercase=0						):
							_lowerCamelCase  :    Optional[Any]					=					floats_tensor((1, 16, 16)						,   rng=random.Random(lowercase						)						).to(lowercase						)
							_lowerCamelCase  :    List[str]					=					floats_tensor((1, 2, 4, 16, 16)						,   rng=random.Random(lowercase						)						).to(lowercase						)
							if str(lowercase						).startswith('mps'						):
											_lowerCamelCase  :    List[str]					=					torch.manual_seed(lowercase						)
							else:
											_lowerCamelCase  :    Optional[int]					=					torch.Generator(device=lowercase						).manual_seed(lowercase						)
							_lowerCamelCase  :    str					=					{
							    'prompt': 'a dog and a newt',
							    'mask_image': mask,
							    'image_latents': latents,
							    'generator': generator,
							    'num_inference_steps': 2,
							    'inpaint_strength': 1.0,
							    'guidance_scale': 6.0,
							    'output_type': 'numpy',
							}

							return inputs
			def       A_					(						self						,   lowercase						,   lowercase=0						):
							_lowerCamelCase  :    List[Any]					=					floats_tensor((1, 3, 32, 32)						,   rng=random.Random(lowercase						)						).to(lowercase						)
							_lowerCamelCase  :    str					=					image.cpu().permute(0						,   2						,   3						,   1						)[0]
							_lowerCamelCase  :    Optional[Any]					=					Image.fromarray(np.uinta(lowercase						)						).convert('RGB'						)
							if str(lowercase						).startswith('mps'						):
											_lowerCamelCase  :    Any					=					torch.manual_seed(lowercase						)
							else:
											_lowerCamelCase  :    Tuple					=					torch.Generator(device=lowercase						).manual_seed(lowercase						)
							_lowerCamelCase  :    str					=					{
							    'image': image,
							    'source_prompt': 'a cat and a frog',
							    'target_prompt': 'a dog and a newt',
							    'generator': generator,
							    'num_inference_steps': 2,
							    'num_maps_per_mask': 2,
							    'mask_encode_strength': 1.0,
							    'guidance_scale': 6.0,
							    'output_type': 'numpy',
							}

							return inputs
			def       A_					(						self						,   lowercase						,   lowercase=0						):
							_lowerCamelCase  :    List[str]					=					floats_tensor((1, 3, 32, 32)						,   rng=random.Random(lowercase						)						).to(lowercase						)
							_lowerCamelCase  :    List[Any]					=					image.cpu().permute(0						,   2						,   3						,   1						)[0]
							_lowerCamelCase  :    List[Any]					=					Image.fromarray(np.uinta(lowercase						)						).convert('RGB'						)
							if str(lowercase						).startswith('mps'						):
											_lowerCamelCase  :    List[Any]					=					torch.manual_seed(lowercase						)
							else:
											_lowerCamelCase  :    List[str]					=					torch.Generator(device=lowercase						).manual_seed(lowercase						)
							_lowerCamelCase  :    Any					=					{
							    'image': image,
							    'prompt': 'a cat and a frog',
							    'generator': generator,
							    'num_inference_steps': 2,
							    'inpaint_strength': 1.0,
							    'guidance_scale': 6.0,
							    'decode_latents': True,
							    'output_type': 'numpy',
							}
							return inputs
			def       A_					(						self						):
							if not hasattr(self.pipeline_class						,   '_optional_components'						):
											return

							_lowerCamelCase  :    List[str]					=					self.get_dummy_components()
							_lowerCamelCase  :    List[str]					=					self.pipeline_class(**lowercase						)
							pipe.to(lowercase						)
							pipe.set_progress_bar_config(disable=lowercase						)

							# set all optional components to None and update pipeline config accordingly
							for optional_component in pipe._optional_components:
											setattr(lowercase						,   lowercase						,   lowercase						)
							pipe.register_modules(**{optional_component: None for optional_component in pipe._optional_components}						)

							_lowerCamelCase  :    List[str]					=					self.get_dummy_inputs(lowercase						)
							_lowerCamelCase  :    List[Any]					=					pipe(**lowercase						)[0]

							with tempfile.TemporaryDirectory() as tmpdir:
											pipe.save_pretrained(lowercase						)
											_lowerCamelCase  :    Optional[int]					=					self.pipeline_class.from_pretrained(lowercase						)
											pipe_loaded.to(lowercase						)
											pipe_loaded.set_progress_bar_config(disable=lowercase						)

							for optional_component in pipe._optional_components:
											self.assertTrue(
											    getattr(lowercase						,   lowercase						) is None						,   F'''`{optional_component}` did not stay set to None after loading.'''						,   )

							_lowerCamelCase  :    List[Any]					=					self.get_dummy_inputs(lowercase						)
							_lowerCamelCase  :    Dict					=					pipe_loaded(**lowercase						)[0]

							_lowerCamelCase  :    List[Any]					=					np.abs(output - output_loaded						).max()
							self.assertLess(lowercase						,   1E-4						)
			def       A_					(						self						):
							_lowerCamelCase  :    Dict					=					'cpu'

							_lowerCamelCase  :    str					=					self.get_dummy_components()
							_lowerCamelCase  :    List[Any]					=					self.pipeline_class(**lowercase						)
							pipe.to(lowercase						)
							pipe.set_progress_bar_config(disable=lowercase						)

							_lowerCamelCase  :    str					=					self.get_dummy_mask_inputs(lowercase						)
							_lowerCamelCase  :    Tuple					=					pipe.generate_mask(**lowercase						)
							_lowerCamelCase  :    Tuple					=					mask[0, -3:, -3:]

							self.assertEqual(mask.shape						,   (1, 16, 16)						)
							_lowerCamelCase  :    int					=					np.array([0] * 9						)
							_lowerCamelCase  :    Dict					=					np.abs(mask_slice.flatten() - expected_slice						).max()
							self.assertLessEqual(lowercase						,   1E-3						)
							self.assertEqual(mask[0, -3, -4]						,   0						)
			def       A_					(						self						):
							_lowerCamelCase  :    List[Any]					=					'cpu'

							_lowerCamelCase  :    Optional[int]					=					self.get_dummy_components()
							_lowerCamelCase  :    List[Any]					=					self.pipeline_class(**lowercase						)
							pipe.to(lowercase						)
							pipe.set_progress_bar_config(disable=lowercase						)

							_lowerCamelCase  :    List[str]					=					self.get_dummy_inversion_inputs(lowercase						)
							_lowerCamelCase  :    str					=					pipe.invert(**lowercase						).images
							_lowerCamelCase  :    Optional[int]					=					image[0, -1, -3:, -3:]

							self.assertEqual(image.shape						,   (2, 32, 32, 3)						)
							_lowerCamelCase  :    Union[str, Any]					=					np.array(
							    [0.51_50, 0.51_34, 0.50_43, 0.53_76, 0.46_94, 0.5_10_50, 0.50_15, 0.44_07, 0.47_99]						,   )
							_lowerCamelCase  :    Any					=					np.abs(image_slice.flatten() - expected_slice						).max()
							self.assertLessEqual(lowercase						,   1E-3						)
			def       A_					(						self						):
							super().test_inference_batch_single_identical(expected_max_diff=5E-3						)






			def       A_					(						self						):
							_lowerCamelCase  :    Union[str, Any]					=					'cpu'

							_lowerCamelCase  :    List[str]					=					self.get_dummy_components()

							_lowerCamelCase  :    Tuple					=					{'beta_start': 0.0_00_85, 'beta_end': 0.0_12, 'beta_schedule': 'scaled_linear'}
							_lowerCamelCase  :    Optional[int]					=					DPMSolverMultistepScheduler(**lowercase						)
							_lowerCamelCase  :    Dict					=					DPMSolverMultistepInverseScheduler(**lowercase						)

							_lowerCamelCase  :    Optional[Any]					=					self.pipeline_class(**lowercase						)
							pipe.to(lowercase						)
							pipe.set_progress_bar_config(disable=lowercase						)

							_lowerCamelCase  :    List[str]					=					self.get_dummy_inversion_inputs(lowercase						)
							_lowerCamelCase  :    Optional[Any]					=					pipe.invert(**lowercase						).images
							_lowerCamelCase  :    Any					=					image[0, -1, -3:, -3:]

							self.assertEqual(image.shape						,   (2, 32, 32, 3)						)
							_lowerCamelCase  :    int					=					np.array(
							    [0.51_50, 0.51_34, 0.50_43, 0.53_76, 0.46_94, 0.5_10_50, 0.50_15, 0.44_07, 0.47_99]						,   )
							_lowerCamelCase  :    Any					=					np.abs(image_slice.flatten() - expected_slice						).max()
							self.assertLessEqual(lowercase						,   1E-3						)






@require_torch_gpu
@slow
class lowerCAmelCase__			(  unittest.TestCase		):






			'''simple docstring'''



			def       A_					(						self						):
							super().tearDown()
							gc.collect()
							torch.cuda.empty_cache()
			@classmethod
			def       A_					(						cls						):
							_lowerCamelCase  :    Union[str, Any]					=					load_image(
							    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/diffedit/fruit.png'						)

							_lowerCamelCase  :    int					=					raw_image.convert('RGB'						).resize((768, 768)						)

							_lowerCamelCase  :    Union[str, Any]					=					raw_image
			def       A_					(						self						):
							_lowerCamelCase  :    List[Any]					=					torch.manual_seed(0						)

							_lowerCamelCase  :    Optional[int]					=					StableDiffusionDiffEditPipeline.from_pretrained(
							    'stabilityai/stable-diffusion-2-1'						,   safety_checker=lowercase						,   torch_dtype=torch.floataa						)
							_lowerCamelCase  :    List[str]					=					DDIMScheduler.from_config(pipe.scheduler.config						)
							_lowerCamelCase  :    Optional[Any]					=					DDIMInverseScheduler.from_config(pipe.scheduler.config						)
							pipe.enable_model_cpu_offload()
							pipe.set_progress_bar_config(disable=lowercase						)

							_lowerCamelCase  :    Any					=					'a bowl of fruit'
							_lowerCamelCase  :    Optional[int]					=					'a bowl of pears'

							_lowerCamelCase  :    Union[str, Any]					=					pipe.generate_mask(
							    image=self.raw_image						,   source_prompt=lowercase						,   target_prompt=lowercase						,   generator=lowercase						,   )

							_lowerCamelCase  :    List[str]					=					pipe.invert(
							    prompt=lowercase						,   image=self.raw_image						,   inpaint_strength=0.7						,   generator=lowercase						).latents

							_lowerCamelCase  :    List[Any]					=					pipe(
							    prompt=lowercase						,   mask_image=lowercase						,   image_latents=lowercase						,   generator=lowercase						,   negative_prompt=lowercase						,   inpaint_strength=0.7						,   output_type='numpy'						,   ).images[0]

							_lowerCamelCase  :    str					=					(
							    np.array(
							        load_image(
							            'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
							            '/diffedit/pears.png'						).resize((768, 768)						)						)
							    / 255
							)
							assert np.abs((expected_image - image).max()						) < 5E-1






			def       A_					(						self						):
							_lowerCamelCase  :    List[str]					=					torch.manual_seed(0						)

							_lowerCamelCase  :    Optional[Any]					=					StableDiffusionDiffEditPipeline.from_pretrained(
							    'stabilityai/stable-diffusion-2-1'						,   safety_checker=lowercase						,   torch_dtype=torch.floataa						)
							_lowerCamelCase  :    Tuple					=					DPMSolverMultistepScheduler.from_config(pipe.scheduler.config						)
							_lowerCamelCase  :    int					=					DPMSolverMultistepInverseScheduler.from_config(pipe.scheduler.config						)
							pipe.enable_model_cpu_offload()
							pipe.set_progress_bar_config(disable=lowercase						)

							_lowerCamelCase  :    Dict					=					'a bowl of fruit'
							_lowerCamelCase  :    Optional[int]					=					'a bowl of pears'

							_lowerCamelCase  :    List[str]					=					pipe.generate_mask(
							    image=self.raw_image						,   source_prompt=lowercase						,   target_prompt=lowercase						,   generator=lowercase						,   )

							_lowerCamelCase  :    int					=					pipe.invert(
							    prompt=lowercase						,   image=self.raw_image						,   inpaint_strength=0.7						,   generator=lowercase						,   num_inference_steps=25						,   ).latents

							_lowerCamelCase  :    List[str]					=					pipe(
							    prompt=lowercase						,   mask_image=lowercase						,   image_latents=lowercase						,   generator=lowercase						,   negative_prompt=lowercase						,   inpaint_strength=0.7						,   num_inference_steps=25						,   output_type='numpy'						,   ).images[0]

							_lowerCamelCase  :    str					=					(
							    np.array(
							        load_image(
							            'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
							            '/diffedit/pears.png'						).resize((768, 768)						)						)
							    / 255
							)
							assert np.abs((expected_image - image).max()						) < 5E-1





"""simple docstring"""






from typing import Dict, List

from nltk.translate import gleu_score

import datasets
from datasets import MetricInfo


lowercase__  		=		"""\
@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}
}
"""

lowercase__  		=		"""\
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.
"""

lowercase__  		=		"""\
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 lowerCAmelCase__			(  datasets.Metric		):






			'''simple docstring'''



			def       A_					(						self						):
							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       A_					(						self						,   lowercase						,   lowercase						,   lowercase = 1						,   lowercase = 4						,   ):
							return {
							    "google_bleu": gleu_score.corpus_gleu(
							        list_of_references=lowercase						,   hypotheses=lowercase						,   min_len=lowercase						,   max_len=lowercase						)
							}