import warnings


def get_padding_up(Lin:int, Lout:int, kernel_size:int, stride=1, output_padding:int=0, dilation:int=1) -> int:
    """return padding length to math target Lout. (for up sampling)"""
    assert Lin <= Lout
    pad = ((Lin - 1)*stride + dilation*(kernel_size - 1) + output_padding+ 1 - Lout)/2
    if pad < 0:
        raise ValueError(f"padding size is invalid {pad}. Please check {Lin, Lout, kernel_size,stride,output_padding,dilation}")
    elif pad%1 > 0:
        warnings.warn(f"No exists pilitic padding :{pad}. Please check {Lin, Lout, kernel_size,stride,output_padding,dilation}", UserWarning)
    return int(pad)