def _dim_compressor(dims, inds):
    """Helper function for ``dim_compress`` that does the heavy lifting.

    Parameters
    ----------
    dims : sequence of int
        The subsystem dimensions.
    inds : sequence of int
        The indices of the 'marked' subsystems.

    Returns
    -------
    generator of (int, int)
        Sequence of pairs of new dimension subsystem with marked flag {0, 1}.
    """
    blocksize_id = blocksize_op = 1
    autoplace_count = 0
    for i, dim in enumerate(dims):
        if dim < 0:
            if blocksize_op > 1:
                yield blocksize_op, 1
                blocksize_op = 1
            elif blocksize_id > 1:
                yield blocksize_id, 0
                blocksize_id = 1
            autoplace_count += dim
        elif i in inds:
            if blocksize_id > 1:
                yield blocksize_id, 0
                blocksize_id = 1
            elif autoplace_count < 0:
                yield autoplace_count, 1
                autoplace_count = 0
            blocksize_op *= dim
        else:
            if blocksize_op > 1:
                yield blocksize_op, 1
                blocksize_op = 1
            elif autoplace_count < 0:
                yield autoplace_count, 1
                autoplace_count = 0
            blocksize_id *= dim
    yield (blocksize_op, 1) if blocksize_op > 1 else (blocksize_id, 0
        ) if blocksize_id > 1 else (autoplace_count, 1)
