def compute_snr_and_psnr(
    x: np.array,
    y: np.array,
) -> Tuple[float, float]:
    """
    Compute the Signal-to-Noise Ratio (SNR) and Peak Signal-to-Noise Ratio (PSNR) between two signals.

    This function calculates the SNR and PSNR between two input signals, typically used to compare
    an original signal (y) with a processed or noisy version of that signal (x).

    Parameters
    ----------
    x : np.array
        The processed or noisy signal.
    
    y : np.array
        The original or reference signal.

    Returns
    -------
    Tuple[float, float]
        A tuple containing two float values:
            - snr (float): The Signal-to-Noise Ratio in decibels (dB).
            - psnr (float): The Peak Signal-to-Noise Ratio in decibels (dB).

    Raises
    ------
        AssertionError: If the lengths of x and y are not equal.

    Examples
    --------
    .. sourcecode:: python

        original = np.array([1, 2, 3, 4, 5])
        noisy = np.array([1.1, 2.1, 2.9, 4.2, 5.1])
        snr, psnr = compute_snr_and_psnr(noisy, original)
        print(f"SNR: {snr:.2f} dB, PSNR: {psnr:.2f} dB")
    """
    assert x.shape == y.shape
    eps = 1e-5
    eps2 = 1e-10
    noise = x - y
    noise_var = np.sum(noise**2) / len(noise)
    signal_energy = np.sum(y**2) / len(y)
    max_signal_energy = np.amax(y**2)
    snr = 10 * np.log10((signal_energy + eps) / (noise_var + eps2))
    psnr = 10 * np.log10((max_signal_energy + eps) / (noise_var + eps2))
    return snr, psnr

    Compute the Signal-to-Noise Ratio (SNR) and Peak Signal-to-Noise Ratio (PSNR) between two signals.

    This function calculates the SNR and PSNR between two input signals, typically used to compare
    an original signal (y) with a processed or noisy version of that signal (x).

    Parameters
    ----------
    x : np.array
        The processed or noisy signal.
    
    y : np.array
        The original or reference signal.

    Returns
    -------
    Tuple[float, float]
        A tuple containing two float values:
            - snr (float): The Signal-to-Noise Ratio in decibels (dB).
            - psnr (float): The Peak Signal-to-Noise Ratio in decibels (dB).

    Raises
    ------
        AssertionError: If the lengths of x and y are not equal.

    Examples
    --------
    .. sourcecode:: python

        original = np.array([1, 2, 3, 4, 5])
        noisy = np.array([1.1, 2.1, 2.9, 4.2, 5.1])
        snr, psnr = compute_snr_and_psnr(noisy, original)
        print(f"SNR: {snr:.2f} dB, PSNR: {psnr:.2f} dB")
    
coremltools/models/ml_program/experimental/debugging_utils.py