It’s because you should have separated the computations for each element of you batch!
Here, instead of:
loss_d_out = (loss_d_1 + loss_d_2) / 2
weight = weight_0 - l_rate * loss_d_out * in_mean
bias = bias_0 - l_rate * loss_d_out

it should rather be:
weight = weight_0 - l_rate * (loss_d_1 * in_1 + loss_d_2 * in_2) / 2
bias = bias_0 - l_rate * (loss_d_1 + loss_d_2) / 2

(Though it doesn’t change anything for the bias)