Only scalars, vectors, and matrices are displayed as output. If the derivative is a higher order tensor it will be computed but it cannot be displayed in matrix notation. Sometimes higher order tensors are represented using Kronecker products. However, this can be ambiguous in some cases. Here, only in unambiguous cases the result is displayed using Kronecker products. The python code still works on the true higher order tensors.