When encoding text to feature vectors - Would be awesome to be able to use the simplest tokenizer with a split on spaces
Author: Svito-zar
Pull request: no

# 🚀 Feature request

When using the `DistilBertTokenizer` (or `BertTokenizer`) I would love to tokenize my text by simply splitting it on spaces:
```
['also', 'du', 'fängst', 'an', 'mit', 'der', 'Stadtrundfahrt']
```
instead of the default behavior, which is splitting it into sub-parts:
```
['also', 'du', 'f', '##ängst', 'an', 'mit', 'der', 'Stadt', '##rund', '##fahrt']
```


## Motivation
That's needed in order to have feature vector length to be the same as the number of words in the text, so that we can have 1-to-1 correspondence between words and their features

<!-- Please outline the motivation for the proposal. Is your feature request
     related to a problem? e.g., I'm always frustrated when [...]. If this is related
     to another GitHub issue, please link here too. -->

## Your contribution

I have seen that such tokenization can be done using `tokenizer.basic_tokenizer` and I have tried to use it to encode the text:
```
from transformers import DistilBertModel, DistilBertTokenizer
import torch

text_str = "also du fängst an mit der Stadtrundfahrt"

# create DistilBERT tokenizer and model
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-german-cased')
model = DistilBertModel.from_pretrained('distilbert-base-german-cased')

# check if tokens are correct
tokens = tokenizer.basic_tokenizer.tokenize(text_str)
print("Tokens: ", tokens)

# Encode the curent text
input_ids = torch.tensor(tokenizer.basic_tokenizer.encode(text_str)).unsqueeze(0)
outputs = model(input_ids)
last_hidden_states = outputs[0]
```

But this code raises an error because `BasicTokenizer` does not have attribute 'encode' yet:
```
Traceback (most recent call last):
  File "/home/tarask/Desktop/Work/Code/Git/probabilistic-gesticulator/my_code/data_processing/annotations/feat/test.py", line 15, in <module>
    input_ids = torch.tensor(tokenizer.basic_tokenizer.encode(text_str)).unsqueeze(0)
AttributeError: 'BasicTokenizer' object has no attribute 'encode'
```


Comments:
This solution seems to be working:
```
from transformers import DistilBertModel, DistilBertTokenizer
import torch

text_str = "also du fängst an mit der Stadtrundfahrt"

# create DistilBERT tokenizer and model
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-german-cased')
model = DistilBertModel.from_pretrained('distilbert-base-german-cased')

# check if tokens are correct
tokens = tokenizer.basic_tokenizer.tokenize(text_str)
print("Tokens: ", tokens)

# Encode the curent text
input_ids = torch.tensor(tokenizer.encode(tokens)).unsqueeze(0)
outputs = model(input_ids)
last_hidden_states = outputs[0]
print(last_hidden_states[0,1:-1].shape)
```

What do you think? Is it correct usage?

I just realized it was not correct. [Users of StackOverflow](https://stackoverflow.com/questions/66064503/in-huggingface-tokenizers-how-can-i-split-a-sequence-simply-on-spaces/) indicated that.

Running the following command: `tokenizer.convert_ids_to_tokens(input_ids.tolist()[0])` indicates that "fängst" and "Stadtrundfahrt" are encoded with the same id because they are not part of the dictionary :( 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.