code: def _test(
      candidates,
      references,
      average,
      smooth="no_smooth",
      smooth_nltk_fn=None,
      ngram_range=8,
  ):
      for i in range(1, ngram_range):
          weights = tuple([1 / i] * i)
          bleu = Bleu(ngram=i, average=average, smooth=smooth)
  
          if average == "macro":
              with warnings.catch_warnings():
                  warnings.simplefilter("ignore")
                  reference = sentence_bleu(
                      references[0],
                      candidates[0],
                      weights=weights,
                      smoothing_function=smooth_nltk_fn,
                  )
              assert pytest.approx(reference) == bleu._sentence_bleu(
                  references[0], candidates[0]
              )
  
          elif average == "micro":
              with warnings.catch_warnings():
                  warnings.simplefilter("ignore")
                  reference = corpus_bleu(
                      references,
                      candidates,
                      weights=weights,
                      smoothing_function=smooth_nltk_fn,
                  )
              assert pytest.approx(reference) == bleu._corpus_bleu(
                  references, candidates
              )
  
          bleu.update((candidates, references))
          assert pytest.approx(reference) == bleu.compute()
  
imports: import os
  import warnings
  from collections import Counter
  import pytest
  import torch
  from nltk.translate.bleu_score import corpus_bleu, sentence_bleu, SmoothingFunction
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics.nlp import Bleu
  from .None import CorpusForTest
label_desc: Use image node_id 2 for calling a global function with example usage: _test(candidates, references, average, smooth, smooth_nltk_fn, ngram_range) without return types