code: def _initialize(self, corpus):
      nd = {}  # word -> number of documents with word
      num_doc = 0
      for document in corpus:
          self.doc_len.append(len(document))
          num_doc += len(document)
  
          frequencies = {}
          for word in document:
              if word not in frequencies:
                  frequencies[word] = 0
              frequencies[word] += 1
          self.doc_freqs.append(frequencies)
  
          for word, freq in frequencies.items():
              if word not in nd:
                  nd[word] = 0
              nd[word] += 1
  
      self.avgdl = num_doc / self.corpus_size
      return nd
  
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 BM25 obj's underlying member method code with example usage: obj._initialize(corpus) and returns: nd