code: def test_n_gram_counter(candidates, references):
      bleu = Bleu(ngram=4)
      hyp_length, ref_length = bleu._n_gram_counter(
          [references], [candidates], Counter(), Counter()
      )
      assert hyp_length == len(candidates)
  
      ref_lens = (len(reference) for reference in references)
      closest_ref_len = min(
          ref_lens,
          key=lambda ref_len: (abs(ref_len - len(candidates)), ref_len),
      )
  
      assert ref_length == closest_ref_len
  
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 15 for calling a global function with example usage: test_n_gram_counter(candidates, references) without return types