code: def test_overfit_batch_limits_eval(stage, mode, overfit_batches):
      model = ClassificationModel()
      dm = ClassifDataModule()
      eval_loader = getattr(dm, f"{mode}_dataloader")()
      trainer = Trainer(overfit_batches=overfit_batches)
      model.trainer = trainer
      trainer.strategy.connect(model)
      trainer._data_connector.attach_datamodule(model, datamodule=dm)
  
      if stage == RunningStage.VALIDATING:
          trainer.fit_loop.epoch_loop.val_loop.setup_data()
          assert (
              trainer.num_val_batches[0] == overfit_batches
              if isinstance(overfit_batches, int)
              else len(dm.val_dataloader()) * overfit_batches
          )
      elif stage == RunningStage.TESTING:
          trainer.test_loop.setup_data()
          assert trainer.num_test_batches[0] == len(eval_loader)
          assert isinstance(
              trainer.test_dataloaders.sampler, SequentialSampler
          )
      elif stage == RunningStage.PREDICTING:
          trainer.predict_loop.setup_data()
          assert trainer.num_predict_batches[0] == len(eval_loader)
          assert isinstance(
              trainer.predict_dataloaders.sampler, SequentialSampler
          )
  
file_path: pytorch-lightning/tests/tests_pytorch/trainer/flags/test_overfit_batches.py
imports: import os
  from unittest import mock
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.trainer.states import RunningStage
  from torch.utils.data import DataLoader, DistributedSampler, RandomSampler, Sampler, SequentialSampler
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.datasets import SklearnDataset
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 3 for calling a global function with example usage: test_overfit_batch_limits_eval(stage, mode, overfit_batches) without return types