def bulk_write(ops, coll, ordered=False, batcher=None, progress=False):
    """Performs a batch of write operations on a collection.

    Args:
        ops: a list of pymongo operations
        coll: a pymongo collection
        ordered (False): whether the operations must be performed in order
        batcher (None): an optional :class:`fiftyone.core.utils.Batcher` class
            to use to batch the operations, or ``False`` to strictly perform
            the operations in a single batch. By default,
            ``fiftyone.config.default_batcher`` is used
        progress (False): whether to render a progress bar (True/False), use
            the default value ``fiftyone.config.show_progress_bars`` (None), or
            a progress callback function to invoke instead

    Returns:
        A list of :class:`pymongo.results.BulkWriteResult` objects
    """
    batcher = fou.get_default_batcher(ops, batcher=batcher, progress=progress)
    results = []

    try:
        with batcher:
            for batch in batcher:
                batch = list(batch)
                res = coll.bulk_write(batch, ordered=ordered)
                if res.bulk_api_result.get("nBytes") and hasattr(
                    batcher, "set_encoding_ratio"
                ):
                    batcher.set_encoding_ratio(
                        res.bulk_api_result.get("nBytes")
                    )
                results.append(res)

    except BulkWriteError as bwe:
        msg = bwe.details["writeErrors"][0]["errmsg"]
        raise ValueError(msg) from bwe
    return results
Performs a batch of write operations on a collection.

    Args:
        ops: a list of pymongo operations
        coll: a pymongo collection
        ordered (False): whether the operations must be performed in order
        batcher (None): an optional :class:`fiftyone.core.utils.Batcher` class
            to use to batch the operations, or ``False`` to strictly perform
            the operations in a single batch. By default,
            ``fiftyone.config.default_batcher`` is used
        progress (False): whether to render a progress bar (True/False), use
            the default value ``fiftyone.config.show_progress_bars`` (None), or
            a progress callback function to invoke instead

    Returns:
        A list of :class:`pymongo.results.BulkWriteResult` objects
    
fiftyone/core/odm/database.py