Return a view of the array with dimensions permuted according to axes, as a masked array.
If axes is None (default), the output view has reversed dimensions compared to the original.
numpy.ma.trace
numpy.ma.MaskedArray.trace