def METHOD_NAME(layers, stacks, kernel_size, dilation=lambda x: 2**x):
    assert layers % stacks == 0
    layers_per_cycle = layers // stacks
    dilations = [dilation(i % layers_per_cycle) for i in range(layers)]
    return (kernel_size - 1) * sum(dilations) + 1