It seems like the issue occurs when adding position embeddings to the patch embeddings.
CLIP uses an image size of 224 and a patch size of 32. Hence, the number of patches equals (224 // 32)**2 = 49, and one also adds a CLS token, so the number of embeddings for the image tokens is 49 + 1 = 50.
However, it seems like 145 position embeddings are added. The position IDs are defined on this line 1. It seems like self.num_positions is set to 145? Can you check if this is the case?