def METHOD_NAME(device):
    rank = idist.get_rank()
    torch.manual_seed(12)
    def _test(n_epochs, metric_device):
        metric_device = torch.device(metric_device)
        n_iters = 80
        batch_size = 16
        y_true = torch.rand(size=(n_iters * batch_size,)).to(device)
        y_preds = torch.rand(size=(n_iters * batch_size,)).to(device)
        def update(engine, i):
            return (
                y_preds[i * batch_size : (i + 1) * batch_size],
                y_true[i * batch_size : (i + 1) * batch_size],
            )
        engine = Engine(update)
        gmrae = GeometricMeanRelativeAbsoluteError(device=metric_device)
        gmrae.attach(engine, "gmrae")
        data = list(range(n_iters))
        engine.run(data=data, max_epochs=n_epochs)
        y_preds = idist.all_gather(y_preds)
        y_true = idist.all_gather(y_true)
        assert "gmrae" in engine.state.metrics
        res = engine.state.metrics["gmrae"]
        np_y = y_true.cpu().numpy()
        np_y_pred = y_preds.cpu().numpy()
        np_gmrae = np.exp(np.log(np.abs(np_y - np_y_pred) / np.abs(np_y - np_y.mean())).mean())
        assert pytest.approx(res, rel=1e-4) == np_gmrae
    metric_devices = ["cpu"]
    if device.type != "xla":
        metric_devices.append(idist.device())
    for metric_device in metric_devices:
        for i in range(2):
            torch.manual_seed(12 + rank + i)
            _test(n_epochs=1, metric_device=metric_device)
            _test(n_epochs=2, metric_device=metric_device)