How to solve this error?

kindly anyone help me how to solve this problem.i have try many solutions but no one works…

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

for i in range(4):
            label = labels[i]
            class_correct[label] += c[i].item()
            class_total[label] += 1

Hi, could you provide more details about your class_correct, and how is c defined

here is my code.

class_correct = list(0. for i in range(3))
class_total = list(0. for i in range(3))
with torch.no_grad():
    for data in testloader:
        images, labels = data
        images = Variable(images)
        labels = Variable(labels)
        outputs = model(images)
        _, predicted = torch.max(outputs, 1)
        c = (predicted == labels).squeeze()
        for i in range(10):
            label = labels[i]
            class_correct[label] += c[i].item()
            class_total[label] += 1
            #print('Accuracy of %5s : %2f %%' % (classes[i], 100 * class_correct[i] / class_total[i]))


# =============================================================================
# for i in range(10):  
#     print('Accuracy of %5s : %2f %%' % (
#         classes[i], 100 * class_correct[i] / class_total[i]))

check the batch size of testdata loader?
testloader = torch.utils.data.DataLoader(dataset=testset,
batch_size=4,
shuffle=False)
in case you set it in batch_size=1