class_docstr: Efficient index for retrieval. Note: default settings are for hugh accuracy but also high RAM usage
code: def index_data(self, data: np.array):
      n = len(data)
  
      # max norm is required before putting all vectors in the index to convert inner product similarity to L2
      if self.phi > 0:
          raise RuntimeError(
              "DPR HNSWF index needs to index all data at once,"
              "results will be unpredictable otherwise."
          )
      phi = 0
      for i, item in enumerate(data):
          doc_vector = item
          norms = (doc_vector**2).sum()
          phi = max(phi, norms)
      logger.info("HNSWF DotProduct -> L2 space phi={}".format(phi))
      self.phi = 0
  
      # indexing in batches is beneficial for many faiss index types
      logger.info("Indexing data, this may take a while.")
      cnt = 0
      for i in range(0, n, self.buffer_size):
          vectors = [
              np.reshape(t, (1, -1))
              for t in data[i : i + self.buffer_size]
          ]
  
          norms = [(doc_vector**2).sum() for doc_vector in vectors]
          aux_dims = [np.sqrt(phi - norm) for norm in norms]
          hnsw_vectors = [
              np.hstack((doc_vector, aux_dims[i].reshape(-1, 1)))
              for i, doc_vector in enumerate(vectors)
          ]
          hnsw_vectors = np.concatenate(hnsw_vectors, axis=0)
  
          self.index.add(hnsw_vectors)
          cnt += self.buffer_size
          logger.info("Indexed data %d" % cnt)
  
      logger.info("Total data indexed %d" % n)
  
imports: import os
  import logging
  import pickle
  import faiss
  import numpy
label_desc: Use image node_id 2 for calling the DenseHNSWFlatIndexer obj's underlying member method code with example usage: obj.index_data(data) without return types