def batch_load_docs(db, doc_iterator, on_duplicate="<STR_LIT:replace>"):
batch_size = <NUM_LIT:100><EOL>counter = <NUM_LIT:0><EOL>collections = {}<EOL>docs = {}<EOL>if on_duplicate not in ["<STR_LIT:error>", "<STR_LIT>", "<STR_LIT:replace>", "<STR_LIT:ignore>"]:<EOL><INDENT>log.error(f"<STR_LIT>")<EOL>return<EOL><DEDENT>for (collection_name, doc) in doc_iterator:<EOL><INDENT>if collection_name not in collections:<EOL><INDENT>collections[collection_name] = db.collection(collection_name)<EOL>docs[collection_name] = []<EOL><DEDENT>counter += <NUM_LIT:1><EOL>docs[collection_name].append(doc)<EOL>if counter % batch_size == <NUM_LIT:0>:<EOL><INDENT>log.info(f"<STR_LIT>")<EOL>for cname in docs:<EOL><INDENT>collections[cname].import_bulk(<EOL>docs[cname], on_duplicate=on_duplicate, halt_on_error=False<EOL>)<EOL>docs[cname] = []<EOL><DEDENT><DEDENT><DEDENT>log.info(f"<STR_LIT>")<EOL>for cname in docs:<EOL><INDENT>collections[cname].import_bulk(<EOL>docs[cname], on_duplicate=on_duplicate, halt_on_error=False<EOL>)<EOL>docs[cname] = []<EOL><DEDENT>
Batch load documents

    Args:
        db: ArangoDB client database handle
        doc_iterator:  function that yields (collection_name, doc_key, doc)
        on_duplicate: defaults to replace, but can be error, update, replace or ignore

        https://python-driver-for-arangodb.readthedocs.io/en/master/specs.html?highlight=import_bulk#arango.collection.StandardCollection.import_bulk