Solved by ptrblck in post #4 
              
              
                Yes, you can pass a tensor in the shape [nb_classes] as the argument to pos_weight. 
In case you want to split the output in dim1, you could use output.split(1, dim=1).