code: def test_deepspeed_config_zero_offload(deepspeed_zero_config):
      """Test the various ways optimizer-offloading can be configured."""
      # default config
      strategy = DeepSpeedStrategy(config=deepspeed_zero_config)
      assert (
          "offload_optimizer"
          not in strategy.config["zero_optimization"]
      )
  
      # default config
      strategy = DeepSpeedStrategy()
      assert (
          "offload_optimizer"
          not in strategy.config["zero_optimization"]
      )
  
      # default config with `offload_optimizer` argument override
      strategy = DeepSpeedStrategy(offload_optimizer=True)
      assert strategy.config["zero_optimization"][
          "offload_optimizer"
      ] == {
          "buffer_count": 4,
          "device": "cpu",
          "nvme_path": "/local_nvme",
          "pin_memory": False,
      }
  
      # externally configured through config
      deepspeed_zero_config["zero_optimization"][
          "offload_optimizer"
      ] = False
      strategy = DeepSpeedStrategy(config=deepspeed_zero_config)
      assert (
          strategy.config["zero_optimization"]["offload_optimizer"]
          is False
      )
  
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 8 for calling a global function with example usage: test_deepspeed_config_zero_offload(deepspeed_zero_config) without return types