
import torch

def get_random_perm(n):
    T = n * (n - 1) // 2
    A = torch.zeros(T, 2, dtype=torch.int)
    c = 0
    for i in range(1, n):
        for j in range(1, i):
            B = torch.tensor([i, j], dtype=torch.int)
            A[c, :] = B
            c += 1
    permuted_indices = torch.randperm(T)
    A = A[permuted_indices, :]
    return A