def METHOD_NAME(arr):
    """Compute the inverse of the non-zero elements of arr, not changing 0.
    Parameters
    ----------
    arr : ndarray
    Returns
    -------
    arr_inv : ndarray
        Array containing the inverse of the non-zero elements of arr, and
        zero elsewhere.
    """
    arr_inv = arr.copy()
    nz = np.nonzero(arr)
    arr_inv[nz] = 1 / arr[nz]
    return arr_inv