code: def assert_sparse_not_supported(optimizer_class, err_msg=None):
      param = torch.randn(1, 1).to_sparse().requires_grad_(True)
      grad = torch.randn(1, 1).to_sparse()
      param.grad = grad
      optimizer = optimizer_class([param])
      optimizer.zero_grad()
      with pytest.raises(RuntimeError) as ctx:
          optimizer.step()
  
      msg = err_msg or "does not support sparse gradients"
      assert msg in str(ctx.value)
  
file_path: pytorch-optimizer/tests/test_param_validation.py
imports: import pytest
  import torch
  import torch_optimizer
label_desc: Use image node_id 1 for calling a global function with example usage: assert_sparse_not_supported(optimizer_class, err_msg) without return types