So you should go through torch.diag operation
https://pytorch.org/docs/stable/generated/torch.diag.html 1
it return the diagonal from the matrix. for example in 3x3 it can only return 5 diagonals (ranging from -2 to 2)
so in case of of 672x672 matrix how it will return 1024 diagonal.
So look into it and run code step by step.