code: def _test_distrib_compute(device):
      rank = idist.get_rank()
  
      manhattan = DistanceMetric.get_metric("manhattan")
  
      def _test(metric_device):
          metric_device = torch.device(metric_device)
          m = ManhattanDistance(device=metric_device)
  
          y_pred = torch.randint(
              0, 10, size=(10,), device=device
          ).float()
          y = torch.randint(0, 10, size=(10,), device=device).float()
  
          m.update((y_pred, y))
  
          # gather y_pred, y
          y_pred = idist.all_gather(y_pred)
          y = idist.all_gather(y)
  
          np_y_pred = y_pred.cpu().numpy()
          np_y = y.cpu().numpy()
          res = m.compute()
          assert manhattan.pairwise([np_y_pred, np_y])[0][
              1
          ] == pytest.approx(res)
  
      for i in range(3):
          torch.manual_seed(10 + rank + i)
          _test("cpu")
          if device.type != "xla":
              _test(idist.device())
  
imports: import os
  import numpy
  import pytest
  import torch
  from sklearn.metrics import DistanceMetric
  import ignite.distributed
  from ignite.contrib.metrics.regression import ManhattanDistance
  from ignite.engine import Engine
label_desc: Use image node_id 5 for calling a global function with example usage: _test_distrib_compute(device) without return types