Also, for BCELoss Backward When The Input is Zero, this function, I printed more values, when the total loss in below 1, I have same value with nn.BCELoss, but in values more than 1,  I have a lot of difference. For example, with these values:
x: tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0587, 0.0732,
         0.0820, 0.0792, 0.0668, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0587,
         0.0850, 0.1194, 0.1449, 0.1363, 0.1033, 0.0718, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0732, 0.1194, 0.2001, 0.2839, 0.2528, 0.1588, 0.0949, 0.0599,
         0.0000, 0.0000, 0.0000, 0.0820, 0.1449, 0.2839, 0.5244, 0.4029, 0.2074,
         0.1103, 0.0657, 0.0000, 0.0000, 0.0000, 0.0792, 0.1363, 0.2528, 0.4029,
         0.3431, 0.1903, 0.1052, 0.0639, 0.0000, 0.0000, 0.0000, 0.0668, 0.1033,
         0.1588, 0.2074, 0.1903, 0.1317, 0.0845, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0718, 0.0949, 0.1103, 0.1052, 0.0845, 0.0622, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0599, 0.0657, 0.0639, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000]], grad_fn=<ViewBackward>)


y: tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1667, 0.2857, 0.5000, 0.6667,
         0.5000, 0.2857, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1818, 0.3333,
         0.6667, 1.0000, 0.6667, 0.3333, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.1667, 0.2857, 0.5000, 0.6667, 0.5000, 0.2857, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.1333, 0.2000, 0.2857, 0.3333, 0.2857, 0.2000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1333, 0.1667, 0.1818, 0.1667,
         0.1333, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0000]])

The nn.BCELoss is 118.65484619140625, but with my function it is 424.10596. I do not know why in some places I get the right answer and somewhere not.
Can you help on this ? @ptrblck @albanD