def METHOD_NAME(  # noqa: PLR0913
    repo,
    targets=None,
    remote=None,
    all_branches=False,
    with_deps=False,
    all_tags=False,
    recursive=False,
    all_commits=False,
    revs=None,
    max_size=None,
    types=None,
    config=None,
    onerror=None,
):
    indexes = {}
    collection_exc = None
    config = config or {}
    if remote:
        core = config.get("core") or {}
        core["remote"] = remote
        config["core"] = core
    for rev in repo.brancher(
        revs=revs,
        all_branches=all_branches,
        all_tags=all_tags,
        all_commits=all_commits,
    ):
        try:
            repo.config.merge(config)
            idx = repo.index.targets_view(
                targets,
                with_deps=with_deps,
                recursive=recursive,
                max_size=max_size,
                types=types,
            )
            data = idx.data["repo"]
            data.onerror = _make_index_onerror(onerror, rev)
            indexes[idx.data_tree.hash_info.value] = data
        except Exception as exc:  # pylint: disable=broad-except
            if onerror:
                onerror(rev, None, exc)
            collection_exc = exc
            logger.exception("failed to collect '%s'", rev or "workspace")
    if not indexes and collection_exc:
        raise collection_exc
    return indexes