import clip
import torch




def embed_text(plip, text, device="cpu"):
    idx = clip.tokenize([text], truncate=True).to(device)
    return plip.encode_text(idx).detach().cpu().numpy()[0]