def test_dataloaders_passed_to_fn(tmp_path, ckpt_path, n):
    """Verify that dataloaders can be passed."""
    train_dataloaders = DataLoader(RandomDataset(32, 64))
    if n == 1:
        model = BoringModel()
        eval_dataloaders = DataLoader(RandomDataset(32, 64))
    else:
        model = MultiEvalDataLoaderModel()
        eval_dataloaders = [DataLoader(RandomDataset(32, 64)), DataLoader(RandomDataset(32, 64))]

    # multiple val dataloaders passed to fit
    trainer = Trainer(default_root_dir=tmp_path, max_epochs=1, limit_val_batches=0.1, limit_train_batches=0.2)

    trainer.fit(model, train_dataloaders=train_dataloaders, val_dataloaders=eval_dataloaders)
    if n > 1:
        assert len(trainer.val_dataloaders) == n
    else:
        assert isinstance(trainer.val_dataloaders, DataLoader)

    if ckpt_path == "specific":
        ckpt_path = trainer.checkpoint_callback.best_model_path

    trainer.test(dataloaders=eval_dataloaders, ckpt_path=ckpt_path)
    if n > 1:
        assert len(trainer.test_dataloaders) == n
    else:
        assert isinstance(trainer.test_dataloaders, DataLoader)

    trainer.validate(dataloaders=eval_dataloaders, ckpt_path=ckpt_path)
    if n > 1:
        assert len(trainer.val_dataloaders) == n
    else:
        assert isinstance(trainer.val_dataloaders, DataLoader)
Verify that dataloaders can be passed.
tests/tests_pytorch/trainer/test_dataloaders.py