def test_deepspeed_strategy_string(tmp_path, strategy):
    """Test to ensure that the strategy can be passed via string or instance, and parallel devices is correctly set."""

    trainer = Trainer(
        accelerator="cpu",
        fast_dev_run=True,
        default_root_dir=tmp_path,
        strategy=strategy if isinstance(strategy, str) else strategy(),
    )

    assert isinstance(trainer.strategy, DeepSpeedStrategy)
    assert trainer.strategy.parallel_devices == [torch.device("cpu")]
Test to ensure that the strategy can be passed via string or instance, and parallel devices is correctly set.
tests/tests_pytorch/strategies/test_deepspeed.py