@Jazz  Thanks,
With some research I reached this solution which already works for my need:
prompt_token_ids = (prompt_token_ids.view(-1,1) == self.input_ids).int().argmax(dim=1)

the code above finds those numbers (stored in input_ids ) in a series of input tokens and replace them with their indexes in input_ids .