code: def choices(population, k=1, split_every=None):
      """
      Return a k sized list of elements chosen with replacement.
  
      Parameters
      ----------
      population: Bag
          Elements to sample.
      k: integer, optional
          Number of elements to sample.
      split_every: int (optional)
          Group partitions into groups of this size while performing reduction.
          Defaults to 8.
  
      Examples
      --------
      >>> import dask.bag as db
      >>> from dask.bag import random
      >>> b = db.from_sequence(range(5), npartitions=2)
      >>> list(random.choices(b, 3).compute())  # doctest: +SKIP
      [1, 1, 5]
      """
      res = _sample_with_replacement(
          population=population, k=k, split_every=split_every
      )
      return res.map_partitions(_finalize_sample, k)
  
file_path: dask/dask/bag/random.py
imports: from __future__ import annotations
  import heapq
  import math
  import random
  from functools import partial
  from itertools import islice
  from dask.bag.core import Bag
label_desc: Use image node_id 2 for calling a global function with example usage: choices(population, k, split_every) and returns: res