code: def test_integration(self, metric_device):
      from ignite.engine import Engine
  
      rank = idist.get_rank()
      torch.manual_seed(12 + rank)
      n_iters = 100
      batch_size = 10
      device = idist.device()
      if metric_device == "process_device":
          metric_device = device if device.type != "xla" else "cpu"
  
      y_pred = torch.rand(
          n_iters * batch_size,
          3,
          28,
          28,
          dtype=torch.float,
          device=device,
      )
      y = y_pred * 0.65
  
      def update(engine, i):
          return (
              y_pred[i * batch_size : (i + 1) * batch_size, ...],
              y[i * batch_size : (i + 1) * batch_size, ...],
          )
  
      engine = Engine(update)
      SSIM(data_range=1.0, device=metric_device).attach(engine, "ssim")
  
      data = list(range(n_iters))
      engine.run(data=data, max_epochs=1)
  
      y_pred = idist.all_gather(y_pred)
      y = idist.all_gather(y)
  
      assert "ssim" in engine.state.metrics
      res = engine.state.metrics["ssim"]
  
      np_pred = y_pred.cpu().numpy()
      np_true = np_pred * 0.65
      true_res = ski_ssim(
          np_pred,
          np_true,
          win_size=11,
          sigma=1.5,
          channel_axis=1,
          gaussian_weights=True,
          data_range=1.0,
          use_sample_covariance=False,
      )
  
      tol = (
          1e-3 if device.type == "xla" else 1e-4
      )  # Isn't better to ask `distributed` about backend info?
  
      assert pytest.approx(res, abs=tol) == true_res
  
      engine = Engine(update)
      SSIM(
          data_range=1.0,
          gaussian=False,
          kernel_size=7,
          device=metric_device,
      ).attach(engine, "ssim")
  
      data = list(range(n_iters))
      engine.run(data=data, max_epochs=1)
  
      assert "ssim" in engine.state.metrics
      res = engine.state.metrics["ssim"]
  
      np_pred = y_pred.cpu().numpy()
      np_true = np_pred * 0.65
      true_res = ski_ssim(
          np_pred,
          np_true,
          win_size=7,
          channel_axis=1,
          gaussian_weights=False,
          data_range=1.0,
      )
  
      assert pytest.approx(res, abs=tol) == true_res
  
file_path: ignite/tests/ignite/metrics/test_ssim.py
imports: from typing import Sequence, Union
  import numpy
  import pytest
  import torch
  from skimage.metrics import structural_similarity
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import SSIM
label_desc: Use image node_id 1 for calling the TestDistributed obj's underlying member method code with example usage: obj.test_integration(metric_device) and returns: y_pred,  y