def _slice_pad_length(num_items, length, overlap=<NUM_LIT:0>):
if length <= overlap:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>step = length - overlap<EOL>span = num_items - length<EOL>residual = span % step<EOL>if residual:<EOL><INDENT>return step - residual<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>
Calculate the padding length needed for sliced samples in order not to discard data.

    Parameters
    ----------
    num_items : int
        Number of items in dataset before collating.
    length : int
        The length of each of the samples.
    overlap : int, default 0
        The extra number of items in current sample that should overlap with the
        next sample.

    Returns
    -------
    Length of paddings.