torch.linalg.matrix_power
torch.linalg.matrix_power(A, n, *, out=None) -> Tensor
Computes the n-th power of a square matrix for an integer n.
Supports input of float, double, cfloat and cdouble dtypes. Also
   supports batches of matrices, and if "A" is a batch of matrices
   then the output has the same batch dimensions.
If "n"= 0, it returns the identity matrix (or batch) of the same
   shape as "A". If "n" is negative, it returns the inverse of each
   matrix (if invertible) raised to the power of abs(n).
Note:
 Consider using "torch.linalg.solve()" if possible for multiplying
 a matrix on the left by a negative power as, if "n"*> 0*:

    matrix_power(torch.linalg.solve(A, B), n) == matrix_power(A, -n)  @ B

 It is always preferred to use "solve()" when possible, as it is
 faster and more numerically stable than computing A^{-n}
 explicitly.

See also:
 "torch.linalg.solve()" computes "A"*.inverse() @ *"B" with a
