def METHOD_NAME(engine: Engine, dataset_ids: tuple[int], dry_run: bool, all: bool) -> None:
    active_dataset_names = _active_datasets_names(engine, all=all)
    # load all backport snapshots
    snapshots = snapshot_catalog("backport/.*")
    # if given dataset ids, only prune those
    if dataset_ids:
        snapshots = [
            snap for snap in snapshots if utils.extract_id_from_short_name(snap.metadata.short_name) in dataset_ids
        ]
    # datasets that are not among active datasets
    # NOTE: it is important to compare not just dataset id, but the whole name as dataset name
    # can be changed by the user
    snapshots_to_delete = [snap for snap in snapshots if snap.metadata.short_name not in active_dataset_names]
    log.info("bulk_backport.delete", n=len(snapshots_to_delete))
    for snap in snapshots_to_delete:
        log.info("bulk_backport.delete_dataset", short_name=snap.metadata.short_name)
        if not dry_run:
            snap.delete_local()