code: def test_deepspeed_save_checkpoint_client_state_separation(tmp_path):
      """Test that the DeepSpeed engine and optimizer get separated from the client state."""
      from deepspeed import DeepSpeedEngine
  
      strategy = DeepSpeedStrategy()
  
      # Model only
      model = Mock(spec=DeepSpeedEngine, optimizer=None)
      model.modules.return_value = [model]
      strategy.save_checkpoint(
          path=tmp_path, state={"model": model, "test": "data"}
      )
      # the client_state should not contain any deepspeed engine or deepspeed optimizer
      model.save_checkpoint.assert_called_with(
          tmp_path, client_state={"test": "data"}, tag="checkpoint"
      )
  
      # Model and optimizer
      optimizer = Mock()
      model = Mock(spec=DeepSpeedEngine, optimizer=optimizer)
      model.modules.return_value = [model]
      strategy.save_checkpoint(
          path=tmp_path,
          state={
              "model": model,
              "optimizer": optimizer,
              "test": "data",
          },
      )
      # the client_state should not contain any deepspeed engine or deepspeed optimizer
      model.save_checkpoint.assert_called_with(
          tmp_path, client_state={"test": "data"}, tag="checkpoint"
      )
  
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 13 for calling a global function with example usage: test_deepspeed_save_checkpoint_client_state_separation(tmp_path) without return types