If I do exactly what you suggested,
class Classifier(nn.Module):
    
    def __init__(self, n_class, batch_size):
        super(Classifier, self).__init__()
        self.batch_size = batch_size
        self.transformer = VisionTransformer()
        #self.criterion = nn.CrossEntropyLoss(reduce=False)
        self.criterion = nn.BCELoss(reduce=False)
        #self.criterion = nn.BCEWithLogitsLoss(reduce=False)



    def forward(self, X, labels):

        stacked_X = torch.stack(X)
        out = self.transformer(stacked_X)
       
        with torch.autocast('cuda'):
            # https://discuss.pytorch.org/t/unclear-about-weighted-bce-loss/21486/2 
            labels = torch.tensor(labels)
            weight = torch.tensor([0.1, 0.9]) # how to decide on this weights?
            weight_ = weight[labels.data.view(-1).long()].view_as(labels)
            m = nn.Sigmoid()
            print('sig: ', m(out[:,1]-out[:,0]))
            #loss = self.criterion(torch.cuda.LongTensor(m(out[:,1]-out[:,0])), torch.tensor(labels).cuda())
            loss = self.criterion(m(out[:,1]-out[:,0]), torch.tensor(labels).cuda())

            print('loss: ', loss)
            print('weight_: ', weight_)
            loss_class_weighted = loss * weight_.cuda()
            loss_class_weighted = loss_class_weighted.mean()
       
       
        #pred = out.data.max(1)[1]
        
        pred_labels = out.argmax(dim=1)
        
        return pred_labels, labels, loss_class_weighted

I get the following error:
x is:  tensor([[ 0.9785,  0.2433],
        [ 0.9771, -0.0478],
        [ 0.7964, -0.0357],
        [ 0.8349, -0.0047],
        [ 1.0577, -0.3201],
        [ 1.1935,  0.0038],
        [ 0.9705, -0.4818],
        [ 1.0076,  0.3583],
        [ 0.8457, -0.2120],
        [ 0.8271,  0.4590],
        [ 0.8754,  0.0792],
        [ 0.7807,  0.3120],
        [ 0.5872,  0.1169],
        [ 1.1021,  0.2229],
        [ 0.7981,  0.0122],
        [ 0.9969,  0.5169]], device='cuda:0', grad_fn=<AddmmBackward0>)
sig:  tensor([0.3240, 0.2641, 0.3032, 0.3016, 0.2014, 0.2333, 0.1897, 0.3432, 0.2578,
        0.4090, 0.3108, 0.3849, 0.3845, 0.2933, 0.3131, 0.3823],
       device='cuda:0', grad_fn=<SigmoidBackward0>)
 UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  loss = self.criterion(m(out[:,1]-out[:,0]), torch.tensor(labels).cuda())
Traceback (most recent call last):
  File "main_classifier.py", line 250, in <module>
    pred,label,loss = trainer.train(sample_batched, model)

    pred, labels, loss = model.forward(feats, labels)
  File "/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
 
    loss = self.criterion(m(out[:,1]-out[:,0]), torch.tensor(labels).cuda())
  File "/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 603, in forward
    return F.binary_cross_entropy(input, target, weight=self.weight, reduction=self.reduction)
  File "/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/functional.py", line 2915, in binary_cross_entropy
    return torch._C._nn.binary_cross_entropy(input, target, weight, reduction_enum)
RuntimeError: torch.nn.functional.binary_cross_entropy and torch.nn.BCELoss are unsafe to autocast.
Many models use a sigmoid layer right before the binary cross entropy layer.
In this case, combine the two layers using torch.nn.functional.binary_cross_entropy_with_logits
or torch.nn.BCEWithLogitsLoss.  binary_cross_entropy_with_logits and BCEWithLogits are
safe to autocast.