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

def validation(test_loader,model):
#print(‘validation’)
tk = tqdm(test_loader, total=len(test_loader),position=0,leave=True)
outputs_ext,targets_ext = [],[]
model.eval()
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)
        #print('outputs->',outputs[0])
        #print('targets->',targets[0])
        for out in outputs:
            outputs_ext.extend(out.tolist())
        for tar in targets:
            targets_ext.extend(tar.detach().cpu())
        #oututs_ext = [i for i in np.array(outputs_ext)]
    targets_ext_np = np.array(targets_ext)
    outputs_ext_np = np.array(outputs_ext)
print('outputs_ext-->',outputs_ext_np.round())
print('targets_ext->',targets_ext_np)

return accuracy_score(outputs_ext_np.round(), targets_ext_np)