def _parse_label_spec(label_spec):
  """Parses label specification."""
  labels = []
  parts = label_spec.split(',')
  for part in parts:
    subset = part.split('-')
    if len(subset) == 1:
      labels.append(int(subset[0]))
    elif len(subset) == 2:
      labels.extend(range(int(subset[0]), int(subset[1]) + 1))
    else:
      raise ValueError('Wrong label specification format.')
  return labels