human
Complete the below
def _lazywhere(cond, arrays, f, fillvalue=None, f2=None):

    ''''np.where(cond, x, fillvalue) always evaluates x even where cond is False.
    This one only evaluates f(arr1[cond], arr2[cond], ...).
    For example,
    >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
    >>> def f(a, b):
    return a*b
    >>> _lazywhere(a > 2, (a, b), f, np.nan)
    array([ nan,  nan,  21.,  32.])
    Notice it assumes that all `arrays` are of the same shape, or can be
    broadcasted together.'
    '''

Write me a the Python code you requested?
assistant
#Here is the Python code you requested.
    if (fillvalue is None):
        if (f2 is None):
            raise ValueError('One    of    (fillvalue,    f2)    must    be    given.')
        else:
            fillvalue = np.nan
    elif (f2 is not None):
        raise ValueError('Only    one    of    (fillvalue,    f2)    can    be    given.')
    arrays = np.broadcast_arrays(*arrays)
    temp = tuple((np.extract(cond, arr) for arr in arrays))
    tcode = np.mintypecode([a.dtype.char for a in arrays])
    out = _valarray(np.shape(arrays[0]), value=fillvalue, typecode=tcode)
    np.place(out, cond, f(*temp))
    if (f2 is not None):
        temp = tuple((np.extract((~ cond), arr) for arr in arrays))
        np.place(out, (~ cond), f2(*temp))
    return out