Hi eqy, thanks …
Eventually, I did something like this…
topk = 3
idx_indices =  idx.indices 

sources_sig    = idx_indices[ :, 0].unsqueeze(-1).float()
targets_sig    = idx_indices[ :, 1:].float()

ones_like      = torch.ones( 1, topk-1, device=key_s_gt.device).float()

sources_sig     = torch.matmul(sources_sig, ones_like)

sources_sig_long = sources_sig.long().view(-1)
targets_sig_long = targets_sig.long().view(-1)

pairwise_sig_st = torch.stack([ sources_sig_long, targets_sig_long], dim=1)

Anyway, please feel free to comment for the better alternatives  …