target = torch.tensor((2,0,3,2,1,1,2,3))
t_size = target.numel()
expand_tar = target.view(1, -1).expand(4,t_size )
adj_target = torch.abs(expand_tar - torch.arange(4).view(-1, 1).expand(4, t_size )).t()