output = np.log(sigma2.item()/sigma1.item()) + (sigma1.item()**2 + (mu1.item() - mu2.item())**2)/(2*sigma2.item()**2) - 0.5

calling item() returns python’s standard float, which is double precision, thus np.log will keep processing floats as double precision
If you want to keep precision intact you can replace item() with numpy(), this will convert all tensor.float32 to np.float32
output = np.log(sigma2.numpy()/sigma1.numpy()) + (sigma1.numpy()**2 + (mu1.numpy() - mu2.numpy())**2)/(2*sigma2.numpy()**2) - 0.5
>>> output
array([5.9604645e-08], dtype=float32)