# Confused with backprop in pytorch with BCE loss

I've a prediction matrix(P) of dimension 3x3 and one-hot encoded label matrix(L) of dimension 3x3 as shown below.

    |0.5 0.3 0.1|      |1 0 0|
P = |0.3 0.2 0.1|  L = |0 1 0|
|0.2 0.5 0.8|      |0 0 1|


each column in 'P' corresponds to prediction of a label in 'L'

1. How is the BCELoss calculated using pytorch?, my experimentation by giving these two matrices as parameters to loss function yielded me poor results and pytorch's loss calculation function doesn't disclose on how loss calculation is done for this case.

2. How is the loss averaged for each instance and across the a batch?

3. if loss is calculated column wise and averaged for each instance and across the batch, then how can loss be backprop'd in pytorch?