It’s just a guess, but it seems the error is coming from your batching.
Currently you are using a DataLoader with a batch_size of 128, i.e. in each iteration your DataLoader will provide a batch of 128 samples.
In this loop you are trying to apply your own batching using the batch number.
However, inputs and labels will only contain 128 samples, not the whole dataset.
After the first valid batch, you will get an empty slice, since start and end will be too large.
If you use a Dataset and DataLoader you don’t have to implement batching yourself. The DataLoader will take care of it (even using multiprocessing to speed up the loading). You just have to implement the logic to load a single sample in your Dataset.
Try to remove the batching code in your training procedure. Also, as a small side note, Variables are deprecated and since 0.4.0 you can use tensors directly.
The loop over the DataLoader corresponds to one epoch, so you should move the epoch up:
for epoch in range(num_epochs):
    for i, data in enumerate(train_loader):
      inputs, labels = data
      optimizer.zero_grad()
      ypred = net(inputs)
      ...

    if epoch%5 == 0:
      print(...)