def test_parse_args_parsing_gpus(mocker, cli_args, expected_gpu):
    """Test parsing of gpus and instantiation of Trainer."""
    mocker.patch("lightning_lite.utilities.device_parser._get_all_available_gpus", return_value=[0, 1])
    cli_args = cli_args.split(" ") if cli_args else []
    parser = LightningArgumentParser(add_help=False)
    parser.add_lightning_class_args(Trainer, None)
    with patch("sys.argv", ["any.py"] + cli_args):
        args = parser.parse_args()

    trainer = Trainer.from_argparse_args(args)
    assert trainer.device_ids == expected_gpu
Test parsing of gpus and instantiation of Trainer.
tests/core/utilities/test_lightning_cli.py