Given $f\in C^2$ with compact support and $\tau$ be a stopping time with $E^x[\tau]<\infty$. Suppose $$Y_t=x+\int_0^t u(s,\omega)ds+\int_0^t v(s,\omega)dB_s(\omega), $$ with bounded $u,v$. Then by Ito formula with fixed $t$, I have
$$ f(Y_t)=f(Y_0)+\int_0^t (u\frac{\partial f}{\partial x}+\frac{1}{2}v^2\frac{\partial^2 f }{\partial^2 x})\,ds +\int_0^t v\frac{\partial f}{\partial x}\, dB_s, $$ My question is, how could I derive the following from the above identity that $$ E^x[f(Y_\tau)]=f(x)+E^x\bigg[\int_0^\tau (u\frac{\partial f}{\partial x}+\frac{1}{2}v^2\frac{\partial^2 f }{\partial^2 x})\,ds\bigg] +E^x\bigg[\int_0^\tau v\frac{\partial f}{\partial x}\, dB_s\bigg]. $$ In other words, how to change the deterministic $t$ into an integrable stopping time?