Repository: huggingface/transformers

Issue:
run_tf_text_classification.py for custom dataset
## 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: master
- Platform: ubuntu 18.04
- Python version: 3.6
- PyTorch version (GPU?): 2080ti
- Tensorflow version (GPU?): 2080ti
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: No

### Who can help
@stefan-it
<!-- 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.
 
 albert, bert, GPT2, XLM: @LysandreJik 
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Speed and Memory Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 Translation: @sshleifer
 Summarization: @sshleifer
 TextGeneration: @TevenLeScao 
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @TevenLeScao
 blenderbot: @mariamabarham
 Bart: @sshleifer
 Marian: @sshleifer
 T5: @patrickvonplaten
 Longformer/Reformer: @patrickvonplaten
 TransfoXL/XLNet: @TevenLeScao 
 examples/seq2seq: @sshleifer
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->

## Information

Model I am using (Bert, XLNet ...): Longformer

The problem arises when using: run_tf_text_classification.py

The tasks I am working on is: customize dataset for text classification


## To reproduce
create a csv file like below
```
exp.csv
id,sentence1,sentence2
0,you,he
0,you,he
0,you,he
0,you,he
0,you,he
0,you,he
0,you,he
0,you,he
0,you,he
```
run official script (though actually I split them in jupyter notebook cell, but the code is the same)
python run_tf_text_classification.py \
  --train_file exp.csv \ ### training dataset file location (mandatory if running with --do_train option)
  --dev_file exp.csv \ ### development dataset file location (mandatory if running with --do_eval option)
  --test_file exp.csv \ ### test dataset file location (mandatory if running with --do_predict option)
  --label_column_id 0 \ ### which column corresponds to the labels
  --model_name_or_path  allenai/longformer-base-4096\
  --output_dir model \
  --num_train_epochs 4 \
  --per_device_train_batch_size 16 \
  --per_device_eval_batch_size 32 \
  --do_train \
  --do_eval \
  --do_predict \
  --logging_steps 10 \
  --evaluate_during_training \
  --save_steps 10 \
  --overwrite_output_dir \
  --max_seq_length 128


<!-- 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
```
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-43-1bd059d64d85> in <module>
      5     tokenizer=tokenizer,
      6     label_column_id=0,
----> 7     max_seq_length=200,
      8 )

<ipython-input-42-7c289105c656> in get_tfds(train_file, eval_file, test_file, tokenizer, label_column_id, max_seq_length)
     43                     padding="max_length",
     44                 ),
---> 45                 batched=True,
     46             )
     47     def gen_train():

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/datasets/arrow_dataset.py in map(self, function, with_indices, input_columns, batched, batch_size, drop_last_batch, remove_columns, keep_in_memory, load_from_cache_file, cache_file_name, writer_batch_size, features, disable_nullable, fn_kwargs, num_proc, suffix_template, new_fingerprint)
   1254                 fn_kwargs=fn_kwargs,
   1255                 new_fingerprint=new_fingerprint,
-> 1256                 update_data=update_data,
   1257             )
   1258         else:

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/datasets/arrow_dataset.py in wrapper(*args, **kwargs)
    154             "output_all_columns": self._output_all_columns,
    155         }
--> 156         out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs)
    157         if new_format["columns"] is not None:
    158             new_format["columns"] = list(set(out.column_names) - unformatted_columns)

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/datasets/fingerprint.py in wrapper(*args, **kwargs)
    161             # Call actual function
    162 
--> 163             out = func(self, *args, **kwargs)
    164 
    165             # Update fingerprint of in-place transforms + update in-place history of transforms

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/datasets/arrow_dataset.py in _map_single(self, function, with_indices, input_columns, batched, batch_size, drop_last_batch, remove_columns, keep_in_memory, load_from_cache_file, cache_file_name, writer_batch_size, features, disable_nullable, fn_kwargs, new_fingerprint, rank, offset, update_data)
   1515                     try:
   1516                         batch = apply_function_on_filtered_inputs(
-> 1517                             batch, indices, check_same_num_examples=len(self.list_indexes()) > 0, offset=offset
   1518                         )
   1519                     except NumExamplesMismatch:

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/datasets/arrow_dataset.py in apply_function_on_filtered_inputs(inputs, indices, check_same_num_examples, offset)
   1433                 effective_indices = [i + offset for i in indices] if isinstance(indices, list) else indices + offset
   1434             processed_inputs = (
-> 1435                 function(*fn_args, effective_indices, **fn_kwargs) if with_indices else function(*fn_args, **fn_kwargs)
   1436             )
   1437             if not update_data:

<ipython-input-42-7c289105c656> in <lambda>(example)
     41                     truncation=True,
     42                     max_length=max_seq_length,
---> 43                     padding="max_length",
     44                 ),
     45                 batched=True,

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/transformers/tokenization_utils_base.py in batch_encode_plus(self, batch_text_or_text_pairs, add_special_tokens, padding, truncation, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs)
   2211             return_length=return_length,
   2212             verbose=verbose,
-> 2213             **kwargs,
   2214         )
   2215 

~/anaconda3/envs/longtext-longformer/lib/python3.6/site-packages/transformers/tokenization_utils.py in _batch_encode_plus(self, batch_text_or_text_pairs, add_special_tokens, padding_strategy, truncation_strategy, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs)
    558                 ids, pair_ids = ids_or_pair_ids, None
    559             else:
--> 560                 ids, pair_ids = ids_or_pair_ids
    561 
    562             first_ids = get_input_ids(ids)

ValueError: too many values to unpack (expected 2)
```
### suggestion for fix:
in line 60 - 69, my suggestion is as comment. 
```
        for k in files.keys():
            transformed_ds[k] = ds[k].map(
                lambda example: tokenizer.batch_encode_plus(
                    (example[features_name[0]], features_name[1]), # it should be (example[features_name[0]], example[features_name[1]])
                    truncation=True,
                    max_length=max_seq_length,
                    padding="max_length",
                ),
                batched=True, # batched need to be set as True, I don't why batched=True doesn't work
            )
```
<!-- A clear and concise description of what you would expect to happen. -->



Discussion:

Resolving patch:
diff --git a/examples/text-classification/run_tf_text_classification.py b/examples/text-classification/run_tf_text_classification.py
--- a/examples/text-classification/run_tf_text_classification.py
+++ b/examples/text-classification/run_tf_text_classification.py
@@ -60,7 +60,7 @@ def get_tfds(
         for k in files.keys():
             transformed_ds[k] = ds[k].map(
                 lambda example: tokenizer.batch_encode_plus(
-                    (example[features_name[0]], features_name[1]),
+                    (example[features_name[0]], example[features_name[1]]),
                     truncation=True,
                     max_length=max_seq_length,
                     padding="max_length",


Test patch: