code: def _test_distrib_integration(device):
      from ignite.engine import Engine
  
      rank = idist.get_rank()
      torch.manual_seed(12)
  
      def _test(metric_device):
          n_iters = 60
          s = 16
          offset = n_iters * s
  
          n_features = 10
  
          y_pred = torch.rand(
              offset * idist.get_world_size(), n_features
          )
          y_true = torch.rand(
              offset * idist.get_world_size(), n_features
          )
  
          def update(_, i):
              return (
                  y_pred[
                      i * s
                      + rank * offset : (i + 1) * s
                      + rank * offset,
                      :,
                  ],
                  y_true[
                      i * s
                      + rank * offset : (i + 1) * s
                      + rank * offset,
                      :,
                  ],
              )
  
          engine = Engine(update)
          m = FID(
              num_features=n_features,
              feature_extractor=torch.nn.Identity(),
              device=metric_device,
          )
          m.attach(engine, "fid")
  
          engine.run(data=list(range(n_iters)), max_epochs=1)
  
          assert "fid" in engine.state.metrics
  
          evaluator = pytorch_fid_score.calculate_frechet_distance
          mu1, sigma1 = y_pred.mean(axis=0).to("cpu"), cov(
              y_pred.to("cpu"), rowvar=False
          )
          mu2, sigma2 = y_true.mean(axis=0).to("cpu"), cov(
              y_true.to("cpu"), rowvar=False
          )
          assert (
              pytest.approx(
                  evaluator(mu1, sigma1, mu2, sigma2), rel=1e-5
              )
              == m.compute()
          )
  
      metric_devices = [torch.device("cpu")]
      if device.type != "xla":
          metric_devices.append(idist.device())
  
      for metric_device in metric_devices:
          _test(metric_device=metric_device)
  
imports: import os
  import re
  from unittest.mock import patch
  import pytest
  import pytorch_fid.fid_score
  import scipy
  import torch
  from numpy import cov
  import ignite.distributed
  from ignite.metrics.gan.fid import FID, fid_score
label_desc: Use image node_id 11 for calling a global function with example usage: _test_distrib_integration(device) and returns: y_pred,  y_true