For the function:
$f=\frac{\alpha}{2}\|A(I_{d}\otimes X)B\|_{F}^{2}+\frac{\beta}{2}\|X-Z\|_{F}^{2},$
where $X,Z\in\mathbb{R}^{m\times n}, A\in\mathbb{R}^{k\times dm},B\in\mathbb{R}^{dn\times\ell}$. What is the derivative of $f$ with respect to $X$? Thank you in advance!
$\def\e{\varepsilon}\def\p{{\partial}}\def\grad#1#2{\frac{\p #1}{\p #2}}\def\hess#1#2#3{\frac{\p^2 #1}{\p #2\,\p #3^T}}\def\R#1{{\mathbb R}^{#1}}$To avoid confusion with derivatives and differentials change the variable $d\to p$.
Let's also define the variables $$\eqalign{ Y &= I_p\otimes X &\in\R{pm\times pn} \\ W &= A^TAYBB^T &\in\R{pm\times pn} \\ \e_k &= \{k^{th}\,{\rm column\,of}\,I_p\} &\in\R{p\times{\tt1}} \\ M_k &= \e_k\otimes I_m &\in\R{pm\times m} \\ N_k &= \e_k\otimes I_n &\in\R{pn\times n} \\ S &= \sum_{k=1}^p M_k^TWN_k &\in\R{m\times n} \\ }$$ and use a colon to denote the trace/Frobenius product $$\eqalign{ S:X &= \sum_{i=1}^m \sum_{j=1}^n S_{ij} X_{ij} \;=\; {\rm Tr}\left(SX^T\right) \\ X:X &= \big\|X\big\|^2_F \\ }$$ Write the function using the above notation, then calculate its differential and gradient. $$\eqalign{ f &= \tfrac 12\alpha(AYB):(AYB) +\tfrac 12\beta(X-Z):(X-Z) \\ df &= \alpha(AYB):A\,dY\,B + \beta(X-Z):dX \\ &= \alpha W:dY + \beta(X-Z):dX \\ &= \alpha S:dX + \beta(X-Z):dX \\ \grad{f}{X} &= \alpha S + \beta X -\beta Z \\\\ }$$
Let's expand the key identity that was used above $$\eqalign{ S:dX &= \sum_{k=1}^p M_k^TWN_k:dX \\ &= W:\sum_{k=1}^p M_k\,dX\,N_k^T \\ &= W:\sum_{k=1}^p (\e_k\otimes I_m)\,(I_{\tt1}\otimes dX)\,(\e_k^T\otimes I_n) \\ &= W:\sum_{k=1}^p (\e_k\e_k^T)\otimes(I_m\,dX\,I_n) \\ &= W:(I_p\otimes dX) \\ &= W:dY \\ }$$