Performs an element-wise check to determine if the NDArray contains an infinite element
    or not.


    Parameters
    ----------
    input : NDArray
        An N-D NDArray.

    Returns
    -------
    output: NDArray
        The output NDarray, with same shape as input, where 1 indicates the array element is
        finite i.e. not equal to positive or negative infinity and 0 in places where it is
        positive or negative infinity.

    Examples
    --------
    >>> data = mx.nd.array([np.inf, -np.inf, np.NINF, -1])
    >>> output = mx.nd.contrib.isfinite(data)
    >>> output
    [0. 0. 0. 1.]
    <NDArray 4 @cpu(0)>

def isfinite(data):
    """Performs an element-wise check to determine if the NDArray contains an infinite element
    or not.


    Parameters
    ----------
    input : NDArray
        An N-D NDArray.

    Returns
    -------
    output: NDArray
        The output NDarray, with same shape as input, where 1 indicates the array element is
        finite i.e. not equal to positive or negative infinity and 0 in places where it is
        positive or negative infinity.

    Examples
    --------
    >>> data = mx.nd.array([np.inf, -np.inf, np.NINF, -1])
    >>> output = mx.nd.contrib.isfinite(data)
    >>> output
    [0. 0. 0. 1.]
    <NDArray 4 @cpu(0)>
    """
    is_data_not_nan = data == data
    is_data_not_infinite = data.abs() != np.inf
    return ndarray.logical_and(is_data_not_infinite, is_data_not_nan)