Place inputs on device when include_inputs_for_metrics is True
# What does this PR do?

As pointed out in #18038, the inputs accumulated in the Trainer when `include_inputs_for_metrics=True` are not on the proper device, which then fails in distributed setups. This PR fixes that.

Fixes #18038
_The documentation is not available anymore as the PR was closed or merged._