code: def test_deepspeed_load_checkpoint_one_deepspeed_engine_required(
      _, tmp_path
  ):
      """Test that the DeepSpeed strategy can only load one DeepSpeedEngine per checkpoint."""
      from deepspeed import DeepSpeedEngine
  
      strategy = DeepSpeedStrategy()
  
      # missing DeepSpeedEngine
      with pytest.raises(
          ValueError,
          match="Could not find a DeepSpeed model in the provided checkpoint state.",
      ):
          strategy.load_checkpoint(
              path=tmp_path, state={"other": "data"}
          )
      with pytest.raises(
          ValueError,
          match="Could not find a DeepSpeed model in the provided checkpoint state.",
      ):
          strategy.load_checkpoint(
              path=tmp_path, state={"model": torch.nn.Linear(3, 3)}
          )
  
      # multiple DeepSpeedEngine
      model1 = Mock(spec=torch.nn.Module)
      model1.modules.return_value = [Mock(spec=DeepSpeedEngine)]
      model2 = Mock(spec=torch.nn.Module)
      model2.modules.return_value = [Mock(spec=DeepSpeedEngine)]
      with pytest.raises(
          ValueError,
          match="Found multiple DeepSpeed engine modules in the given state.",
      ):
          strategy.load_checkpoint(
              path=tmp_path, state={"model1": model1, "model2": model2}
          )
  
imports: import json
  from re import escape
  from unittest import mock
  from unittest.mock import ANY, Mock
  import pytest
  import torch
  from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator
  from lightning.fabric.strategies import DeepSpeedStrategy
  from torch.optim import Optimizer
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 17 for calling a global function with example usage: test_deepspeed_load_checkpoint_one_deepspeed_engine_required(_, tmp_path) without return types