code: def validate_batch_sizes(my_batch_size: int) -> bool:
      """
      Validates all workers got the same batch size.
      """
  
      # skip batch size validation on XLA (as there's too much overhead
      # and data loader automatically drops the last batch in XLA mode)
      if is_xla():
          return True
  
      batch_size_tensor = torch.IntTensor([my_batch_size])
      if torch.cuda.is_available():
          batch_size_tensor = batch_size_tensor.cuda()
      all_batch_sizes = gather_tensor(batch_size_tensor)
      for j, oth_batch_size in enumerate(all_batch_sizes.data):
          if oth_batch_size != my_batch_size:
              logger.error(
                  f"Node {j} batch {oth_batch_size} != {my_batch_size}"
              )
              return False
      return True
  
file_path: mmf/mmf/trainers/core/evaluation_loop.py
imports: import logging
  from abc import ABC
  from typing import Any, Dict, Tuple, Type
  import torch
  import tqdm
  from mmf.common.meter import Meter
  from mmf.common.report import Report
  from mmf.common.sample import to_device
  from mmf.utils.distributed import gather_tensor, is_main, is_xla
label_desc: Use image node_id 1 for calling a global function with example usage: validate_batch_sizes(my_batch_size) and returns: True, True, False