def _pull_out_unaffected_blocks_rhs(rest, rhs, out_port, in_port):
    """Similar to :func:`_pull_out_unaffected_blocks_lhs` but on the RHS of a
    series product self-feedback.
    """
    _, block_index = rhs.index_in_block(in_port)
    rest = tuple(rest)
    bs = rhs.block_structure
    (nbefore, nblock, nafter) = (sum(bs[:block_index]),
                                 bs[block_index],
                                 sum(bs[block_index + 1:]))
    before, block, after = rhs.get_blocks((nbefore, nblock, nafter))
    if before != cid(nbefore) or after != cid(nafter):
        outer_rhs = before + cid(nblock - 1) + after
        inner_rhs = cid(nbefore) + block + cid(nafter)
        return Feedback.create(SeriesProduct.create(*(rest + (inner_rhs,))),
                               out_port=out_port, in_port=in_port) << outer_rhs
    elif block == cid(nblock):
        outer_rhs = before + cid(nblock - 1) + after
        return Feedback.create(SeriesProduct.create(*rest),
                               out_port=out_port, in_port=in_port) << outer_rhs
    raise CannotSimplify()
Similar to :func:`_pull_out_unaffected_blocks_lhs` but on the RHS of a
    series product self-feedback.