code: def _kl_divergence(self, summary_freq, doc_freq):
          
          sum_val = 0
          for w in summary_freq:
              frequency = doc_freq.get(w)
              if frequency:  # missing or zero = no frequency
                  sum_val += frequency * math.log(frequency / summary_freq[w])
  
          return sum_val
docs: Note: Could import scipy.stats and use scipy.stats.entropy(doc_freq, summary_freq)
          but this gives equivalent value without the import