How can I sum up the inverse covariance matrix in pytorch?

How can I sum up the inverse covariance matrix and the mean over a Number of samples like in the following formula in pytorch:

math

Thanks in advance.

is torch.inverse(covariance) the right way for inverting the covariance matrix in this case?