I want to use create multiple-hot vector.
I tried to use scatter_ function of Tensor.
It works fine for the fixed length of indices.
batch_size = 4
dim = 7
idx = torch.LongTensor([[0,1],[2,3],[0,4],[0,5]])
hot_vec = hot_v = torch.zeros(batch_size, dim)
hot_vec.scatter_(1, idx, 1.0)

result
    1     1     0     0     0     0     0
    0     0     1     1     0     0     0
    1     0     0     0     1     0     0
    1     0     0     0     0     1     0

But my data does not have the same number of index
for
idx_v = torch.LongTensor( [[0], [2,3], [0,1,4], [0,5]] )
I want the hot vector like the below.
    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

What  can I use to make the vector ?