def select_random(items_list, n_to_select):
  """Selecting the given number of items at random."""
  selected = set()
  if n_to_select >= len(items_list):
    return items_list

  while len(selected) < n_to_select:
    j = random.randint(0, len(items_list) - 1)
    if items_list[j] not in selected:
      selected.add(items_list[j])

  return selected
Selecting the given number of items at random.
language/multivec/preprocessing/create_training_data.py