I am having trouble figuring out the following matrix derivative $\frac{\partial(B X A')(AX A')^{-1}}{\partial X}$, where $X$ is square $n\times n$, A is $m\times n$, with $m<n$. and B is dimension $l\times N$.
I started with $\frac{\partial BX A'}{\partial X}(AX A')^{-1}+ (BX A')\frac{\partial (A XA)^{-1}}{\partial X}$, but I can't properly figure out the second term.
The desired matrix derivative has $n^2$ matrix elements of dimensions $\ell\times m$ given by $$\begin{eqnarray}\frac{\partial(BXA')(A XA')^{-1}}{\partial x_{ij}}& =&\frac{\partial(BXA')}{\partial x_{ij}}(A XA')^{-1}+(BXA')\frac{\partial(A XA')^{-1}}{\partial x_{ij}}\\& = &\frac{\partial(BXA')}{\partial x_{ij}}(A XA')^{-1}-(BXA')(A XA')^{-1}\frac{\partial(A XA')}{\partial x_{ij}}(A XA')^{-1}\end{eqnarray}$$ with $X=[x_{ij}]_{i,j=1}^n$. Note that the matrix derivative will have dimensions $n\ell\times nm$ so your development is not correct.
Using Kronecker product notation and the $vec$ operator we can write the complete solution as follows $$\begin{align}\frac{\partial(BXA')(A XA')^{-1}}{\partial X} & = \frac{\partial(BXA')}{\partial X}\left[\mathbb{I}_n\otimes (A XA')^{-1}\right]\\&\qquad -\left[\mathbb{I}_n\otimes (BXA')(A XA')^{-1}\right]\frac{\partial(A XA')}{\partial X}\left[\mathbb{I}_n\otimes(A XA')^{-1}\right]\\ & = (vec B')(vec A')'\left[\mathbb{I}_n\otimes (A XA')^{-1}\right]\\ &\qquad-\left[\mathbb{I}_n\otimes (BXA')(A XA')^{-1}\right](vec A')(vec A')'\left[\mathbb{I}_n\otimes(A XA')^{-1}\right]\end{align}$$