code: def test_eval_limit_batches(mode, limit_batches):
      limit_eval_batches = f"limit_{mode}_batches"
      dl_hook = f"{mode}_dataloader"
      model = BoringModel()
      eval_loader = getattr(model, dl_hook)()
  
      trainer = Trainer(**{limit_eval_batches: limit_batches})
      model.trainer = trainer
      trainer.strategy.connect(model)
      trainer._data_connector.attach_dataloaders(model)
  
      if mode == "val":
          trainer.validate_loop.setup_data()
          trainer.state.fn = TrainerFn.VALIDATING
          loader_num_batches = trainer.num_val_batches
          dataloaders = trainer.val_dataloaders
      elif mode == "test":
          trainer.test_loop.setup_data()
          loader_num_batches = trainer.num_test_batches
          dataloaders = trainer.test_dataloaders
      elif mode == "predict":
          trainer.predict_loop.setup_data()
          loader_num_batches = trainer.num_predict_batches
          dataloaders = trainer.predict_dataloaders
  
      expected_batches = (
          int(limit_batches * len(eval_loader))
          if isinstance(limit_batches, float)
          else limit_batches
      )
      assert loader_num_batches[0] == expected_batches
      assert len(dataloaders) == len(eval_loader)
  
file_path: pytorch-lightning/tests/tests_pytorch/trainer/flags/test_limit_batches.py
imports: import logging
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.states import TrainerFn
label_desc: Use image node_id 2 for calling a global function with example usage: test_eval_limit_batches(mode, limit_batches) without return types