VICReg requires torch >= 1.10
Hi,

The torch.cov in the covariance_loss function requires torch >= 1.10.
Replacing:
>      _, D = emb.size()
>      cov_emb = torch.cov(emb.T)
>      cov_ref_emb = torch.cov(ref_emb.T)
to:
>      batch_size, D = emb.size()
>      cov_emb = (emb.T @ emb) / (batch_size - 1)
>      cov_ref_emb = (ref_emb.T @ ref_emb) / (batch_size - 1)
would make it compatible with older versions as well.

Another remark is that in the reference implementation, the variance loss is divided by 2: https://github.com/facebookresearch/vicreg/blob/5e7b38f4586384bbb0d9a035352fab1d8f03b3b4/main_vicreg.py#L207
Was it intentionally left out, or am I missing something here?
diff --git a/src/pytorch_metric_learning/losses/vicreg_loss.py b/src/pytorch_metric_learning/losses/vicreg_loss.py
index 0be29b2..e539ae9 100644
--- a/src/pytorch_metric_learning/losses/vicreg_loss.py
+++ b/src/pytorch_metric_learning/losses/vicreg_loss.py
@@ -70,12 +70,14 @@ class VICRegLoss(BaseMetricLossFunction):
     def variance_loss(self, emb, ref_emb):
         std_emb = torch.sqrt(emb.var(dim=0) + self.eps)
         std_ref_emb = torch.sqrt(ref_emb.var(dim=0) + self.eps)
-        return F.relu(1 - std_emb), F.relu(1 - std_ref_emb)
+        return F.relu(1 - std_emb) / 2, F.relu(1 - std_ref_emb) / 2 # / 2 for averaging
 
     def covariance_loss(self, emb, ref_emb):
-        _, D = emb.size()
-        cov_emb = torch.cov(emb.T)
-        cov_ref_emb = torch.cov(ref_emb.T)
+        N, D = emb.size()
+        emb = emb - emb.mean(dim=0)
+        ref_emb = ref_emb - ref_emb.mean(dim=0)
+        cov_emb = (emb.T @ emb) / (N - 1)
+        cov_ref_emb = (ref_emb.T @ ref_emb) / (N - 1)
 
         diag = torch.eye(D, device=cov_emb.device)
         cov_loss = (
diff --git a/tests/losses/test_vicreg_loss.py b/tests/losses/test_vicreg_loss.py
index 102ae7a..7395c2d 100644
--- a/tests/losses/test_vicreg_loss.py
+++ b/tests/losses/test_vicreg_loss.py
@@ -42,6 +42,7 @@ class TestVICRegLoss(unittest.TestCase):
                     variance_loss = torch.mean(F.relu(1 - std_emb)) + torch.mean(
                         F.relu(1 - std_ref_emb)
                     )
+                    variance_loss = variance_loss / 2 # for averaging
 
                     # covariance loss, a more manual version
                     N, D = emb.size()
['src/pytorch_metric_learning/losses/vicreg_loss.py', 'tests/losses/test_vicreg_loss.py']