RoBERTa: ValueError: The two structures don't have the same sequence length. Input structure has length 5, while shallow structure has length 4.
## Environment info
`transformers` version: 4.5.1
Platform: Google Colab
Python version: 3.7
PyTorch version (GPU?): NA
Tensorflow version (GPU?): 2.4.1
Using GPU in script?: Yes
Using distributed or parallel set-up in script?: No

### Who can help:
@LysandreJik for Roberta issue
@sgugger for trainer (tf_trainer) issue

Models:Roberta: @LysandreJik
Library: /transformers/trainer_tf.py: @sgugger

## Information
Model I am using RoBERTa (roberta-base) for SQuAD 2.0 Question Answering task fine tuning exercise:

The tasks I am working on is:

I am using functions from official transformer scripts only with an official SQUaD 2.0 dataset task: (give the name)
[RoBERTa_transformer_fine_tune_pre_trained_model_tftpu.zip](https://github.com/huggingface/transformers/files/6371875/RoBERTa_transformer_fine_tune_pre_trained_model_tftpu.zip)


## To reproduce
Steps to reproduce the behavior:

Run the attached script shared with GPU on Google Colab and it will give error when it tries to run trainer.train() with SQuAD 2.0 TF dataset.
Error message:
InvalidArgumentError: TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was ({'input_ids': tf.int32, 'attention_mask': tf.int32, 'feature_index': tf.int64, 'qas_id': tf.string}, {'start_positions': tf.int64, 'end_positions': tf.int64, 'cls_index': tf.int64, 'p_mask': tf.int32, 'is_impossible': tf.int32}), but the yielded element was ({'input_ids': [0, 1779, 222, 12674, 1755, 386, 1959, 1406, 116, 2, 2, 12674, 12695, 272, 354, 6591, 10690, 1634, 12, 43732, 48229, 5605, 43621, 16948, 49066, 267, 35423, 10659, 282, 1090, 35423, 10278, 73, 19417, 12, 975, 2191, 12, 28357, 43, 36, 5400, 772, 204, 6, 14130, 43, 16, 41, 470, 3250, 6, 2214, 9408, 6, 638, 3436, 8, 3390, 4, 8912, 8, 1179, 11, 2499, 6, 1184, 6, 79, 3744, 11, 1337, 6970, 8, 7950, 9150, 25, 10, 920, 6, 8, 1458, 7, 9444, 11, 5, 628, 4525, 29, 25, 483, 3250, 9, 248, 947, 387, 1816, 12, 13839, 23313, 18, 7442, 4, 1554, 4628, 30, 69, 1150, 6, 4101, 16152, 10690, 1634, 6, 5, 333, 1059, 65, 9, 5, 232, 18, 275, 12, 11393, 1816, 1134, 9, 70, 86, 4, 2667, 25224, 794, 5, 800, 9, 12674, 12695, 18, 2453, 2642, 6, 34880, 9412, 11, 3437, 36, 35153, 238, 61, 2885, 69, 25, 10, 5540, 3025, 3612, 6, 2208, 292, 12727, 4229, 8, 3520, 5, 18919, 6003, 727, 346, 12, 1264, 7695, 22, 347, 36616, 11, 3437, 113, 8, 22, 30047, 5637, 845, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
Traceback (most recent call last):

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 897, in generator_py_func
    flattened_values = nest.flatten_up_to(output_types, values)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 396, in flatten_up_to
    assert_shallow_structure(shallow_tree, input_tree)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 324, in assert_shallow_structure
    check_types=check_types)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 311, in assert_shallow_structure
    % (len(input_tree), len(shallow_tree)))

ValueError: The two structures don't have the same sequence length. Input structure has length 5, while shallow structure has length 4.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py", line 249, in __call__
    ret = func(*args)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py", line 620, in wrapper
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 905, in generator_py_func
    sys.exc_info()[2])

  File "/usr/local/lib/python3.7/dist-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 897, in generator_py_func
    flattened_values = nest.flatten_up_to(output_types, values)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 396, in flatten_up_to
    assert_shallow_structure(shallow_tree, input_tree)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 324, in assert_shallow_structure
    check_types=check_types)

  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/util/nest.py", line 311, in assert_shallow_structure
    % (len(input_tree), len(shallow_tree)))

TypeError: `generator` yielded an element that did not match the expected structure. The expected structure was ({'input_ids': tf.int32, 'attention_mask': tf.int32, 'feature_index': tf.int64, 'qas_id': tf.string}, {'start_positions': tf.int64, 'end_positions': tf.int64, 'cls_index': tf.int64, 'p_mask': tf.int32, 'is_impossible': tf.int32}), but the yielded element was ({'input_ids': [0, 1779, 222, 12674, 1755, 386, 1959, 1406, 116, 2, 2, 12674, 12695, 272, 354, 6591, 10690, 1634, 12, 43732, 48229, 5605, 43621, 16948, 49066, 267, 35423, 10659, 282, 1090, 35423, 10278, 73, 19417, 12, 975, 2191, 12, 28357, 43, 36, 5400, 772, 204, 6, 14130, 43, 16, 41, 470, 3250, 6, 2214, 9408, 6, 638, 3436, 8, 3390, 4, 8912, 8, 1179, 11, 2499, 6, 1184, 6, 79, 3744, 11, 1337, 6970, 8, 7950, 9150, 25, 10, 920, 6, 8, 1458, 7, 9444, 11, 5, 628, 4525, 29, 25, 483, 3250, 9, 248, 947, 387, 1816, 12, 13839, 23313, 18, 7442, 4, 1554, 4628, 30, 69, 1150, 6, 4101, 16152, 10690, 1634, 6, 5, 333, 1059, 65, 9, 5, 232, 18, 275, 12, 11393, 1816, 1134, 9, 70, 86, 4, 2667, 25224, 794, 5, 800, 9, 12674, 12695, 18, 2453, 2642, 6, 34880, 9412, 11, 3437, 36, 35153, 238, 61, 2885, 69, 25, 10, 5540, 3025, 3612, 6, 2208, 292, 12727, 4229, 8, 3520, 5, 18919, 6003, 727, 346, 12, 1264, 7695, 22, 347, 36616, 11, 3437, 113, 8, 22, 30047, 5637, 845, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...



## Expected behavior
* 'squad_convert_examples_to_features' function should have taken care of what all features to be passed to the model based on pre-trained tokenizer defined.
* If not then what should be steps to remove/add features required for albert model training/fine-tuning tasks should be documented somewhere [As per my knowledge it is not available anywhere]
Can someone look into it? as I am passing the same data structure as mentioned in above error i n trainer.train(). PFB.

<_AssertCardinalityDataset shapes: ({input_ids: (None,), attention_mask: (None,), feature_index: (), qas_id: ()}, {start_positions: (), end_positions: (), cls_index: (), p_mask: (None,), is_impossible: ()}), types: ({input_ids: tf.int32, attention_mask: tf.int32, feature_index: tf.int64, qas_id: tf.string}, {start_positions: tf.int64, end_positions: tf.int64, cls_index: tf.int64, p_mask: tf.int32, is_impossible: tf.int32})><|||||>Hi @PremalMatalia, thank you for opening an issue. Pinging @Rocketknight1 as the TensorFlow developer.

Please be aware that we're in the process of deprecating the `TFTrainer` and that we will not be maintaining it anymore as it doesn't offer features that cannot be handled by Keras directly. We're in the process of moving examples to Keras, and @Rocketknight1 has already started with the text classification example [here](https://github.com/huggingface/transformers/blob/master/examples/tensorflow/text-classification/run_text_classification.py).

QA is sure to follow.<|||||>Thanks @LysandreJik for your response. Good to know that TFTrainer is being deprecated so I can focus on some other ways to fine-tune.

Any other references to follow at this moment for question answering of SQuAD? <|||||>Hi! I'll take a look, but the error is quite convoluted. Can you link me to any examples you're following for this? If our code examples aren't working we definitely want to fix that.<|||||>@Rocketknight1 ...I was following below run_tf_squad.py file for fine tuning.

https://github.com/huggingface/transformers/blob/d9c62047a8d75e18d2849d345ab3394875a712ef/examples/question-answering/run_tf_squad.py
<|||||>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.