code: def test_mse_epoch_metric():
      def compute_fn(y_preds, y_targets):
          return torch.mean(
              ((y_preds - y_targets.type_as(y_preds)) ** 2)
          ).item()
  
      em = EpochMetric(compute_fn)
  
      em.reset()
      output1 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output1)
      output2 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output2)
      output3 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output3)
  
      preds = torch.cat([output1[0], output2[0], output3[0]], dim=0)
      targets = torch.cat([output1[1], output2[1], output3[1]], dim=0)
  
      result = em.compute()
      assert result == compute_fn(preds, targets)
  
      em.reset()
      output1 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output1)
      output2 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output2)
      output3 = (
          torch.rand(4, 3),
          torch.randint(0, 2, size=(4, 3), dtype=torch.long),
      )
      em.update(output3)
  
      preds = torch.cat([output1[0], output2[0], output3[0]], dim=0)
      targets = torch.cat([output1[1], output2[1], output3[1]], dim=0)
  
      result = em.compute()
      assert result == compute_fn(preds, targets)
  
file_path: ignite/tests/ignite/metrics/test_epoch_metric.py
imports: import pytest
  import torch
  import ignite.distributed
  from ignite.engine import Engine
  from ignite.metrics import EpochMetric
  from ignite.metrics.epoch_metric import EpochMetricWarning, NotComputableError
label_desc: Use image node_id 3 for calling a global function with example usage: test_mse_epoch_metric() and returns: torch