what size is tokens_embedding?
If all your token embeddings are of size torch.Size([768]) and say you have four of them. You’ll want to use torch.stack in this example,
tokens_embedding = [torch.randn(768) for _ in range(4)] #list of 4 Tensors of shape [768]

_embedding = torch.cat(tokens_embedding)
_embedding.shape #returns torch.Size([3072])
 
_embedding = torch.stack(tokens_embedding)
_embedding.shape #returns torch.Size([4, 768])