code: def _test(
      y_pred,
      y,
      data_range,
      metric_device,
      n_iters,
      batch_size,
      atol,
      output_transform=lambda x: x,
      compute_y_channel=False,
  ):
      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)
      psnr = PSNR(
          data_range=data_range,
          output_transform=output_transform,
          device=metric_device,
      )
      psnr.attach(engine, "psnr")
      data = list(range(n_iters))
  
      engine.run(data=data, max_epochs=1)
  
      y = idist.all_gather(y)
      y_pred = idist.all_gather(y_pred)
  
      assert "psnr" in engine.state.metrics
      result = engine.state.metrics["psnr"]
      assert result > 0.0
  
      if compute_y_channel:
          np_y_pred = y_pred[:, 0, ...].cpu().numpy()
          np_y = y[:, 0, ...].cpu().numpy()
      else:
          np_y_pred = y_pred.cpu().numpy()
          np_y = y.cpu().numpy()
  
      np_psnr = 0
      for np_y_pred_, np_y_ in zip(np_y_pred, np_y):
          np_psnr += ski_psnr(np_y_, np_y_pred_, data_range=data_range)
  
      assert np.allclose(result, np_psnr / np_y.shape[0], atol=atol)
  
file_path: ignite/tests/ignite/metrics/test_psnr.py
imports: import numpy
  import pytest
  import torch
  from skimage.metrics import peak_signal_noise_ratio
  import ignite.distributed
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
  from ignite.metrics import PSNR
  from ignite.utils import manual_seed
label_desc: Use image node_id 5 for calling a global function with example usage: _test(y_pred, y, data_range, metric_device, n_iters, batch_size, atol, output_transform, compute_y_channel) and returns: y_pred,  y