def update_gradients(self, dL_dF, X):
        x = X.flatten()
        dL_dF = dL_dF.flatten()

        dL_db = np.zeros(self.sorted_breaks.size)
        dL_dv = np.zeros(self.sorted_values.size)

        #loop across each interval, computing the gradient for each of the 4 parameters that define it
        for i, (low, up, g, v) in enumerate(zip(self. sorted_breaks[:-1], self.sorted_breaks[1:], self.grads, self.sorted_values[:-1])):
            index = np.logical_and(x>low, x<up)
            xx = x[index]
            grad = dL_dF[index]
            span = up-low
            dL_dv[i] += np.sum(grad*( (low - xx)/span + 1))
            dL_dv[i+1] += np.sum(grad*(xx-low)/span)
            dL_db[i] += np.sum(grad*g*(xx-up)/span)
            dL_db[i+1] += np.sum(grad*g*(low-xx)/span)

        #now the end parts
        dL_db[0] -= np.sum(dL_dF[x<self.sorted_breaks[0]])
        dL_db[-1] -= np.sum(dL_dF[x>self.sorted_breaks[-1]])
        dL_dv[0] += np.sum(dL_dF[x<self.sorted_breaks[0]])
        dL_dv[-1] += np.sum(dL_dF[x>self.sorted_breaks[-1]])

        #now put the gradients back in the correct order!
        self.breaks.gradient = dL_db[self.reverse_order]
        self.values.gradient = dL_dv[self.reverse_order]
dataset/ETHPy150Open SheffieldML/GPy/GPy/mappings/piecewise_linear.py/PiecewiseLinear.update_gradients/original