I want to create a tensor having specific size like the below,
# a: (B, N, 2) = (2, 3, 2)
a = torch.LongTensor([[[2, 1], [2, 2], [3, 3]], [[2, 0], [3, 2], [1, 2]]])
K = 5

# The expected tensor has the size of (B, K, K) = (2, 5, 5)
# For the first batch,
result[0] = torch.LongTensor([[0, 0, 0, 0, 0],
                              [0, 0, 0, 0, 0],
                              [0, 1, 1, 0, 0],
                              [0, 0, 0, 1, 0],
                              [0, 0, 0, 0, 0]])

The result tensor can be a LongTensor or BoolTensor whatever. I need to use it as a mask.
I want to avoid a loop operation since N might be scalable.
Thanks,