Transformer layers + Functional API is failed but subclass is successful
Author: Douboo
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert):

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce
**successful**
```python
# define model via subclassing
class MyModel(tf.keras.Model):
    def __init__(self, item_dim, num_layers, num_heads, max_len, **kwargs):
        super(MyModel, self).__init__(**kwargs)
        self.item_dim = item_dim
        self.num_layers = num_layers
        self.num_heads = num_heads
        self.max_len = max_len
        self.config = BertConfig(hidden_size=item_dim, num_hidden_layers=num_layers,
                            num_attention_heads=num_heads, intermediate_size=item_dim*4,
                            max_position_embeddings=max_len)
        self.bert = TFBertMainLayer(config=self.config)
        self.dense = Dense(1, activation='sigmoid')
    def call(self, inputs):
        seq_emb = self.bert(inputs=None, inputs_embeds=inputs)[0]
        last_token_emb = seq_emb[:, -1, :]
        outputs = self.dense(last_token_emb)
        return outputs
```
**failed**
```python
def build_model(item_dim, num_layers, num_heads, max_len):
    config = BertConfig(hidden_size=item_dim, num_hidden_layers=num_layers,
                        num_attention_heads=num_heads, intermediate_size=item_dim*4,
                        max_position_embeddings=max_len)
    bert = TFBertMainLayer(config=config)
    inputs = Input(shape=(max_len, item_dim), dtype=tf.float32, name='inputs')
    # pre-training vectors to bert
    seq_emb = bert(inputs=None, inputs_embeds=inputs)[0]
    last_token_emb = seq_emb[:, -1, :]
    outputs = Dense(1, activation='sigmoid')(last_token_emb)
    model = Model(inputs=inputs, outputs=outputs)
    return model
```
Errors with
`ValueError: It appears you are trying to construct a functional model, but not all of the inputs in the first positional argument of your layer call are symbolic tensors. (Input objects, or the output of another layer) Functional models cannot correctly track custom layers unless all values in the first call argument are symbolic.`

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior
* Run the code successfully when use transformer layers and functional api.
<!-- A clear and concise description of what you would expect to happen. -->

## Environment info
https://colab.research.google.com/gist/Douboo/80dfa91917c176c530ef64be244a99a6/untitled2.ipynb
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
 
- `transformers` version: 3.1.0
- Platform: google colab
- Python version: 3.7
- Tensorflow version (GPU?): 2.3.0
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no


Comments:
Don't use transformers in tensorflow when use functional API and use pre-training vector. Help!!!

Might be of interest to @jplu 

> Might be of interest to @jplu

Thanks! Finally someone replied to me. I am a beginner.

Hello!

You are not creating you input properly, `inputs` cannot be `None`. This piece of code should work:
```
import tensorflow as tf
from transformers import TFBertMainLayer, BertConfig

config = BertConfig.from_pretrained("bert-base-cased")
bert = TFBertMainLayer(config)
inputs = tf.keras.layers.Input(shape=(None,), name='input_embeds', dtype='int32')
seq_emb = bert(inputs)[0]
last_token_emb = seq_emb[:, -1, :]
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(last_token_emb)
model = tf.keras.Model(inputs=inputs, outputs=outputs)
```

Ok after a deeper investigation, this partially solve the issue, it might have a bug in the way the model handles the Keras symbolic tensors, I need to do more tests to be sure but we certainly need to review this on our side.

Ok I found a workaround for you:

```
import tensorflow as tf
from transformers import TFBertMainLayer, BertConfig

config = BertConfig.from_pretrained("bert-base-cased")
bert = TFBertMainLayer(config)
inputs_embeds = tf.keras.layers.Input(shape=(None,768), name='inputs_embeds', dtype='float32')
inputs = {"input_embeds": inputs_embeds}
seq_emb = bert(inputs)[0]
last_token_emb = seq_emb[:, -1, :]
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(last_token_emb)
model = tf.keras.Model(inputs=inputs, outputs=[outputs])
```

> Ok I found a workaround for you:
> 
> ```
> import tensorflow as tf
> from transformers import TFBertMainLayer, BertConfig
> 
> config = BertConfig.from_pretrained("bert-base-cased")
> bert = TFBertMainLayer(config)
> inputs_embeds = tf.keras.layers.Input(shape=(None,768), name='inputs_embeds', dtype='float32')
> inputs = {"input_embeds": inputs_embeds}
> seq_emb = bert(inputs)[0]
> last_token_emb = seq_emb[:, -1, :]
> outputs = tf.keras.layers.Dense(1, activation='sigmoid')(last_token_emb)
> model = tf.keras.Model(inputs=inputs, outputs=[outputs])
> ```

Thank you very much! This method successfully solved my problem. Transformers is very awesome project. Thank you again! @jplu @LysandreJik