code: def _slice(index, n_samples, margin=None):
      
      if margin is None:
          margin = (0, 0)
      assert isinstance(n_samples, (tuple, list))
      assert len(n_samples) == 2
      before, after = n_samples
      assert isinstance(margin, (tuple, list))
      assert len(margin) == 2
      margin_before, margin_after = margin
      before += margin_before
      after += margin_after
      index = int(index)
      before = int(before)
      after = int(after)
      return slice(max(0, index - before), index + after, None)
docs: Return a waveform slice.