code: def psnr_stack(data1, data2, metric=np.mean, method='starck'):
      r
  
      if data1.ndim != 3 or data2.ndim != 3:
          raise ValueError('Input data must be a 3D np.ndarray')
  
      return metric([psnr(i, j, method=method) for i, j in
                    zip(data1, data2)])
docs: r"""Peak Signa-to-Noise for stack of images
  
      This method calculates the PSNRs for two stacks of 2D arrays.
      By default the metod returns the mean value of the PSNRs, but any other
      metric can be used.
  
      Parameters
      ----------
      data1 : np.ndarray
          Stack of images, 3D array
      data2 : np.ndarray
          Stack of recovered images, 3D array
      method : str {'starck', 'wiki'}, optional
          PSNR implementation, default ('starck')
      metric : function
          The desired metric to be applied to the PSNR values (default is
          'np.mean')
  
      Returns
      -------
      float metric result of PSNR values
  
      Raises
      ------
      ValueError
          For invalid input data dimensions
  
      Examples
      --------
      >>> from modopt.math.stats import psnr_stack
      >>> a = np.arange(18).reshape(2, 3, 3)
      >>> psnr_stack(a, a + 2)
      12.041199826559248