def _get_pad_size(in_size, dilated_kernel_size, stride_size):
    """Calculate the paddings size for Conv/Pool in SAME padding mode."""

    if stride_size == 1 or in_size % stride_size == 0:
        pad = max(dilated_kernel_size - stride_size, 0)
    else:
        pad = max(dilated_kernel_size - (in_size % stride_size), 0)

    pad_before = pad // 2
    pad_after = pad - pad_before

    return [pad_before, pad_after]