Just stumbled across this old post when looking for something else, but variable length scatter is basically creating a sparse tensor:
>>> idx = torch.LongTensor([[0, 0], [1, 2], [1 ,3], [2, 0], [2, 1], [2 ,4], [3, 0], [3 ,5]])
>>> val = torch.ones(len(idx))
>>> hot_vec = torch.sparse.FloatTensor(idx.t(), val, torch.Size([4, 7])
>>> hot_vec.to_dense()
tensor([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.],
        [ 0.,  0.,  1.,  1.,  0.,  0.,  0.],
        [ 1.,  1.,  0.,  0.,  1.,  0.,  0.],
        [ 1.,  0.,  0.,  0.,  0.,  1.,  0.]])