Hi,
I’m a bit confused by your convert_to_correlation. It does not use m.
For 1: all the operations your use support batching (.diagonal, .inverse and matmul), so you can write a convert_to_correlation that works on the whole batch at once.
For 2: we have an implementation of derivatives for inversion and all other functions you use. So the result will be differentiable  (You can check that res.requires_grad = True).