code: def bleu_advanced(
      y_true: List[Any],
      y_predicted: List[Any],
      weights: Tuple = (1,),
      smoothing_function=SMOOTH.method1,
      auto_reweigh=False,
      penalty=True,
  ) -> float:
      """Calculate BLEU score
  
      Parameters:
          y_true: list of reference tokens
          y_predicted: list of query tokens
          weights: n-gram weights
          smoothing_function: SmoothingFunction
          auto_reweigh: Option to re-normalize the weights uniformly
          penalty: either enable brevity penalty or not
  
      Return:
          BLEU score
      """
  
      bleu_measure = sentence_bleu(
          [y_true],
          y_predicted,
          weights,
          smoothing_function,
          auto_reweigh,
      )
  
      hyp_len = len(y_predicted)
      hyp_lengths = hyp_len
      ref_lengths = closest_ref_length([y_true], hyp_len)
  
      bpenalty = brevity_penalty(ref_lengths, hyp_lengths)
  
      if penalty is True or bpenalty == 0:
          return bleu_measure
  
      return bleu_measure / bpenalty
  
file_path: DeepPavlov/deeppavlov/metrics/bleu.py
imports: import itertools
  from typing import List, Tuple, Any
  from nltk.translate.bleu_score import corpus_bleu, sentence_bleu, SmoothingFunction, brevity_penalty, closest_ref_length
  from deeppavlov.core.common.metrics_registry import register_metric
  from deeppavlov.metrics.google_bleu import compute_bleu
label_desc: Use image node_id 1 for calling a global function with example usage: bleu_advanced(y_true, y_predicted, weights, smoothing_function, auto_reweigh, penalty) and returns: unknown, bleu_measure