If it’s a multi-label classification, there are modules you need to use. But if you are new, I prefer to give you directly an overview of what could be a good code for your problem (you have to google the modules I import for further understanding) : this code is just an illustration.
I include here the reviews of @user_123454321
import torch
#from sklearn.preprocessing import LabelBinarizer
from sklearn.preprocessing import MultiLabelBinarizer

num_classes = 18 # I hope
class_names = list(range(num_classes)) 
label_binarizer = MultiLabelBinarizer(classes=class_names)

target_list = []
outputs_list = []
loss_list = []

for i, data in loop:
    inputs, target = data['image'].float().to(device),  data['label'].float().to(device)
    #...
    # your code
    #...
    outputs = model(inputs).to(device)
    #...
    #your code
    # ...

    target_list.append(target.cpu())
    y_pred = outputs.round().int() # = (outputs >= 0.5).int()
    outputs_list.append(y_pred.detach().cpu())
    loss_list.append(loss.item())

mean_loss = sum(loss_list)/len(loss_list)
y_pred = torch.cat(outputs_list, dim=0).numpy() # shape : n_samples * n_classes
y_pred = label_binarizer.fit_transform(y_pred) # [[1, 0, ..., ], [....]]

# Here it's up to you to make sure the target is in the right format : [[1, 0, ..., ], [....]]
y_true = torch.cat(target_list, dim=0).numpy()
y_true = label_binarizer.fit_transform(y_true) 

You can use your sklearn metrics now, but I recommend the pytorch_lightning ones:
from pytorch_lightning.metrics import IoU, AUROC, F1, Accuracy, AveragePrecision
from pytorch_lightning.metrics import HammingDistance # problem for some versions : cannot import name 'HammingDistance' from 'pytorch_lightning.metrics'

val_metrics = {
    'hamming_dist': HammingDistance(), 
    'iou': IoU(num_classes=num_classes),
    'auroc': AUROC(num_classes=num_classes), 
    'f1': F1(num_classes=num_classes, multilabel=True), 
    'avg_precision': AveragePrecision(num_classes=num_classes),
    'accuracy' : Accuracy(top_k=1),
}


result = {}
y_pred = torch.from_numpy(y_pred)
y_true = torch.from_numpy(y_true)
for key in val_metrics :
	result[k] = val_metrics[k](y_pred, y_true)
	val_metrics[k].reset()