<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _slice_pad_length(num_items, length, overlap=0):
 """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. """

    if length <= overlap:
        raise ValueError('length needs to be larger than overlap')

    step = length - overlap
    span = num_items - length
    residual = span % step
    if residual:
        return step - residual
    else:
        return 0