def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int:
    """
    Calculate symmetric padding for a convolution
    Args:
        kernel_size(`Int`):
            Convolution kernel size.
        stride(`Int`):
            Convolution stride parameter.
        dilation(`Int`):
            Convolution dilation parameter.
    Returns:
        (`Int`)
            Padding size to keep.
    """
    padding = ((stride - 1) + dilation * (kernel_size - 1)) // 2
    return padding
Calculate symmetric padding for a convolution
Args:
kernel_size(`Int`):
Convolution kernel size.
stride(`Int`):
Convolution stride parameter.
dilation(`Int`):
Convolution dilation parameter.
Returns:
(`Int`)
Padding size to keep.
towhee/models/layers/padding_functions.py