Oh ok, I was little confused by # 15 because now I reduced my classes to 6, but I think I get this function now. I ran your code for the case when classes = 6, but I get the output as tensor([[1., 1., 1., 0., 1., 1.]]), however in my case 0 still means a class. Do I need to change it in a dictionary of my labels?
If I do, I will get then  ([[1., 1., 1., 1., 1., 1.]])
for labels = torch.tensor([2, 5, 2, 1, 6, 3])
and it will be true for all of my labels, since every each of them has 6 different values and thus they all will be activated.  Will the loss function be accurate in this case then?
My batch is size of 4, so according to your example I have my code as follows:
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(6, 16, 5)
        self.fc1 = nn.Linear(16 * 22 * 39, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 15)

    def forward(self, x):
        # my inputs have size of [170,100,3] so I am swapping dimensions here so it would comply model requirements
        x = x.view(-1, 3, 100, 170)
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(-1, 16 * 22 * 39)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x

net = Net()
net.to(device)

import torch.optim as optim

criterion = nn.BCEWithLogitsLoss()
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)

print(len(trainloader))
for epoch in range(4):  # loop over the dataset multiple times

    losses = []
    
    running_loss = 0.0
    for i, data in enumerate(trainloader, 0):
        # get the inputs
        inputs, labels = data
        labels = labels.unsqueeze(-1)
        targets = torch.zeros(labels.size(0),15).scatter_(1, labels, 1.)
        targets = targets.squeeze(0)
        targets = targets.float()
        inputs, targets = inputs.to(device), targets.to(device)

        # zero the parameter gradients
        optimizer.zero_grad()

        # forward + backward + optimize
        outputs = net(inputs)
        loss = criterion(outputs, targets)
        loss.backward()
        optimizer.step()

        losses.append(loss.data.cpu().numpy())
        print("Epoch {} Loss: {:.4f}".format(epoch, np.asscalar(np.mean(losses))))

print('Finished Training')


dataiter = iter(testloader)
images, labels = dataiter.next()



net.to(device)
images, labels = images.to(device), labels.to(device)
outputs = net(images)

with torch.no_grad():
    for data in testloader:
        images, labels = data
        images, labels = images.to(device), labels.to(device)
        y = net(images)
        print('Y (logits): {}'.format(y.data.cpu().numpy()))
        print('Y (argmax): {}'.format(y.data.cpu().numpy() > 0))

but the output that I am getting is :
Y (logits): [[-1.631788  -1.1816276 -2.5093026 -3.4875336 -2.4541166 -3.1875174
  -2.6211216 -3.6854322 -2.8854806 -3.81516   -3.0067604 -3.414101
  -3.5943007 -3.71672   -3.5693698]
 [-1.7025979 -1.2310716 -2.612976  -3.6319766 -2.5535479 -3.3250632
  -2.7306297 -3.8352551 -3.0070634 -3.9727454 -3.1343684 -3.5583117
  -3.7449632 -3.8727129 -3.7125916]
 [-1.6599652 -1.1989014 -2.5494416 -3.540475  -2.487864  -3.2383528
  -2.6703634 -3.7370138 -2.932359  -3.877006  -3.0570838 -3.470197
  -3.6498802 -3.7754254 -3.6216202]
 [-1.4784788 -1.0684851 -2.273665  -3.1516986 -2.2127426 -2.8756993
  -2.3788373 -3.3367095 -2.598027  -3.450463  -2.7082787 -3.08899
  -3.2494898 -3.3505046 -3.230426 ]]
Y (argmax): [[False False False False False False False False False False False False
  False False False]
 [False False False False False False False False False False False False
  False False False]
 [False False False False False False False False False False False False
  False False False]
 [False False False False False False False False False False False False
  False False False]]

even though my loss is on average 0.2213
so I am not sure what is wrong in this case… I feel like there are 3 possible reasons for that:

I don’t measure accuracy right
Something wrong with my training part( I implemented wrong my loss criterion)
Something wrong with my data ( imbalanced?)