code: def _slice_pad_length(num_items, length, overlap=0):
      
      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
docs: 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.