mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Add check for if num_items_in_batch is not None (#35102)
This commit is contained in:
parent
203e978826
commit
a821b9c7ab
@ -5162,7 +5162,7 @@ class Trainer:
|
||||
except (TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
if self.args.average_tokens_across_devices:
|
||||
if self.args.average_tokens_across_devices and num_items_in_batch is not None:
|
||||
num_items_in_batch = self.accelerator.gather(num_items_in_batch).sum().item()
|
||||
|
||||
if torch.is_tensor(num_items_in_batch):
|
||||
|
Loading…
Reference in New Issue
Block a user