code: def do_test_remove(self, index_type):
      k = 16
      quant = faiss.IndexFlatL2(d)
      index = self.make_index_for_merge(quant, index_type, None)
  
      # trains the quantizer
      index.train(xt)
  
      if index_type < 4:
          index.add(xb)
      else:
          gen = np.random.RandomState(1234)
          id_list = gen.permutation(nb * 7)[:nb].astype("int64")
          index.add_with_ids(xb, id_list)
  
      print("ref search ntotal=%d" % index.ntotal)
      Dref, Iref = index.search(xq, k)
  
      toremove = np.zeros(nq * k, dtype="int64")
      nr = 0
      for i in range(nq):
          for j in range(k):
              # remove all even results (it's ok if there are duplicates
              # in the list of ids)
              if Iref[i, j] % 2 == 0:
                  nr = nr + 1
                  toremove[nr] = Iref[i, j]
  
      print("nr=", nr)
  
      idsel = faiss.IDSelectorBatch(nr, faiss.swig_ptr(toremove))
  
      for i in range(nr):
          assert idsel.is_member(int(toremove[i]))
  
      nremoved = index.remove_ids(idsel)
  
      print("nremoved=%d ntotal=%d" % (nremoved, index.ntotal))
  
      D, I = index.search(xq, k)
  
      # make sure results are in the same order with even ones removed
      ndiff = 0
      for i in range(nq):
          j2 = 0
          for j in range(k):
              if Iref[i, j] % 2 != 0:
                  if I[i, j2] != Iref[i, j]:
                      ndiff += 1
                  assert abs(D[i, j2] - Dref[i, j]) < 1e-5
                  j2 += 1
      # draws are ordered arbitrarily
      assert ndiff < 5
  
imports: import unittest
  import faiss
  import numpy
  from faiss.contrib.datasets import SyntheticDataset
  from common_faiss_tests import Randu10k
label_desc: Use image node_id 4 for calling the TestMerge1 obj's underlying member method code with example usage: obj.do_test_remove(index_type) without return types