Thanks for your apply. I tried the solution but it does not work as I expected.
A related question. Suppose I have a = torch.tensor([1,2,3]), how to expand it to
tensor([[[ 1,  1,  1],
[ 1,  1,  1]],
       [[ 2,  2,  2],
       [ 2,  2,  2]],

       [[ 3,  3,  3],
       [ 3,  3,  3]]])

Thanks!