



from typing import Any, Dict, Optional

import torch
import torch.nn.functional as F
from torch import nn

from ..utils import maybe_allow_in_graph
from .activations import get_activation
from .attention_processor import Attention
from .embeddings import CombinedTimestepLabelEmbeddings






@maybe_allow_in_graph
class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						str						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Dict=0.0						,  __UpperCAmelCase     :						Optional[int] = None						,  __UpperCAmelCase     :						str = "geglu"						,  __UpperCAmelCase     :						Optional[int] = None						,  __UpperCAmelCase     :						bool = False						,  __UpperCAmelCase     :						bool = False						,  __UpperCAmelCase     :						bool = False						,  __UpperCAmelCase     :						bool = False						,  __UpperCAmelCase     :						bool = True						,  __UpperCAmelCase     :						str = "layer_norm"						,  __UpperCAmelCase     :						bool = False						,  )      ->			str:
							super().__init__()
							UpperCAmelCase_=       only_cross_attention

							UpperCAmelCase_=       (num_embeds_ada_norm is not None) and norm_type == """ada_norm_zero"""
							UpperCAmelCase_=       (num_embeds_ada_norm is not None) and norm_type == """ada_norm"""

							if norm_type in ("ada_norm", "ada_norm_zero") and num_embeds_ada_norm is None:
													raise ValueError(
													    F"""`norm_type` is set to {norm_type}, but `num_embeds_ada_norm` is not defined. Please make sure to"""
													    F""" define `num_embeds_ada_norm` if setting `norm_type` to {norm_type}."""					)

							# Define 3 blocks. Each block has its own normalization layer.
							# 1. Self-Attn
							if self.use_ada_layer_norm:
													UpperCAmelCase_=       AdaLayerNorm(__UpperCAmelCase						,  __UpperCAmelCase					)
							elif self.use_ada_layer_norm_zero:
													UpperCAmelCase_=       AdaLayerNormZero(__UpperCAmelCase						,  __UpperCAmelCase					)
							else:
													UpperCAmelCase_=       nn.LayerNorm(__UpperCAmelCase						,  elementwise_affine=__UpperCAmelCase					)
							UpperCAmelCase_=       Attention(
							    query_dim=__UpperCAmelCase						,  heads=__UpperCAmelCase						,  dim_head=__UpperCAmelCase						,  dropout=__UpperCAmelCase						,  bias=__UpperCAmelCase						,  cross_attention_dim=cross_attention_dim if only_cross_attention else None						,  upcast_attention=__UpperCAmelCase						,  )

							# 2. Cross-Attn
							if cross_attention_dim is not None or double_self_attention:
													# We currently only use AdaLayerNormZero for self attention where there will only be one attention block.
													# I.e. the number of returned modulation chunks from AdaLayerZero would not make sense if returned during
													# the second cross attention block.
													UpperCAmelCase_=       (
													    AdaLayerNorm(__UpperCAmelCase						,  __UpperCAmelCase					)
													    if self.use_ada_layer_norm
													    else nn.LayerNorm(__UpperCAmelCase						,  elementwise_affine=__UpperCAmelCase					)
													)
													UpperCAmelCase_=       Attention(
													    query_dim=__UpperCAmelCase						,  cross_attention_dim=cross_attention_dim if not double_self_attention else None						,  heads=__UpperCAmelCase						,  dim_head=__UpperCAmelCase						,  dropout=__UpperCAmelCase						,  bias=__UpperCAmelCase						,  upcast_attention=__UpperCAmelCase						,  )  # is self-attn if encoder_hidden_states is none
							else:
													UpperCAmelCase_=       None
													UpperCAmelCase_=       None

							# 3. Feed-forward
							UpperCAmelCase_=       nn.LayerNorm(__UpperCAmelCase						,  elementwise_affine=__UpperCAmelCase					)
							UpperCAmelCase_=       FeedForward(__UpperCAmelCase						,  dropout=__UpperCAmelCase						,  activation_fn=__UpperCAmelCase						,  final_dropout=__UpperCAmelCase					)

							# let chunk size default to None
							UpperCAmelCase_=       None
							UpperCAmelCase_=       0




	def   _SCREAMING_SNAKE_CASE		(     self     :						int						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						int					)      ->			Optional[int]:
							# Sets chunk feed-forward
							UpperCAmelCase_=       chunk_size
							UpperCAmelCase_=       dim




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						torch.FloatTensor						,  __UpperCAmelCase     :						Optional[torch.FloatTensor] = None						,  __UpperCAmelCase     :						Optional[torch.FloatTensor] = None						,  __UpperCAmelCase     :						Optional[torch.FloatTensor] = None						,  __UpperCAmelCase     :						Optional[torch.LongTensor] = None						,  __UpperCAmelCase     :						Dict[str, Any] = None						,  __UpperCAmelCase     :						Optional[torch.LongTensor] = None						,  )      ->			List[Any]:
							# Notice that normalization is always applied before the real computation in the following blocks.
							# 1. Self-Attention
							if self.use_ada_layer_norm:
													UpperCAmelCase_=       self.norma(__UpperCAmelCase						,  __UpperCAmelCase					)
							elif self.use_ada_layer_norm_zero:
													UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       self.norma(
													    __UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase						,  hidden_dtype=hidden_states.dtype					)
							else:
													UpperCAmelCase_=       self.norma(__UpperCAmelCase					)

							UpperCAmelCase_=       cross_attention_kwargs if cross_attention_kwargs is not None else {}

							UpperCAmelCase_=       self.attna(
							    __UpperCAmelCase						,  encoder_hidden_states=encoder_hidden_states if self.only_cross_attention else None						,  attention_mask=__UpperCAmelCase						,  **__UpperCAmelCase						,  )
							if self.use_ada_layer_norm_zero:
													UpperCAmelCase_=       gate_msa.unsqueeze(1					) * attn_output
							UpperCAmelCase_=       attn_output + hidden_states

							# 2. Cross-Attention
							if self.attna is not None:
													UpperCAmelCase_=       (
													    self.norma(__UpperCAmelCase						,  __UpperCAmelCase					) if self.use_ada_layer_norm else self.norma(__UpperCAmelCase					)
													)

													UpperCAmelCase_=       self.attna(
													    __UpperCAmelCase						,  encoder_hidden_states=__UpperCAmelCase						,  attention_mask=__UpperCAmelCase						,  **__UpperCAmelCase						,  )
													UpperCAmelCase_=       attn_output + hidden_states

							# 3. Feed-forward
							UpperCAmelCase_=       self.norma(__UpperCAmelCase					)

							if self.use_ada_layer_norm_zero:
													UpperCAmelCase_=       norm_hidden_states * (1 + scale_mlp[:, None]) + shift_mlp[:, None]

							if self._chunk_size is not None:
													# "feed_forward_chunk_size" can be used to save memory
													if norm_hidden_states.shape[self._chunk_dim] % self._chunk_size != 0:
																			raise ValueError(
																			    F"""`hidden_states` dimension to be chunked: {norm_hidden_states.shape[self._chunk_dim]} has to be divisible by chunk size: {self._chunk_size}. Make sure to set an appropriate `chunk_size` when calling `unet.enable_forward_chunking`."""					)

													UpperCAmelCase_=       norm_hidden_states.shape[self._chunk_dim] // self._chunk_size
													UpperCAmelCase_=       torch.cat(
													    [self.ff(__UpperCAmelCase					) for hid_slice in norm_hidden_states.chunk(__UpperCAmelCase						,  dim=self._chunk_dim					)]						,  dim=self._chunk_dim						,  )
							else:
													UpperCAmelCase_=       self.ff(__UpperCAmelCase					)

							if self.use_ada_layer_norm_zero:
													UpperCAmelCase_=       gate_mlp.unsqueeze(1					) * ff_output

							UpperCAmelCase_=       ff_output + hidden_states

							return hidden_states






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Optional[int] = None						,  __UpperCAmelCase     :						int = 4						,  __UpperCAmelCase     :						float = 0.0						,  __UpperCAmelCase     :						str = "geglu"						,  __UpperCAmelCase     :						bool = False						,  )      ->			Any:
							super().__init__()
							UpperCAmelCase_=       int(dim * mult					)
							UpperCAmelCase_=       dim_out if dim_out is not None else dim

							if activation_fn == "gelu":
													UpperCAmelCase_=       GELU(__UpperCAmelCase						,  __UpperCAmelCase					)
							if activation_fn == "gelu-approximate":
													UpperCAmelCase_=       GELU(__UpperCAmelCase						,  __UpperCAmelCase						,  approximate="""tanh"""					)
							elif activation_fn == "geglu":
													UpperCAmelCase_=       GEGLU(__UpperCAmelCase						,  __UpperCAmelCase					)
							elif activation_fn == "geglu-approximate":
													UpperCAmelCase_=       ApproximateGELU(__UpperCAmelCase						,  __UpperCAmelCase					)

							UpperCAmelCase_=       nn.ModuleList([]					)
							# project in
							self.net.append(__UpperCAmelCase					)
							# project dropout
							self.net.append(nn.Dropout(__UpperCAmelCase					)					)
							# project out
							self.net.append(nn.Linear(__UpperCAmelCase						,  __UpperCAmelCase					)					)
							# FF as used in Vision Transformer, MLP-Mixer, etc. have a final dropout
							if final_dropout:
													self.net.append(nn.Dropout(__UpperCAmelCase					)					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						Tuple					)      ->			int:
							for module in self.net:
													UpperCAmelCase_=       module(__UpperCAmelCase					)
							return hidden_states






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						str = "none"					)      ->			Tuple:
							super().__init__()
							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  __UpperCAmelCase					)
							UpperCAmelCase_=       approximate




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[int]						,  __UpperCAmelCase     :						Optional[Any]					)      ->			List[Any]:
							if gate.device.type != "mps":
													return F.gelu(__UpperCAmelCase						,  approximate=self.approximate					)
							# mps: gelu is not implemented for float16
							return F.gelu(gate.to(dtype=torch.floataa					)						,  approximate=self.approximate					).to(dtype=gate.dtype					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						Dict					)      ->			List[Any]:
							UpperCAmelCase_=       self.proj(__UpperCAmelCase					)
							UpperCAmelCase_=       self.gelu(__UpperCAmelCase					)
							return hidden_states






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Dict						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int					)      ->			Dict:
							super().__init__()
							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  dim_out * 2					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						Union[str, Any]					)      ->			int:
							if gate.device.type != "mps":
													return F.gelu(__UpperCAmelCase					)
							# mps: gelu is not implemented for float16
							return F.gelu(gate.to(dtype=torch.floataa					)					).to(dtype=gate.dtype					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						List[Any]						,  __UpperCAmelCase     :						List[Any]					)      ->			Optional[Any]:
							UpperCAmelCase_,       UpperCAmelCase_=       self.proj(__UpperCAmelCase					).chunk(2						,  dim=-1					)
							return hidden_states * self.gelu(__UpperCAmelCase					)






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int					)      ->			str:
							super().__init__()
							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  __UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						int					)      ->			str:
							UpperCAmelCase_=       self.proj(__UpperCAmelCase					)
							return x * torch.sigmoid(1.702 * x					)






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Tuple						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Optional[Any]					)      ->			Any:
							super().__init__()
							UpperCAmelCase_=       nn.Embedding(__UpperCAmelCase						,  __UpperCAmelCase					)
							UpperCAmelCase_=       nn.SiLU()
							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  embedding_dim * 2					)
							UpperCAmelCase_=       nn.LayerNorm(__UpperCAmelCase						,  elementwise_affine=__UpperCAmelCase					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						int					)      ->			Union[str, Any]:
							UpperCAmelCase_=       self.linear(self.silu(self.emb(__UpperCAmelCase					)					)					)
							UpperCAmelCase_,       UpperCAmelCase_=       torch.chunk(__UpperCAmelCase						,  2					)
							UpperCAmelCase_=       self.norm(__UpperCAmelCase					) * (1 + scale) + shift
							return x






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Union[str, Any]						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						str					)      ->			List[Any]:
							super().__init__()

							UpperCAmelCase_=       CombinedTimestepLabelEmbeddings(__UpperCAmelCase						,  __UpperCAmelCase					)

							UpperCAmelCase_=       nn.SiLU()
							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  6 * embedding_dim						,  bias=__UpperCAmelCase					)
							UpperCAmelCase_=       nn.LayerNorm(__UpperCAmelCase						,  elementwise_affine=__UpperCAmelCase						,  eps=1E-6					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Optional[Any]						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int=None					)      ->			str:
							UpperCAmelCase_=       self.linear(self.silu(self.emb(__UpperCAmelCase						,  __UpperCAmelCase						,  hidden_dtype=__UpperCAmelCase					)					)					)
							UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_=       emb.chunk(6						,  dim=1					)
							UpperCAmelCase_=       self.norm(__UpperCAmelCase					) * (1 + scale_msa[:, None]) + shift_msa[:, None]
							return x, gate_msa, shift_mlp, scale_mlp, gate_mlp






class 		lowercase						(			nn.Module):






	"""simple docstring"""


	def __init__(     self     :						Any						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Optional[str] = None						,  __UpperCAmelCase     :						float = 1E-5					)      ->			List[str]:
							super().__init__()
							UpperCAmelCase_=       num_groups
							UpperCAmelCase_=       eps

							if act_fn is None:
													UpperCAmelCase_=       None
							else:
													UpperCAmelCase_=       get_activation(__UpperCAmelCase					)

							UpperCAmelCase_=       nn.Linear(__UpperCAmelCase						,  out_dim * 2					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						Optional[int]						,  __UpperCAmelCase     :						Any					)      ->			Optional[Any]:
							if self.act:
													UpperCAmelCase_=       self.act(__UpperCAmelCase					)
							UpperCAmelCase_=       self.linear(__UpperCAmelCase					)
							UpperCAmelCase_=       emb[:, :, None, None]
							UpperCAmelCase_,       UpperCAmelCase_=       emb.chunk(2						,  dim=1					)

							UpperCAmelCase_=       F.group_norm(__UpperCAmelCase						,  self.num_groups						,  eps=self.eps					)
							UpperCAmelCase_=       x * (1 + scale) + shift
							return x









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					)
							}




