All we’re doing here is doing an abuse of notation. You should say that dl/dyi * dyi/dx = dl/dx_i where the _i signifies that this only considers the contribution from y_i.
If we write things down: You have a function Y = f(X).
And we are given for every entry in Y, a gradient wrt a loss dl/dyi.
Now if you want to compute the gradient for a given entry in X, let’s say x0, you want dl/dx0. And to compute this, you use the chain rule to consider all the elements in Y that contribute to l which were made from x0. And so dl/dx0 = sum_i (dl/dyi * dyi/dx0) where i allows you to consider all the outputs one by one.