Yeah, it worked, but can you please explain this, like what is nb_samples and this -
conf_matrix = torch.zeros(nb_classes, nb_classes)
for t, p in zip(target, pred):
    conf_matrix[t, p] += 1

print('Confusion matrix\n', conf_matrix)

TP = conf_matrix.diag()
for c in range(nb_classes):
    idx = torch.ones(nb_classes).byte()
    idx[c] = 0
    # all non-class samples classified as non-class
    TN = conf_matrix[idx.nonzero()[:, None], idx.nonzero()].sum() #conf_matrix[idx[:, None], idx].sum() - conf_matrix[idx, c].sum()
    # all non-class samples classified as class
    FP = conf_matrix[idx, c].sum()
    # all class samples not classified as class
    FN = conf_matrix[c, idx].sum()