code: def do_write_callback(self, bsz):
      d, n = 32, 1000
      x = np.random.uniform(size=(n, d)).astype("float32")
      index = faiss.IndexFlatL2(d)
      index.add(x)
  
      f = io.BytesIO()
      # test with small block size
      writer = faiss.PyCallbackIOWriter(f.write, 1234)
  
      if bsz > 0:
          writer = faiss.BufferedIOWriter(writer, bsz)
  
      faiss.write_index(index, writer)
      del writer  # make sure all writes committed
  
      if sys.version_info[0] < 3:
          buf = f.getvalue()
      else:
          buf = f.getbuffer()
  
      index2 = faiss.deserialize_index(
          np.frombuffer(buf, dtype="uint8")
      )
  
      self.assertEqual(index.d, index2.d)
      np.testing.assert_array_equal(
          faiss.vector_to_array(index.codes),
          faiss.vector_to_array(index2.codes),
      )
  
      # This is not a callable function: should raise an exception
      writer = faiss.PyCallbackIOWriter("blabla")
      self.assertRaises(Exception, faiss.write_index, index, writer)
  
imports: import numpy
  import unittest
  import faiss
  import tempfile
  import os
  import io
  import sys
  import pickle
  from multiprocessing.pool import ThreadPool
label_desc: Use image node_id 1 for calling the TestCallbacks obj's underlying member method code with example usage: obj.do_write_callback(bsz) without return types