check type before logging in trainer to ensure values are scalars
This change was necessary to avoid https://github.com/lanpa/tensorboardX/issues/567 since a non-scalar value was being passed in.
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=h1) Report
> Merging [#4883](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/9f5d5a531d769d07403f59661884e254f8420afe&el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `66.66%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/4883/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #4883   +/-   ##
=======================================
  Coverage   76.55%   76.56%           
=======================================
  Files         128      128           
  Lines       21502    21504    +2     
=======================================
+ Hits        16461    16464    +3     
+ Misses       5041     5040    -1     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/trainer.py](https://codecov.io/gh/huggingface/transformers/pull/4883/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `39.67% <66.66%> (+0.99%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4883/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl91dGlscy5weQ==) | `87.28% <0.00%> (-0.32%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=footer). Last update [9f5d5a5...9c9d9c3](https://codecov.io/gh/huggingface/transformers/pull/4883?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
<|||||>> Wouldn't the more robust fix be to change these values to scalars if they're not?
> 
> In the case were a string is passed (which seems to be your case), I think a warning would be better than a silently not registering anything. What do you think?

I agree that logging the non-scalar values would be an improvement, and I'll update this PR to that effect. I haven't characterized what the exact error is, so I'm not sure that we can even cast the troublesome values to scalars. Thank you very much for the good feedback here @LysandreJik.<|||||>@LysandreJik please feel free to suggest a different log level or log message from that in a33e28b