Solved by KFrank in post #2 
              
              
                Hi Jhp! 

Not really. 

KLDivLoss doesn’t care what any of the dimesions – including 
the batch dimension – are.  It simply performs an element-wise 
computation and takes the mean (but see its documentation for 
how its reduction = 'batchmean' and deprecated reduce  and 
size_average constructor ar…