Wrap x and y in a DataLoader with shuffle=False and batch_size, then
return the list of (feature_batch, label_batch) pairs it yields.
With shuffling off the order is the dataset's own, and the final batch is whatever is left over -- it is not padded or dropped unless you ask for that.
Input
x =
tensor([[0., 1.],
[2., 3.],
[4., 5.],
[6., 7.],
[8., 9.]])
y = tensor([0, 1, 2, 3, 4])
batch_size = 2
Output
[(tensor([[0., 1.],
[2., 3.]]), tensor([0, 1])), (tensor([[4., 5.],
[6., 7.]]), tensor([2, 3])), (tensor([[8., 9.]]), tensor([4]))]