code: def test_overwrite_index():
      # Issue #335
      f = 40
  
      # Build the initial index
      t = AnnoyIndex(f, "angular")
      for i in range(1000):
          v = [random.gauss(0, 1) for z in range(f)]
          t.add_item(i, v)
      t.build(10)
      t.save("test.ann")
  
      # Load index file
      t2 = AnnoyIndex(f, "angular")
      t2.load("test.ann")
  
      # Overwrite index file
      t3 = AnnoyIndex(f, "angular")
      for i in range(500):
          v = [random.gauss(0, 1) for z in range(f)]
          t3.add_item(i, v)
      t3.build(10)
      if os.name == "nt":
          # Can't overwrite on Windows
          with pytest.raises(IOError):
              t3.save("test.ann")
      else:
          t3.save("test.ann")
          # Get nearest neighbors
          v = [random.gauss(0, 1) for z in range(f)]
          t2.get_nns_by_vector(v, 1000)
  
imports: import os
  import random
  import pytest
  from annoy import AnnoyIndex
label_desc: Use image node_id 17 for calling a global function with example usage: test_overwrite_index() without return types