docstr: Function maps counts of ngram to vector of tf-idf weights.
  The function returns vec, an array of dictionary that store mapping of
  n-gram and tf-idf weights. The n-th entry of array denotes length of
  n-grams.
  :param counts:
  :return: vec (array of dict), norm (array of float), length (int)
docstr_tok: ["Function","maps","counts","of","ngram","to","vector","of","tf-idf","weights",".","The","function","returns","vec",",","an","array","of","dictionary","that","store","mapping","of","n-gram","and","tf-idf","weights",".","The","n-th","entry","of","array","denotes","length","of","n-grams",".",":","param","counts",":",":","return",":","vec","(","array","of","dict",")",",","norm","(","array","of","float",")",",","length","(","int",")"]
code: def _counts_to_vec(
      self, counts: Dict[Tuple[str], int]
  ) -> Tuple[List[Dict[Tuple[str], float]], List[float], int]:
      """
      Function maps counts of ngram to vector of tf-idf weights.
      The function returns vec, an array of dictionary that store mapping of
      n-gram and tf-idf weights. The n-th entry of array denotes length of
      n-grams.
      :param counts:
      :return: vec (array of dict), norm (array of float), length (int)
      """
      vec = [defaultdict(float) for _ in range(self.n)]
      length = 0
      norm = [0.0 for _ in range(self.n)]
      for ngram, term_freq in counts.items():
          # Give word count 1 if it doesn't appear in reference corpus
          cur_doc_freq = np.log(max(1.0, self.doc_freq[ngram]))
          # ngram index
          n = len(ngram) - 1
          # tf (term_freq) * idf (precomputed idf) for n-grams
          vec[n][ngram] = float(term_freq) * (
              self.ref_len - cur_doc_freq
          )
          # Compute vector norm, use it for computing similarity
          norm[n] += pow(vec[n][ngram], 2)
          if n == 1:
              length += term_freq
      norm = [np.sqrt(n) for n in norm]
      return vec, norm, length
  
file_path: vizseq/vizseq/scorers/_cider/__init__.py
imports: from typing import List, Dict, Tuple
  from collections import defaultdict
  import math
  from concurrent.futures import ProcessPoolExecutor, as_completed
  import numpy
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling the _CIDErScorer obj's underlying member method code with example usage: obj._counts_to_vec(counts) and returns: vec,  norm,  length