class_docstr: Indexer for Dense, HNSW FLAT Index.
  
  High retrieval accuracy comes at the cost of High RAM Usage.
docstr: Index data.
  
  The HNSW Flat Indexer computes an auxiliary dimension that converts inner product
  similarity to L2 distance similarity.
  
  :param data:
      List of torch.Tensor
docstr_tok: ["Index","data",".","The","HNSW","Flat","Indexer","computes","an","auxiliary","dimension","that","converts","inner","product","similarity","to","L2","distance","similarity",".",":","param","data",":","List","of","torch.Tensor"]
code: def index_data(self, tensors: List[torch.Tensor]):
      """
      Index data.
  
      The HNSW Flat Indexer computes an auxiliary dimension that converts inner product
      similarity to L2 distance similarity.
  
      :param data:
          List of torch.Tensor
      """
      data = torch.cat(tensors).float()
      n = data.size(0)
      # max norm is required before putting all vectors in the index to convert inner product similarity to L2
      if self.built:
          raise RuntimeError(
              "HNSW index needs to index all data at once, results will be unpredictable otherwise."
          )
      phi = 0
      norms = (data**2).sum(dim=1)
      max_norms = norms.max().item()
      phi = max(phi, max_norms)
      logging.info(f"HNSWF DotProduct -> L2 space phi={phi}")
      start = time.time()
  
      for i in range(0, n, self.buffer_size):
          vectors_i = data[i : i + self.buffer_size]
          norms_i = norms[i : i + self.buffer_size]
          aux_dims = torch.sqrt(phi - norms_i)
          hnsw_vectors = torch.cat(
              [vectors_i, aux_dims.unsqueeze(1)], dim=1
          )
          self.index.add(hnsw_vectors.numpy())
          logging.info(
              f"{time.time() - start}s Elapsed: data indexed {i + len(vectors_i)}"
          )
  
      logging.info(f"Total data indexed {n}")
  
imports: from parlai.core.build_data import modelzoo_path
  from parlai.core.opt import Opt
  import parlai.utils.logging
  from abc import ABC, abstractmethod
  import math
  import numpy
  import os
  import random
  import time
  import torch
  import torch.cuda
  from typing import List, Tuple, Optional
  from parlai.agents.rag.args import WIKIPEDIA_COMPRESSED_INDEX, WIKIPEDIA_EXACT_INDEX
label_desc: Use image node_id 2 for calling the DenseHNSWFlatIndexer obj's underlying member method code with example usage: obj.index_data(tensors) without return types