Repository: huggingface/transformers

Issue:
Wrong arg order for `nested_xla_mesh_reduce` in trainer.py
## Environment info
Python 3.7 on Google Cloud TPUs

### Who can help
@sgugger 


## Information
When training examples from [run_glue.py](https://github.com/huggingface/transformers/blob/master/examples/text-classification/run_glue.py) using Cloud TPUs, we run into this error:
```
TypeError: _xla_rendezvous(): incompatible function arguments. The following argument types are supported:

1. (arg0: int, arg1: str, arg2: str, arg3: List[int]) -> List[bytes]
```

This issue is just due to the wrong arg order in [this line](https://github.com/huggingface/transformers/blob/master/src/transformers/trainer.py#L1337) where the [args should be switched](https://github.com/huggingface/transformers/blob/656c27c3a3345d0d2cf31c16f780b573c3dea09a/src/transformers/trainer_utils.py#L162).

This was introduced in:  https://github.com/huggingface/transformers/commit/492bb6aa486856f8243dfeb533ed1b23e996e403 

## To reproduce

Steps to reproduce the behavior:

1. Running the provided example on Cloud TPU.

## Expected behavior
Should not fail with `TypeError`.
Wrong arg order for `nested_xla_mesh_reduce` in trainer.py
## Environment info
Python 3.7 on Google Cloud TPUs

### Who can help
@sgugger 


## Information
When training examples from [run_glue.py](https://github.com/huggingface/transformers/blob/master/examples/text-classification/run_glue.py) using Cloud TPUs, we run into this error:
```
TypeError: _xla_rendezvous(): incompatible function arguments. The following argument types are supported:

1. (arg0: int, arg1: str, arg2: str, arg3: List[int]) -> List[bytes]
```

This issue is just due to the wrong arg order in [this line](https://github.com/huggingface/transformers/blob/master/src/transformers/trainer.py#L1337) where the [args should be switched](https://github.com/huggingface/transformers/blob/656c27c3a3345d0d2cf31c16f780b573c3dea09a/src/transformers/trainer_utils.py#L162).

This was introduced in:  https://github.com/huggingface/transformers/commit/492bb6aa486856f8243dfeb533ed1b23e996e403 

## To reproduce

Steps to reproduce the behavior:

1. Running the provided example on Cloud TPU.

## Expected behavior
Should not fail with `TypeError`.


Discussion:
Indeed, I switched the args, sorry about that. Will make a PR to fix this tomorrow morning.
Indeed, I switched the args, sorry about that. Will make a PR to fix this tomorrow morning.

Resolving patch:
diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py
--- a/src/transformers/trainer.py
+++ b/src/transformers/trainer.py
@@ -1334,9 +1334,9 @@ def prediction_loop(
         elif is_torch_tpu_available():
             # tpu-comment: Get all predictions and labels from all worker shards of eval dataset
             if preds is not None:
-                preds = nested_xla_mesh_reduce("eval_preds", preds)
+                preds = nested_xla_mesh_reduce(preds, "eval_preds")
             if label_ids is not None:
-                label_ids = nested_xla_mesh_reduce("eval_label_ids", label_ids, torch.cat)
+                label_ids = nested_xla_mesh_reduce(label_ids, "eval_label_ids")
             if eval_losses is not None:
                 eval_losses = xm.mesh_reduce("eval_losses", torch.tensor(eval_losses), torch.cat).tolist()
 


Test patch: