deriving the gradient of batch normalization
Your derivative computation is correct, so I think your understanding of what BN does is slightly off. If you want a more thorough proof that your computation graph is correct, you can backpropagate from $\bar{x} = x-\mu$ using the partial derivatives with respect to each input in the batch, i.e. $\frac{\partial\bar{x}_i}{\partial x_j}$ from $\bar{x}_i = x_i - \mu$. There are two cases to calculate: when $i=j$:

$$
\frac{\partial\bar{x}_i}{\partial x_i} = \frac{\partial x_i}{\partial x_i} - \frac{\partial\mu}{\partial x_i} = 1 - \frac{1}{B}
$$

And when $i \neq j$:

$$
\frac{\partial\bar{x}_i}{\partial x_j} = \frac{\partial x_i}{\partial x_j} - \frac{\partial\mu}{\partial x_j} = -\frac{1}{B}
$$

of which there are $B-1$ cases. Therefore:

$$\begin{align}
\frac{\partial\bar{x}}{\partial x} &amp;= \sum_i^B \sum_j^B \frac{\partial\bar{x}_i}{\partial x_j} \\
 &amp;= \sum_i^B 1 - \frac{1}{B} - \frac{B-1}{B} \\
 &amp;= \sum_i^B 0 \\
\frac{\partial\bar{x}}{\partial x} &amp;= 0
\end{align}$$

Note also that $\frac{\partial\mu}{x}=1$, as you also correctly pointed out. What this means is that $\frac{\partial\text{BN}}{\partial x}$ is entirely dependent on the demeaned inputs ($\bar{x}=x-\mu$) and not the original inputs themselves; more importantly, backpropagation through a BN layer is invariant to the scale of the inputs. This directly results in some of the observed benefits of using BN, such as a smaller dependence on the initialization scheme and easier/faster training.