code: def test_batch_level_batch_indices():
      """Test that batch_indices are returned when `return_predictions=False`."""
      DummyPredictionWriter.write_on_batch_end = Mock()
  
      class CustomBoringModel(BoringModel):
          def on_predict_epoch_end(self, *args, **kwargs):
              assert self.trainer.predict_loop.epoch_batch_indices == [
                  []
              ]
  
      writer = DummyPredictionWriter("batch")
      model = CustomBoringModel()
      dataloader = DataLoader(RandomDataset(32, 64), batch_size=4)
      trainer = Trainer(limit_predict_batches=4, callbacks=writer)
      trainer.predict(
          model, dataloaders=dataloader, return_predictions=False
      )
  
      writer.write_on_batch_end.assert_has_calls(
          [
              call(trainer, model, ANY, [0, 1, 2, 3], ANY, 0, 0),
              call(trainer, model, ANY, [4, 5, 6, 7], ANY, 1, 0),
              call(trainer, model, ANY, [8, 9, 10, 11], ANY, 2, 0),
              call(trainer, model, ANY, [12, 13, 14, 15], ANY, 3, 0),
          ]
      )
  
file_path: pytorch-lightning/tests/tests_pytorch/callbacks/test_prediction_writer.py
imports: from unittest.mock import ANY, Mock, call
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import BasePredictionWriter
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch.utils.data import DataLoader
label_desc: Use image node_id 4 for calling a global function with example usage: test_batch_level_batch_indices() without return types