def METHOD_NAME(fi, fid, rfi):
    """Remove indices."""
    if not rfi:
        return fi, fid
    rfip = sorted((r, p) for p, r in enumerate(rfi))
    nrfi = len(rfi)
    nfi = len(fi)
    shape = [None] * nrfi
    k = 0
    pos = 0
    newfiid = []
    while pos < nfi:
        rk = rfip[k][0]
        # Keep
        while fi[pos] < rk:
            newfiid.append((fi[pos], fid[pos]))
            pos += 1
        # Skip
        removed = 0
        while pos < nfi and fi[pos] == rk:
            shape[rfip[k][1]] = fid[pos]
            pos += 1
            removed += 1
        # Expecting to find each index from rfi in fi
        if not removed:
            raise ValueError(f"Index to be removed ({rk}) not part of indices ({fi}).")
        # Next to remove
        k += 1
        if k == nrfi:
            # No more to remove, keep the rest
            if pos < nfi:
                newfiid.extend(zip(fi[pos:], fid[pos:]))
            break
    assert None not in shape
    # Unpack into two tuples
    fi, fid = zip(*newfiid) if newfiid else ((), ())
    return fi, fid, tuple(shape)