How to calculate the multilabel accuracy?

Here I try to calculate the multilabel accuracy
is there any part is not correct?

def validation(test_loader,model):
tk = tqdm(test_loader, total=len(test_loader),position=0,leave=True)
outputs_ext,targets_ext = [],[]
with torch.no_grad():
for i, (images,targets) in enumerate(tk):
device = torch.device(‘cuda’ if torch.cuda.is_available() else ‘cpu’)
images, targets = images.cuda(),targets.cuda()
outputs = model(images)
loss = criterion(outputs,targets)

        for out in outputs:
        for tar in targets:
        #oututs_ext = [i for i in np.array(outputs_ext)]
    targets_ext_np = np.array(targets_ext)
    outputs_ext_np = np.array(outputs_ext)

return accuracy_score(outputs_ext_np.round(), targets_ext_np)

I don’t know what kind of outputs your model provides, i.e. if they are logits, probabilities, class predictions etc., but outputs_ext_np.round() looks a bit unusual, so I would recommend to double check that it’s indeed working as expected.