def get_reduction_level(indsize, optlevel, slicesize, chunksize):
    """Compute the reduction level based on indsize and optlevel."""
    rlevels = [[8, 8, 8, 8, 4, 4, 4, 2, 2, 1], [4, 4, 4, 4, 2, 2, 2, 1, 1, 
        1], [2, 2, 2, 2, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
    isizes = {(1): 0, (2): 1, (4): 2, (8): 3}
    rlevel = rlevels[isizes[indsize]][optlevel]
    if rlevel >= slicesize:
        rlevel = 1
    if slicesize <= chunksize * rlevel:
        rlevel = 1
    if indsize == 8:
        assert rlevel == 1
    return rlevel
