code: def compute_ngram_scores(
      candidate: Sequence[Any], reference: Sequence[Any], n: int = 4
  ) -> Score:
      """
      Compute the score based on ngram co-occurence of sequences of items
  
      Args:
          candidate: candidate sequence of items
          reference: reference sequence of items
          n: ngram order
  
      Returns:
          The score containing the number of ngram co-occurences
  
      .. versionadded:: 0.4.5
      """
  
      # ngrams of the candidate
      candidate_counter = ngrams(candidate, n)
      # ngrams of the references
      reference_counter = ngrams(reference, n)
      # ngram co-occurences in the candidate and the references
      match_counters = candidate_counter & reference_counter
  
      # the score is defined using Fraction
      return Score(
          match=sum(match_counters.values()),
          candidate=sum(candidate_counter.values()),
          reference=sum(reference_counter.values()),
      )
  
imports: from abc import ABCMeta, abstractmethod
  from collections import namedtuple
  from typing import Any, Callable, List, Mapping, Optional, Sequence, Tuple, Union
  import torch
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Metric
  from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
  from ignite.metrics.nlp.utils import lcs, ngrams
label_desc: Use image node_id 1 for calling a global function with example usage: compute_ngram_scores(candidate, reference, n) and returns: Score