problem about Custom class inheriting from <TFBertPreTrainedModel>
# ❓ Questions & Help


## Details
<!-- Description of your issue -->
I constructed class inheriting from TFBertPreTrainedModel. as follows:
```
class Model(transformers.TFBertPreTrainedModel):
    def __init__(self,config, *inputs, **kwargs):
        super(Model,self).__init__(config, *inputs, **kwargs)
        self.bert = transformers.TFBertMainLayer(config,name="bert")
       

    @tf.function
    def call(self, inputs, training=None, mask=None,**kwargs):
        out = self.bert(inputs)
        print(out)
        return out
```
main progress as follow:
```
if __name__ == "__main__":
    tokenizer = transformers.BertTokenizer("model/chinese_L-12_H-768_A-12/vocab.txt")
    text_2 = tokenizer.batch_encode_plus(["你买啊，买了就是成都人", "你来啊，来了就是深圳人"], max_length=20, pad_to_max_length=True)
    print(text_2)
    model = Model.from_pretrained("bert-base-chinese")
    out = model([tf.convert_to_tensor(text_2["input_ids"]),tf.convert_to_tensor(text_2['attention_mask'])])
```

unfortunately，the print on console was different for what I expect when I run this program. I expect that the out of **print(out)** is a tensor with size [2,20,768], but in fact, the print was run three times, outputs is **(<tf.Tensor 'bert/encoder/layer_._11/output/LayerNorm/batchnorm/add_1:0' shape=(3, 5, 768) dtype=float32>, <tf.Tensor 'bert/pooler/dense/Tanh:0' shape=(3, 768) dtype=float32>)** , **(<tf.Tensor 'bert/encoder/layer_._11/output/LayerNorm/batchnorm/add_1:0' shape=(3, 5, 768) dtype=float32>, <tf.Tensor 'bert/pooler/dense/Tanh:0' shape=(3, 768) dtype=float32>)** and **(<tf.Tensor 'bert/encoder/layer_._11/output/LayerNorm/batchnorm/add_1:0' shape=(2, 20, 768) dtype=float32>, <tf.Tensor 'bert/pooler/dense/Tanh:0' shape=(2, 768) dtype=float32>)**
My question are 1) why 2)how could I get the last outputs for following layers
I am looking forward your help, thanks
<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on Stack Overflow**:
We are trying to move these kinds of questions (which are not obvious bugs, but question for customized use cases) more and more to https://discuss.huggingface.co/. Would you mind posting it there again with your sample code:
```python
class Model(transformers.TFBertPreTrainedModel):
    def __init__(self,config, *inputs, **kwargs):
        super(Model,self).__init__(config, *inputs, **kwargs)
        self.bert = transformers.TFBertMainLayer(config,name="bert")
       

    @tf.function
    def call(self, inputs, training=None, mask=None,**kwargs):
        out = self.bert(inputs)
        print(out)
        return out
```<|||||>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.
