Given $X\in \mathbb{R}^{m\times n}$, $Y\in \mathbb{R}^{m\times k}$, $X^\top Y=Z\in \mathbb{R}^{n\times k}$, and $f:\mathbb{R}^{n\times k} \to \mathbb{R}$, we have the following:
\begin{equation} f(X^\top Y)=f(Z) \end{equation} What is the derivative of $f$ with respect to $X$, i.e., what is $\frac{\partial f}{\partial X}$?
I tried to "expect" $\frac{\partial f}{\partial X}$ just by trying to match the dimension $m,n,k$ as follows:
\begin{equation} \begin{aligned} \frac{\partial f}{\partial X} =\frac{\partial f}{\partial Z}\frac{\partial Z}{\partial X} =Y\left(\frac{\partial f}{\partial Z}\right)^\top \end{aligned} \end{equation}
Since $\frac{\partial Z}{\partial X}$ should be a fourth-order tensor, I tried to calculate $\frac{\partial Z}{\partial X}$ by using $\frac {\partial AXB}{\partial X}=B^T\otimes A$ like this:
\begin{equation} \begin{aligned} \frac{\partial Z}{\partial X}=\frac{\partial (X^\top Y)}{\partial X} {=\left(\frac{\partial ((X^\top) Y)}{\partial (X^\top)}\right)^\top} {=\left(Y^\top \otimes I \right)^\top} {=(Y^\top)^\top \otimes I^\top} {=Y \otimes I} \end{aligned} \end{equation}
Where $\otimes$ is the Kronecker product and $I$ is the $n\times n$ identity matrix. From this, we have:
\begin{equation} \begin{aligned} \frac{\partial f}{\partial X} =\frac{\partial f}{\partial Z}\frac{\partial Z}{\partial X} =\frac{\partial f}{\partial Z}\left(Y \otimes I\right) \end{aligned} \end{equation}
From above equations, this should be true:
\begin{equation} \begin{aligned} \frac{\partial f}{\partial X} =\frac{\partial f}{\partial Z}\left(Y \otimes I\right) =Y\left(\frac{\partial f}{\partial Z}\right)^\top \end{aligned} \end{equation} The last equation seemed counter intuitive. I can not figure it out. Do I calculate $\frac{\partial f}{\partial X}$ correctly ?
If I did it wrong, how should I calculate $\frac{\partial f}{\partial X}$ instead?