class_docstr: Computes BLEU Score.
class_docstr_tok: ["Computes","BLEU","Score","."]
docstr: Initializes BLEU Combiner.
  
  Args:
    eval_config: Eval config.
    model_name: The model for which to compute these metrics.
    output_name: The output name for which to compute these metrics.
    key: MetricKey for extract_output().
    **bleu_kwargs: kwargs to initialize BLEU Metric. Possible options include
      'lowercase' (If True, lowercases the input, enabling
      case-insensitivity.), 'force' (If True, insists that the tokenized input
      is detokenized.), 'tokenize' (Tokenization method to use for BLEU.
      Possible values are 'none' (No tokenization), 'zh' (Chinese
      tokenization), '13a' (mimics the mteval-v13a from Moses), and 'intl'
      (International tokenization, mimics the mteval-v14 script from Moses).),
      'smooth_method' (The smoothing method to use. Possible values are 'none'
      (no smoothing), 'floor' (increment zero counts), 'add-k' (increment
      num/denom by k for n>1), and 'exp' (exponential decay).), 'smooth_value'
      (The smoothing value. Only valid when smoothmethod='floor' or
      smooth_method='add-k'.), and 'effective_order' (If True, stops including
      n-gram orders for which precision is 0. This should be True if
      sentence-level BLEU will be computed.).
docstr_tok: ["Initializes","BLEU","Combiner",".","Args",":","eval_config",":","Eval","config",".","model_name",":","The","model","for","which","to","compute","these","metrics",".","output_name",":","The","output","name","for","which","to","compute","these","metrics",".","key",":","MetricKey","for","extract_output","(",")",".","*","*","bleu_kwargs",":","kwargs","to","initialize","BLEU","Metric",".","Possible","options","include","'lowercase","'","(","If","True",",","lowercases","the","input",",","enabling","case-insensitivity",".",")",",","'force","'","(","If","True",",","insists","that","the","tokenized","input","is","detokenized",".",")",",","'tokenize","'","(","Tokenization","method","to","use","for","BLEU",".","Possible","values","are","'none","'","(","No","tokenization",")",",","'zh","'","(","Chinese","tokenization",")",",","'13a","'","(","mimics","the","mteval-v13a","from","Moses",")",",","and","'intl'","(","International","tokenization",",","mimics","the","mteval-v14","script","from","Moses",")",".",")",",","'smooth_method","'","(","The","smoothing","method","to","use",".","Possible","values","are","'none'","(","no","smoothing",")",",","'floor","'","(","increment","zero","counts",")",",","'add-k","'","(","increment","num\/denom","by","k","for","n",">","1",")",",","and","'exp","'","(","exponential","decay",")",".",")",",","'smooth_value'","(","The","smoothing","value",".","Only","valid","when","smoothmethod='floor","'","or","smooth_method='add-k","'",".",")",",","and","'effective_order","'","(","If","True",",","stops","including","n-gram","orders","for","which","precision","is","0",".","This","should","be","True","if","sentence-level","BLEU","will","be","computed",".",")","."]
code: def __init__(
      self,
      eval_config: config_pb2.EvalConfig,
      model_name: str,
      output_name: str,
      key: metric_types.MetricKey,
      **bleu_kwargs,
  ):
      """Initializes BLEU Combiner.
  
      Args:
        eval_config: Eval config.
        model_name: The model for which to compute these metrics.
        output_name: The output name for which to compute these metrics.
        key: MetricKey for extract_output().
        **bleu_kwargs: kwargs to initialize BLEU Metric. Possible options include
          'lowercase' (If True, lowercases the input, enabling
          case-insensitivity.), 'force' (If True, insists that the tokenized input
          is detokenized.), 'tokenize' (Tokenization method to use for BLEU.
          Possible values are 'none' (No tokenization), 'zh' (Chinese
          tokenization), '13a' (mimics the mteval-v13a from Moses), and 'intl'
          (International tokenization, mimics the mteval-v14 script from Moses).),
          'smooth_method' (The smoothing method to use. Possible values are 'none'
          (no smoothing), 'floor' (increment zero counts), 'add-k' (increment
          num/denom by k for n>1), and 'exp' (exponential decay).), 'smooth_value'
          (The smoothing value. Only valid when smoothmethod='floor' or
          smooth_method='add-k'.), and 'effective_order' (If True, stops including
          n-gram orders for which precision is 0. This should be True if
          sentence-level BLEU will be computed.).
      """
      self.eval_config = eval_config
      self.model_name = model_name
      self.output_name = output_name
      self.key = key
      self.bleu_metric = sacrebleu.metrics.BLEU(**bleu_kwargs)
      # len(stats) = len(hyp_len) + len(ref_len) + len(correct) + len(total)
      # = 1 + 1 + max_ngram_order + max_ngram_order = 2 + 2 * max_ngram_order
      self.stats_len = 2 + 2 * self.bleu_metric.max_ngram_order
  
file_path: model-analysis/tensorflow_model_analysis/metrics/bleu.py
imports: from typing import Dict, Iterable, Optional
  import apache_beam
  import numpy
  import sacrebleu
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 1 to create a new _BleuCombiner object from inherited base classes: beam with example: obj = _BleuCombiner(eval_config, model_name, output_name, key)