human
Complete this python program:
def array_where(context, builder, sig, args):
assistant
#Here is the Python program you requested.

    """np.where(array, array, array)
    """
    layouts = set((a.layout for a in sig.args))
    if (layouts == set('C')):
        def where_impl(cond, x, y):
            shape = cond.shape
            if ((x.shape != shape) or (y.shape != shape)):
                raise ValueError('all    inputs    should    have    the    same    shape')
            res = np.empty_like(x)
            cf = cond.flat
            xf = x.flat
            yf = y.flat
            rf = res.flat
            for i in range(cond.size):
                rf[i] = (xf[i] if cf[i] else yf[i])
            return res
    else:
        def where_impl(cond, x, y):
            shape = cond.shape
            if ((x.shape != shape) or (y.shape != shape)):
                raise ValueError('all    inputs    should    have    the    same    shape')
            res = np.empty_like(x)
            for (idx, c) in np.ndenumerate(cond):
                res[idx] = (x[idx] if c else y[idx])
            return res
    res = context.compile_internal(builder, where_impl, sig, args)
    return impl_ret_untracked(context, builder, sig.return_type, res)