docstr: Calculates frequencies of terms in documents and in corpus.
  This algorithm sets a floor on the idf values to eps * average_idf
docstr_tok: ["Calculates","frequencies","of","terms","in","documents","and","in","corpus",".","This","algorithm","sets","a","floor","on","the","idf","values","to","eps","*","average_idf"]
code: def _calc_idf(self, nd):
      """
      Calculates frequencies of terms in documents and in corpus.
      This algorithm sets a floor on the idf values to eps * average_idf
      """
      # collect idf sum to calculate an average idf for epsilon value
      idf_sum = 0
      # collect words with negative idf to set them a special epsilon value.
      # idf can be negative if word is contained in more than half of documents
      negative_idfs = []
      for word, freq in nd.items():
          idf = math.log(self.corpus_size - freq + 0.5) - math.log(
              freq + 0.5
          )
          self.idf[word] = idf
          idf_sum += idf
          if idf < 0:
              negative_idfs.append(word)
      self.average_idf = idf_sum / len(self.idf)
  
      eps = self.epsilon * self.average_idf
      for word in negative_idfs:
          self.idf[word] = eps
  
imports: from nboost.plugins import Plugin
  from nboost.delegates import ResponseDelegate
  from nboost.database import DatabaseRow
  import numpy
  from multiprocessing import Pool, cpu_count
  import math
  from nltk.stem import PorterStemmer
  from nltk.tokenize import word_tokenize
  from nltk.corpus import stopwords
  import nltk
label_desc: Use image node_id 2 for calling the BM25Okapi obj's underlying member method code with example usage: obj._calc_idf(nd) without return types