<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw(cdf, size=None):
 """ Generate a random sample according to the cumulative distribution given by `cdf`. Jit-complied by Numba in nopython mode. Parameters cdf : array_like(float, ndim=1) Array containing the cumulative distribution. size : scalar(int), optional(default=None) Size of the sample. If an integer is supplied, an ndarray of `size` independent draws is returned; otherwise, a single draw is returned as a scalar. Returns ------- scalar(int) or ndarray(int, ndim=1) Examples -------- 1 array([1, 0, 1, 0, 1, 0, 0, 0, 1, 0]) """

    if isinstance(size, types.Integer):
        def draw_impl(cdf, size):
            rs = np.random.random_sample(size)
            out = np.empty(size, dtype=np.int_)
            for i in range(size):
                out[i] = searchsorted(cdf, rs[i])
            return out
    else:
        def draw_impl(cdf, size):
            r = np.random.random_sample()
            return searchsorted(cdf, r)
    return draw_impl