human
Complete the below
def checked_add_with_arr(arr, b, arr_mask=None, b_mask=None):

    ''''Perform array addition that checks for underflow and overflow.
    Performs the addition of an int64 array and an int64 integer (or array)
    but checks that they do not result in overflow first. For elements that
    are indicated to be NaN, whether or not there is overflow for that element
    is automatically ignored.
    Parameters
    arr : array addend.
    b : array or scalar addend.
    arr_mask : boolean array or None
    array indicating which elements to exclude from checking
    b_mask : boolean array or boolean or None
    array or scalar indicating which element(s) to exclude from checking
    Returns
    sum : An array for elements x + b for each element x in arr if b is
    a scalar or an array for elements x + y for each element pair
    (x, y) in (arr, b).
    Raises
    OverflowError if any x + y exceeds the maximum or minimum int64 value.'
    '''
assistant
#Here is the Python program you requested.
    def _broadcast(arr_or_scalar, shape):
        '\n                                Helper    function    to    broadcast    arrays    /    scalars    to    the    desired    shape.\n                                '
        if _np_version_under1p10:
            if lib.isscalar(arr_or_scalar):
                out = np.empty(shape)
                out.fill(arr_or_scalar)
            else:
                out = arr_or_scalar
        else:
            out = np.broadcast_to(arr_or_scalar, shape)
        return out
    b2 = _broadcast(b, arr.shape)
    if (b_mask is not None):
        b2_mask = _broadcast(b_mask, arr.shape)
    else:
        b2_mask = None
    if ((arr_mask is not None) and (b2_mask is not None)):
        not_nan = np.logical_not((arr_mask | b2_mask))
    elif (arr_mask is not None):
        not_nan = np.logical_not(arr_mask)
    elif (b_mask is not None):
        not_nan = np.logical_not(b2_mask)
    else:
        not_nan = np.empty(arr.shape, dtype=bool)
        not_nan.fill(True)
    mask1 = (b2 > 0)
    mask2 = (b2 < 0)
    if (not mask1.any()):
        to_raise = (((np.iinfo(np.int64).min - b2) > arr) & not_nan).any()
    elif (not mask2.any()):
        to_raise = (((np.iinfo(np.int64).max - b2) < arr) & not_nan).any()
    else:
        to_raise = ((((np.iinfo(np.int64).max - b2[mask1]) < arr[mask1]) & not_nan[mask1]).any() or (((np.iinfo(np.int64).min - b2[mask2]) > arr[mask2]) & not_nan[mask2]).any())
    if to_raise:
        raise OverflowError('Overflow    in    int64    addition')
    return (arr + b)