Change of variables example in an ODE I do not understand how this was obtained

Why the $(y')^2$ becomes $y'$ and the $y'$ becomes $(y')^2$ and why $y^2$ becomes $x^2 (y')^3$ in the new ode?
How does $\frac{d y(x)}{d x}$ change under this change of variables?

IMO Leibniz's notation is a bit easier to follow.
$$\frac{d^2y}{dx^2} - \frac1y \left(\frac{dy}{dx}\right)^2 + \sin(x) y \frac{dy}{dx} + \cos(x) y^2 = 0$$
By the chain rule,
$$\frac{dy}{dx} = \frac1{\frac{dx}{dy}} \implies \frac{d^2y}{dx^2} = -\frac1{\left(\frac{dx}{dy}\right)^2} \frac{d\frac{dx}{dy}}{dx} = -\frac1{\left(\frac{dx}{dy}\right)^2} \frac{d^2x}{dy^2} \frac{dy}{dx} = -\frac1{\left(\frac{dx}{dy}\right)^3} \frac{d^2x}{dy^2}$$
The ODE transforms to
$$-\frac1{\left(\frac{dx}{dy}\right)^3} \frac{d^2x}{dy^2} - \frac1y \left(\frac1{\frac{dx}{dy}}\right)^2 + \sin(x) y \left(\frac1{\frac{dx}{dy}}\right) + \cos(x) y^2 = 0,$$
simplifies to
$$- \frac{d^2x}{dy^2} - \frac1y \frac{dx}{dy} + \sin(x) y \left(\frac{dx}{dy}\right)^2 + \cos(x) y^2 \left(\frac{dx}{dy}\right)^3 = 0,$$
and with the last variable change, we end up with
$$-\frac{d^2y}{dx^2} - \frac1x \frac{dy}{dx} + x \sin(y) \left(\frac{dy}{dx}\right)^2 + x^2 \cos(y) \left(\frac{dy}{dx}\right)^3 = 0$$
Multiply by $-1$ and swap out $\frac{dy}{dx}$ for $y'$ to get the exact same ODE.
