I'm trying to define custom loss function for Caffe using Python layer but I can't clarify what is a required output.
Let's a function for the layer is defined as L = sum(F(xi, yi))/batch\_size, where L is loss function to be minimized (i.e. top[0]), x is a network output (bottom[0]), y is ground truth label (i.e. bottom[1]) and xi,yi are i-th samples in a batch.

Widely known example with EuclideanLossLayer (<https://github.com/BVLC/caffe/blob/master/examples/pycaffe/layers/pyloss.py>) shows that backward level in this case must return `bottom[0].diff[i] = dL(x,y)/dxi`. Another reference I've found shows the same: [Implement Bhattacharyya loss function using python layer Caffe](https://stackoverflow.com/questions/39977133/implement-bhattacharyya-loss-function-using-python-layer-caffe)

But in other examples I have seen that it should be multiplied by top[0].diff.
1. What is correct? bottom[0][i] = dL/dx or bottom[0].diff[i] = dL/dxi\*top[0].diff[i]