This should be a relatively simple question. I'm trying to confirm my understanding of the subscript notation on expectations when the subscript denotes a conditioning. In the example $$E_{Y|X}[(Y-f(X))^2|X]$$ the subscript denotes the distribution over which you take the expectation, so we would want to use $p_{Y|X}(y|X)=P(Y=y|X)$ as the distribution in our expectation and sum over the density of $y$. And the argument $$[(Y-f(X))^2|X]$$ means that when we take the expectation we should consider the value of $X$ in $(Y-f(X))^2$ to be given. This would imply that the statement can be rewritten: $$ E_{Y|X}[(Y-f(X))^2|X]=\int_{-\infty}^{\infty} [y-f(X)]^2 p_{Y|X}(y|X) dy. $$ And if I wanted to find $E_{X}E_{Y|X}[(Y-f(X))^2|X]$ I could rewrite that as: $$ E_{X}E_{Y|X}[(Y-f(X))^2|X]=\int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} [y-f(X)]^2 p_{Y|X}(y|X) dy]) \right) p_{X}(x)dx. $$ Is this all correct?
Correction Updated last line to fix an error that was caught in the comments: $$ E_{X}E_{Y|X}[(Y-f(X))^2|X]=\int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} [y-f(x)]^2 p_{Y|X}(y|x) dy]) \right) p_{X}(x)dx. $$