code: def smoothed_sentence_bleu(task, target_tokens, hypo_tokens):
      """
      Implements "Smoothing 3" method from Chen and Cherry. "A Systematic
      Comparison of Smoothing Techniques for Sentence-Level BLEU".
      http://acl2014.org/acl2014/W14-33/pdf/W14-3346.pdf
      """
      dst_dict = task.target_dictionary
      scorer = bleu.Scorer(
          bleu.BleuConfig(
              pad=dst_dict.pad(),
              eos=dst_dict.eos(),
              unk=dst_dict.unk(),
          )
      )
      scorer.add(target_tokens, hypo_tokens)
  
      invcnt = 1
      ratios = []
      for match, count in [
          (scorer.stat.match1, scorer.stat.count1),
          (scorer.stat.match2, scorer.stat.count2),
          (scorer.stat.match3, scorer.stat.count3),
          (scorer.stat.match4, scorer.stat.count4),
      ]:
          if count == 0:
              # disregard n-grams for values of n larger than hypothesis length
              continue
          if match == 0:
              invcnt *= 2
              match = 1.0 / invcnt
          ratios.append(match / count)
  
      brevity_penalty = np.min(
          [1, np.exp(1 - (scorer.stat.reflen / scorer.stat.predlen))]
      )
      geometric_mean = np.exp(np.log(ratios).mean())
      smoothed_bleu = brevity_penalty * geometric_mean
      return smoothed_bleu
  
imports: import argparse
  import collections
  import os
  import pickle
  from typing import List, NamedTuple, Optional
  import numpy
  import torch
  from fairseq import data, iterative_refinement_generator, options, progress_bar, tasks, utils
  from fairseq.meters import StopwatchMeter, TimeMeter
  from fairseq.models import FairseqEncoderDecoderModel, FairseqMultiModel
  from fairseq.scoring import bleu
  from pytorch_translate import beam_decode, char_aware_hybrid, char_source_hybrid, char_source_model, char_source_transformer_model, hybrid_transformer_rnn, options, rnn, transformer, utils
  from pytorch_translate.constants import CHECKPOINT_PATHS_DELIMITER
  from pytorch_translate.data import data
  from pytorch_translate.dual_learning.dual_learning_models import DualLearningModel
  from pytorch_translate.research.beam_search import competing_completed
  from pytorch_translate.research.multisource import multisource_data, multisource_decode
  from pytorch_translate.tasks.pytorch_translate_multi_task import PyTorchTranslateMultiTask
  from pytorch_translate.tasks.pytorch_translate_task import PytorchTranslateTask
label_desc: Use image node_id 4 for calling a global function with example usage: smoothed_sentence_bleu(task, target_tokens, hypo_tokens) and returns: smoothed_bleu