TFDecoderEncoder: The following keyword arguments are not supported by this model: ['position_ids', 'token_type_ids']
Author: khang-nguyen2907
Pull request: no

## Environment info
<!-- 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: v4.17.0
- Platform: Google Colab
- Python version: 3.7
- PyTorch version (GPU?): NA
- Tensorflow version (GPU?): 2.8.0
- Using GPU in script?: Yes 
- Using distributed or parallel set-up in script?: No

### Who can help
@patrickvonplaten for EncoderDecoder
Models: transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py: @patrickvonplaten
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- T5, Pegasus, EncoderDecoder: @patrickvonplaten
- Blenderbot, MBART, BART, Marian, Pegasus: @patil-suraj
- Reformer, TransfoXL, XLNet, FNet: @patrickvonplaten
- Longformer, BigBird: @ydshieh
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patil-suraj, @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder, UniSpeech, UniSpeechSAT, SEW, SEW-D, Speech2Text: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten @narsil
- Tokenizers: @SaulLu
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): TFEncoderDecoderModel. The encoder is distilroberta and the decoder is GPT2. I have my own ```position_ids``` and ```token_type_ids``` initialized for distilroberta when I tokenize my inputs. In pytorch version of EncoderDecoderModel, I can easily pass these 2 arguments to EncoderdecoderModel forward function. However, when I do the same thing in TFEncoderDecoderModel, it raises error that ```position_ids``` and ```token_type_ids``` argument are not supported by this model

## To reproduce
```python 
encoder_config = AutoConfig.from_pretrained('distilroberta-base')
decoder_config = AutoConfig.from_pretrained('gpt2')
config = EncoderDecoderConfig.from_encoder_decoder_configs(encoder_config, decoder_config)
model = TFEncoderDecoderModel(config)

outputs = model(
                    input_ids=input_ids_batch,
                    attention_mask=attention_mask_batch,
                    decoder_input_ids=decoder_input_ids_batch,
                    decoder_attention_mask=decoder_attn_mask_batch,
                    encoder_outputs=None,
                    past_key_values=None,
                    inputs_embeds=None,
                    decoder_inputs_embeds=None,
                    labels=labelled_batch,
                    use_cache=None,
                    output_attentions=None,
                    output_hidden_states=None,
                    return_dict=None,
                    training=False,
                    position_ids = pos_ids_batch,
                    token_type_ids = token_type_batch
                )
```
```python
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-da93c7339615> in <module>()
     33                     return_dict=None,
     34                     training=False,
---> 35                     **new_args
     36                 )

2 frames
/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
     65     except Exception as e:  # pylint: disable=broad-except
     66       filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67       raise e.with_traceback(filtered_tb) from None
     68     finally:
     69       del filtered_tb

/usr/local/lib/python3.7/dist-packages/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py in call(self, input_ids, attention_mask, decoder_input_ids, decoder_attention_mask, encoder_outputs, past_key_values, inputs_embeds, decoder_inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict, training, **kwargs)
    541             kwargs_encoder = {}
    542 
--> 543             encoder_inputs = input_processing(**encoder_processing_inputs)
    544 
    545             # Handle the case where the inputs are passed as a single dict which contains `labels`.

/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py in input_processing(func, config, input_ids, **kwargs)
    401     if len(kwargs["kwargs_call"]) > 0:
    402         raise ValueError(
--> 403             f"The following keyword arguments are not supported by this model: {list(kwargs['kwargs_call'].keys())}."
    404         )
    405 

ValueError: Exception encountered when calling layer "tf_encoder_decoder_model" (type TFEncoderDecoderModel).

The following keyword arguments are not supported by this model: ['position_ids', 'token_type_ids'].

Call arguments received:
  • input_ids=tf.Tensor(shape=(1, 512), dtype=int32)
  • attention_mask=tf.Tensor(shape=(1, 512, 512), dtype=int32)
  • decoder_input_ids=tf.Tensor(shape=(1, 512), dtype=int32)
  • decoder_attention_mask=tf.Tensor(shape=(1, 512), dtype=int32)
  • encoder_outputs=None
  • past_key_values=None
  • inputs_embeds=None
  • decoder_inputs_embeds=None
  • labels=tf.Tensor(shape=(1, 512), dtype=int32)
  • use_cache=None
  • output_attentions=None
  • output_hidden_states=None
  • return_dict=None
  • training=False
  • kwargs={'position_ids': 'tf.Tensor(shape=(1, 512), dtype=int32)', 'token_type_ids': 'tf.Tensor(shape=(1, 512), dtype=int32)'}
```

<!-- 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
This should handle additional arguments correctly. 

<!-- A clear and concise description of what you would expect to happen. -->


Comments:
@khang-nguyen2907 thank you for raising this. We have been making some changes to simplify our TF model code, and it seems to have caused this issue. I will look into it and keep you in the loop.

Old versions of `transformers` seem to have the same behavior, so the root cause is not what I thought. Diving deeper 🔍 

@khang-nguyen2907 the PR liked to this issue, which was just merged, should fix your issue -- try (re)installing `transformers==4.18.0.dev0`.

If it doesn't solve the issue, or if you run into new problems, feel free to reopen :)