code: def run_add(args, ds, index, res):
      print("adding")
      t0 = time.time()
      if args.add_bs == -1:
          assert args.split == [
              1,
              0,
          ], "split not supported with full batch add"
          index.add(sanitize(ds.get_database()))
      else:
          totn = ds.nb // args.split[0]  # approximate
          i0 = 0
          print(
              f"Adding in block sizes {args.add_bs} with split {args.split}"
          )
          for xblock in ds.database_iterator(
              bs=args.add_bs, split=args.split
          ):
              i1 = i0 + len(xblock)
              print(
                  "  adding %d:%d / %d [%.3f s, RSS %d kiB] "
                  % (
                      i0,
                      i1,
                      totn,
                      time.time() - t0,
                      faiss.get_mem_usage_kb(),
                  )
              )
              index.add(xblock)
              i0 = i1
  
      res.t_add = time.time() - t0
      print(f"  add in {res.t_add:.3f} s index size {index.ntotal}")
  
file_path: faiss/benchs/bench_all_ivf/bench_all_ivf.py
imports: import argparse
  import os
  import sys
  import time
  import json
  import faiss
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: run_add(args, ds, index, res) without return types