import torch


def gen_random_labels(num_instance, max_idx):
    """ get random labels in randomrange(max_idx)
    >>> labels = gen_random_labels(10, 3)
    """
    return torch.multinomial(torch.ones(max_idx), num_instance, replacement = True)