code: def reverse_index_factory(index):
      """
      attempts to get the factory string the index was built with
      """
      index = faiss.downcast_index(index)
      if isinstance(index, faiss.IndexFlat):
          return "Flat"
      elif isinstance(index, faiss.IndexIVF):
          quantizer = faiss.downcast_index(index.quantizer)
  
          if isinstance(quantizer, faiss.IndexFlat):
              prefix = f"IVF{index.nlist}"
          elif isinstance(quantizer, faiss.MultiIndexQuantizer):
              prefix = f"IMI{quantizer.pq.M}x{quantizer.pq.nbits}"
          elif isinstance(quantizer, faiss.IndexHNSW):
              prefix = f"IVF{index.nlist}_HNSW{get_hnsw_M(quantizer)}"
          else:
              prefix = f"IVF{index.nlist}({reverse_index_factory(quantizer)})"
  
          if isinstance(index, faiss.IndexIVFFlat):
              return prefix + ",Flat"
          if isinstance(index, faiss.IndexIVFScalarQuantizer):
              return prefix + ",SQ8"
          if isinstance(index, faiss.IndexIVFPQ):
              return prefix + f",PQ{index.pq.M}x{index.pq.nbits}"
          if isinstance(index, faiss.IndexIVFPQFastScan):
              return prefix + f",PQ{index.pq.M}x{index.pq.nbits}fs"
  
      elif isinstance(index, faiss.IndexPreTransform):
          if index.chain.size() != 1:
              raise NotImplementedError()
          vt = faiss.downcast_VectorTransform(index.chain.at(0))
          if isinstance(vt, faiss.OPQMatrix):
              prefix = f"OPQ{vt.M}_{vt.d_out}"
          elif isinstance(vt, faiss.ITQTransform):
              prefix = f"ITQ{vt.itq.d_out}"
          elif isinstance(vt, faiss.PCAMatrix):
              assert vt.eigen_power == 0
              prefix = (
                  "PCA"
                  + ("R" if vt.random_rotation else "")
                  + str(vt.d_out)
              )
          else:
              raise NotImplementedError()
          return f"{prefix},{reverse_index_factory(index.index)}"
  
      elif isinstance(index, faiss.IndexHNSW):
          return f"HNSW{get_hnsw_M(index)}"
  
      elif isinstance(index, faiss.IndexRefine):
          return f"{reverse_index_factory(index.base_index)},Refine({reverse_index_factory(index.refine_index)})"
  
      elif isinstance(index, faiss.IndexPQFastScan):
          return f"PQ{index.pq.M}x{index.pq.nbits}fs"
  
      elif isinstance(index, faiss.IndexPQ):
          return f"PQ{index.pq.M}x{index.pq.nbits}"
  
      elif isinstance(index, faiss.IndexLSH):
          return (
              "LSH"
              + ("r" if index.rotate_data else "")
              + ("t" if index.train_thresholds else "")
          )
  
      elif isinstance(index, faiss.IndexScalarQuantizer):
          sqtypes = {
              faiss.ScalarQuantizer.QT_8bit: "8",
              faiss.ScalarQuantizer.QT_4bit: "4",
              faiss.ScalarQuantizer.QT_6bit: "6",
              faiss.ScalarQuantizer.QT_fp16: "fp16",
          }
          return f"SQ{sqtypes[index.sq.qtype]}"
  
      raise NotImplementedError()
  
imports: import faiss
  import re
label_desc: Use image node_id 3 for calling a global function with example usage: reverse_index_factory(index) and returns: str, unknown, unknown, unknown, unknown, prefix, str, reverse_index_factory, str, get_hnsw_M, reverse_index_factory, str, reverse_index_factory, str, str, index, str, index, str, str, index, str, index, unknown, str, sqtypes