How to obtain $ \frac{\mathrm{d}}{\mathrm{d} \mathbf{T}} (\mathbf{Z} \circ (\mathbf{T}\mathbf{X})) = \mathbf{X}^T \otimes Diag(\mathbf{Z}) $? $$
\frac{\mathrm{d}}{\mathrm{d} \mathbf{T}} (\mathbf{Z} \circ (\mathbf{T}\mathbf{X})) = \mathbf{X}^T \otimes Diag(\mathbf{Z})
$$
For $T \in \mathbb{R}^{K \times K}, Z,X \in \mathbb{R}^{K \times 1}$
I want to solve this derivative, however no matter what I found online, I just couldn't find a way to construct an equation with Kronecker product as shown above 
here $\circ$ means Hadamard product.
Any helps is much appreciated!
 A: $
\def\o{{\tt1}}\def\p{\partial}
\def\L{\left}\def\R{\right}
\def\LR#1{\L(#1\R)}
\def\BR#1{\Big(#1\Big)}
\def\bR#1{\big(#1\big)}
\def\vec#1{\operatorname{vec}\LR{#1}}
\def\bvec#1{\operatorname{vec}\!\BR{\!#1}}
\def\Diag#1{\operatorname{Diag}\LR{#1}}
\def\trace#1{\operatorname{Tr}\LR{#1}}
\def\qiq{\quad\implies\quad}
\def\grad#1#2{\frac{\p #1}{\p #2}}
\def\c#1{\color{red}{#1}}
$The standard basis matrix $E_{ij}\;\big($whose elements are all zero except for the $\{i,j\}^{th}$ element which is equal to $\o\big)\,$ can be used to write the gradient of a matrix with respect to its own components
$$\eqalign{
\grad{T}{T_{ij}} &= E_{ij} \\
}$$
Therefore the component-wise gradients of the given function are
$$\eqalign{
f &= z\circ (Tx) \;=\; \Diag{z}\;Tx \\
\grad{f}{T_{ij}} &= \Diag{z}\;E_{ij}\,x \\
}$$
Instead of using components, some authors vectorize the equation
before calculating the gradient
$$\eqalign{
f &= \bvec{\Diag{z}\;Tx} \;=\; \BR{x^T\otimes\Diag{z}}\vec{T} \\
\grad{f}{\vec{T}} &= {x^T\otimes\Diag{z}} \\
}$$
But both approaches side-step the underlying issue, which is that the true gradient is neither a vector nor a matrix but is, in fact,
a third-order tensor$\;$which can be calculated as follows
$$\eqalign{
f &= \BR{\!\Diag{z}\star x}:T \\
\grad{f}{T} &= {\Diag{z}\star x} \\
}$$
where $(\star)$ denotes the dyadic product
and $(:)$ the double-dot product, i.e.
$$\eqalign{
\bR{A\star b}_{ijk} &= A_{ij}\,b_{k} \\
\bR{{A\star b}:T}_i
 &= \sum_{j=\o}^m\sum_{k=\o}^n A_{i\c{j}}\,b_{\c{k}}\;T_{\c{jk}} \\
}$$
