def sample(population, k):
    'Chooses k unique random elements from a bag.\n\n    Returns a new bag containing elements from the population while\n    leaving the original population unchanged.\n\n    Parameters\n    ----------\n    population: Bag\n        Elements to sample.\n    k: integer, optional\n        Number of elements to sample.\n\n    Examples\n    --------\n    >>> import dask.bag as db # doctest: +SKIP\n    ... from dask.bag import random\n    ...\n    ... b = db.from_sequence(range(5), npartitions=2)\n    ... list(random.sample(b, 3).compute())\n    [1, 3, 5]\n    '
    return _sample(population=population, k=k, replace=False)
Chooses k unique random elements from a bag.

Returns a new bag containing elements from the population while
leaving the original population unchanged.

Parameters
----------
population: Bag
    Elements to sample.
k: integer, optional
    Number of elements to sample.

Examples
--------
>>> import dask.bag as db # doctest: +SKIP
... from dask.bag import random
...
... b = db.from_sequence(range(5), npartitions=2)
... list(random.sample(b, 3).compute())
[1, 3, 5]
def sample(population, k):
    'Chooses k unique random elements from a bag.\n\n    Returns a new bag containing elements from the population while\n    leaving the original population unchanged.\n\n    Parameters\n    ----------\n    population: Bag\n        Elements to sample.\n    k: integer, optional\n        Number of elements to sample.\n\n    Examples\n    --------\n    >>> import dask.bag as db # doctest: +SKIP\n    ... from dask.bag import random\n    ...\n    ... b = db.from_sequence(range(5), npartitions=2)\n    ... list(random.sample(b, 3).compute())\n    [1, 3, 5]\n    '
    return _sample(population=population, k=k, replace=False)