db(t)\\
u(x,T)=h(x,m)+\displaystyle\int_{\mathbb{R}^{n}}\dfrac{\partial h(\xi,m)}{\partial m}(x)m(\xi)d\xi.
\end{array}
\right.\\
\\
\left\{
\begin{array}{l}
\partial_{t}m+(\mathcal{A}^{*}m-\dfrac{1}{2}\beta^{2}\Delta m+\text{div}(G(x,m,Du)m))dt+\beta Dmdb(t)=0\\
m(x,0)=m_{0}(x).\\
\end{array}
\right.
\end{array}$$

Since the equation for $u$ is a backward stochastic partial differential equation (BSPDE), the solution is expressed by the pair $(u(x,t),B(x,t))$ which is adapted to the filtration $\mathcal{B}^{t}$.

OBTAINING THE SYSTEM OF STOCHASTIC HJB-FP EQUATIONS BY CALCULUS OF VARIATIONS
-----------------------------------------------------------------------------

In this section, we are going to check that the system (\[eq:3.7-1\]) can be also obtained by calculus of variations techniques, without referring to the Master equation. This is similar to approach in the deterministic case, see [@BFY]. We go back to the formulation (\[eq:3.2-1\]), (\[eq:3.3\]) . Let $\hat{v}(x,t)$ be an optimal feedback (it is a random field adapted to $\mathcal{B}^{t}$). We denote $m(x,t)=m_{\hat{v}(\cdot)}(x,t)$, which is therefore the solution of $$\left\{
\begin{array}{l}
\partial_{t}m+(\mathcal{A}^{*}m-\dfrac{1}{2}\beta^{2}\Delta m+\text{div}(g(x,m(t),\hat{v}(x,t))m))dt+\beta Dmdb(t)=0,\label{eq:3.4-1}\\
m(x,0)=m_{0}(x).
\end{array}
\right.$$

We can compute its Gâteaux differential $$\tilde{m}(x,t)=\dfrac{d}{d\theta}m_{\hat{v}(\cdot)+\theta v(\cdot)}(x,t)|_{\theta=0},$$ which satisfies $$\label{eq:3.4-2}
\left\{
\begin{array}{l}
    \partial_{t}\tilde{m}+(\mathcal{A}^{*}\tilde{m}-\dfrac{1}{2}\beta^{2}\Delta\tilde{m}+\text{div}(g(x,m(t),\hat{v}(x,t))\tilde{m}))dt+\beta D\tilde{m}db(t)\\
    \qquad+\text{div}\:\left(\Big[\displaystyle\int_{\mathbb{R}^{n}}\dfrac{\partial g(x,m,\hat{v}(x))}{\partial m}(\xi)\tilde{m}(\xi)d\xi+\dfrac{\partial g}{\partial v}(x,m,\hat{v}(x))v(x)\Big]m(x)\right)dt=0\\
    \tilde{m}(x,0)=0\\
\end{array}
\right.$$

We next compute the Gâteaux differential of the cost functional $$\begin{array}{rl}
    &\dfrac{d}{d\theta}J(\hat{v}(\cdot)+\theta v(\cdot))|_{\theta=0}\\
    =& \mathbb{E} \bigg[\displaystyle\int_{0}^{T}\int_{\mathbb{R}^{n}}f(x,m(t),\hat{v}(x,t))\tilde{m}(x,t)dxdt+\int_{0}^{T}\int_{\mathbb{R}^{n}}\frac{\partial f}{\partial v}(x,m(t),\hat{v}(x,t))v(x)m(x)dxdt\\    
    &\qquad+\displaystyle\int_{0}^{T}\int_{\mathbb{R}^{n}}\int_{\mathbb{R}^{n}}\frac{\partial f}{\partial m}(x,m(t),\hat{v}(x,t))(\xi)\tilde{m}(\xi,t)m(x,t)dxd\xi dt\\
    &\qquad+\displaystyle\int_{\mathbb{R}^{n}}h(x,m(T))\tilde{m}(x,T)dx+\int_{\mathbb{R}^{n}}\int_{\mathbb{R}^{n}}\frac{\partial}{\partial m}h(x,m(T))(\xi)\tilde{m}(\xi,T)m(x,T)dx\bigg].
\end{array}$$

As an adjoint equation, consider the BSPDE: $$\label{eq:3.9}
\left\{
\begin{array}{rcl}
    -\partial_{t}u&=&\bigg(f(x,m,\hat{v}(x))+Dug(x,m,\hat{v}(x))-\mathcal{A}u+\frac{1}{2}\beta^{2}\Delta u-\beta^{2}\text{div} B(x,t)\\
    &&\qquad+\displaystyle\int_{\mathbb{R}^{n}}\frac{\partial}{\partial m}f(\xi,m,\hat{v}(\xi))(x)m(\xi)d\xi+\int_{\mathbb{R}^{n}}Du(\xi)\frac{\partial}{\partial m}g(\xi,m,\hat{v}(\xi))(x)m(\xi)d\xi\bigg)dt\\
    &&+\beta B(x,t)db(t),\\
    