code: def test_error_on_dataloader_passed_to_fit(tmpdir):
      """Verify that when the auto-scale batch size feature raises an error if a train dataloader is passed to fit."""
  
      # only train passed to fit
      model = BatchSizeModel(batch_size=2)
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=1,
          limit_val_batches=0.1,
          limit_train_batches=0.2,
      )
      tuner = Tuner(trainer)
  
      with pytest.raises(
          MisconfigurationException,
          match="Batch size finder cannot be used with dataloaders passed directly",
      ):
          tuner.scale_batch_size(
              model,
              train_dataloaders=model.train_dataloader(),
              mode="power",
          )
  
imports: import logging
  import os
  from copy import deepcopy
  from unittest.mock import patch
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks.batch_size_finder import BatchSizeFinder
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel, RandomDataset
  from lightning.pytorch.tuner.tuning import Tuner
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning_utilities.test.warning import no_warning_call
  from torch.utils.data import DataLoader
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_error_on_dataloader_passed_to_fit(tmpdir) without return types