code: def get_populated_index(preproc):
      if not index_cachefile or not os.path.exists(index_cachefile):
          if not altadd:
              gpu_index, indexall = compute_populated_index(preproc)
          else:
              gpu_index, indexall = compute_populated_index_2(preproc)
          if index_cachefile:
              print("store", index_cachefile)
              faiss.write_index(indexall, index_cachefile)
      else:
          print("load", index_cachefile)
          indexall = faiss.read_index(index_cachefile)
          gpu_index = None
  
      co = faiss.GpuMultipleClonerOptions()
      co.useFloat16 = use_float16
      co.useFloat16CoarseQuantizer = False
      co.usePrecomputed = use_precomputed_tables
      co.indicesOptions = 0
      co.verbose = True
      co.shard = True  # the replicas will be made "manually"
      t0 = time.time()
      print(
          "CPU index contains %d vectors, move to GPU" % indexall.ntotal
      )
      if replicas == 1:
          if not gpu_index:
              print("copying loaded index to GPUs")
              vres, vdev = make_vres_vdev()
              index = faiss.index_cpu_to_gpu_multiple(
                  vres, vdev, indexall, co
              )
          else:
              index = gpu_index
  
      else:
          del gpu_index  # We override the GPU index
  
          print("Copy CPU index to %d sharded GPU indexes" % replicas)
  
          index = faiss.IndexReplicas()
  
          for i in range(replicas):
              gpu0 = ngpu * i / replicas
              gpu1 = ngpu * (i + 1) / replicas
              vres, vdev = make_vres_vdev(gpu0, gpu1)
  
              print("   dispatch to GPUs %d:%d" % (gpu0, gpu1))
  
              index1 = faiss.index_cpu_to_gpu_multiple(
                  vres, vdev, indexall, co
              )
              index1.this.disown()
              index.addIndex(index1)
          index.own_fields = True
      del indexall
      print("move to GPU done in %.3f s" % (time.time() - t0))
      return index
  
imports: from __future__ import print_function
  import numpy
  import time
  import os
  import sys
  import faiss
  import re
  from multiprocessing.pool import ThreadPool
  from datasets import ivecs_read
label_desc: Use image node_id 17 for calling a global function with example usage: get_populated_index(preproc) and returns: index