Thanks for the note.
Yeah. torch.cat can help. But what I further need to do is to copy the last few tokens’ embedding to previous slots if w_len is less than the max_len (20 here)  in first token sequence. That may needs a for loop. So do you know any other efficient ways of dong this. Thanks for your precious time.