def permute(factor, num_values, random_state):
  """Permutes the ordinal information of a given factor.

  Args:
    factor: Numpy array with the observations of a factor of varation with shape
      (num_labelled_samples,) and type Int64.
    num_values: Int with number of distinct values the factor of variation can
      take.
    random_state: Random state used to sample the permutation.

  Returns:
    factor: Numpy array of Int64 with the observations of a factor of varation
      with permuted values and shape (num_labelled_samples,).
  """
  unordered_dict = random_state.permutation(range(num_values))
  factor[:] = unordered_dict[factor]
  return factor