Here is the error and snippet of code when attempted batch size of 4:
running_loss = 0.0
for epoch in range(1):  # loop over the dataset multiple times
    
    if len(list(enumerate(trainloader, 0))) < 10:
            print('Batch size too small (<10) for PR-curve')
            
    for i, data in enumerate(trainloader, 0):
        
        # get the inputs; data is a list of [inputs, labels]
        inputs, labels = data

        # zero the parameter gradients
        optimizer.zero_grad()

        # forward + backward + optimize
        outputs = net(inputs)
        loss = criterion(outputs, labels)
        loss.backward()
        optimizer.step()

        running_loss += loss.item()
        if i % 10 == 9:    # every 1000 mini-batches...
#         if i % 1000 == 999:    # every 1000 mini-batches...

            # ...log the running loss
            writer.add_scalar('training loss',
                            running_loss / 1000,
                            epoch * len(trainloader) + i)

            # ...log a Matplotlib Figure showing the model's predictions on a
            # random mini-batch
            writer.add_figure('predictions vs. actuals',
                            plot_classes_preds(net, inputs, labels),
                            global_step=epoch * len(trainloader) + i)
            running_loss = 0.0
        
print('Finished Training')


0 index of predictions with length 4: 49254
1 index of predictions with length 4: 79865
2 index of predictions with length 4: 44043
3 index of predictions with length 4: 43242
IndexError                                Traceback (most recent call last)
 in 
31             # random mini-batch
32             writer.add_figure(‘predictions vs. actuals’,
—> 33                             plot_classes_preds(net, inputs, labels),
34                             global_step=epoch * len(trainloader) + i)
35             running_loss = 0.0
 in plot_classes_preds(net, images, labels)
31         matplotlib_imshow(images[idx], one_channel=True)
32         ax.set_title("{0}, {1:.1f}%\n(label: {2})".format(
—> 33             classes[preds[idx]],
34             probs[idx] * 100.0,
35             classes[labels[idx]]),
IndexError: list index out of range