import math


def get_inv_unit(block_index,diff):
    """
    given a block index and a 0-indexed layer in that block, returns a unit index. 
    """
    bottleneck_block_mapping = {1:0,
                                2:3,
                                3:7,
                                4:13}
    return bottleneck_block_mapping[block_index] + math.floor((abs(diff-1)/3))