code: def test_redo_cosine(self):
      # test redo with cosine distance (inner prod, so objectives are reversed)
      d = 64
      n = 1000
  
      rs = np.random.RandomState(123)
      x = rs.uniform(size=(n, d)).astype("float32")
      faiss.normalize_L2(x)
  
      # make sure that doing 10 redos yields a better objective than just 1
      # for cosine distance, it is IP so higher is better
  
      clus = faiss.Clustering(d, 20)
      clus.nredo = 1
      clus.train(x, faiss.IndexFlatIP(d))
      obj1 = clus.iteration_stats.at(
          clus.iteration_stats.size() - 1
      ).obj
  
      clus = faiss.Clustering(d, 20)
      clus.nredo = 10
      clus.train(x, faiss.IndexFlatIP(d))
      obj10 = clus.iteration_stats.at(
          clus.iteration_stats.size() - 1
      ).obj
  
      self.assertGreater(obj10, obj1)
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import faiss
  import unittest
  import array
  from common_faiss_tests import get_dataset_2
label_desc: Use image node_id 2 for calling the TestCompositeClustering obj's underlying member method code with example usage: obj.test_redo_cosine() without return types