Parse in tensorflow strings as well as normal strings
# 🚀 Feature request
So this is something I came across while trying to get a (fast) streaming dataset via the tensorflow data API for TPUs. This is a crosspost of [this SO question](https://stackoverflow.com/questions/61555097/mapping-text-data-through-huggingface-tokenizer/). 

I have my encode function that looks like this:
```python
from transformers import BertTokenizer, BertModel

MODEL = 'bert-base-multilingual-uncased'
tokenizer = BertTokenizer.from_pretrained(MODEL)

def encode(texts, tokenizer=tokenizer, maxlen=10):
#     import pdb; pdb.set_trace()
    inputs = tokenizer.encode_plus(
        texts,
        return_tensors='tf',
        return_attention_masks=True, 
        return_token_type_ids=True,
        pad_to_max_length=True,
        max_length=maxlen
    )
    
    return inputs['input_ids'], inputs["token_type_ids"], inputs["attention_mask"]
```
I want to get my data **encoded on the fly** by doing this:
```python
x_train = (tf.data.Dataset.from_tensor_slices(df_train.comment_text.astype(str).values)
           .map(encode))
```
However, this chucks the error:
```
ValueError: Input is not valid. Should be a string, a list/tuple of strings or a list/tuple of integers.
```

Now from my understanding when I set a breakpoint inside `encode` it was because I was sending a non-numpy array. How do I get huggingface transformers to play nice with tensorflow strings as inputs?

If you need a dummy dataframe here it is:
```
df_train = pd.DataFrame({'comment_text': ['Today was a good day']*5})
```
## What I tried
So I tried to use `from_generator` so that I can parse in the strings to the `encode_plus` function. However, this does not work with TPUs.
```python
AUTO = tf.data.experimental.AUTOTUNE

def get_gen(df):
    def gen():
        for i in range(len(df)):
            yield encode(df.loc[i, 'comment_text']) , df.loc[i, 'toxic']
    return gen

shapes = ((tf.TensorShape([maxlen]), tf.TensorShape([maxlen]), tf.TensorShape([maxlen])), tf.TensorShape([]))

train_dataset = tf.data.Dataset.from_generator(
    get_gen(df_train),
    ((tf.int32, tf.int32, tf.int32), tf.int32),
    shapes
)
train_dataset = train_dataset.batch(BATCH_SIZE).prefetch(AUTO)
```

My final solution was to encode the all the strings using `batch_encode_plus` but to write those tensors out to disk. This currently takes ~1 hour, but seems like an inefficient way of prepping data for training.
## Version Info:
`transformers.__version__, tf.__version__` => `('2.7.0', '2.1.0')`
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>Hey, any updates about this issue? I'm facing the exact same problem!<|||||>@sachinruk @joaopedromattos any luck here in the end :)