Made token instance check more flexible so it also works with integers from numpy arrays or long tensors