code: def run_matmul_reference(
      x, w, mode, trans_a, trans_b, layout, block, dy
  ):
      x = sparse_to_dense(x, layout, block) if mode == "dsd" else x
      w = sparse_to_dense(w, layout, block) if mode == "dds" else w
      x.retain_grad()
      w.retain_grad()
      xx = x.transpose(2, 3) if trans_a else x
      ww = w.transpose(2, 3) if trans_b else w
      y = torch.matmul(xx, ww)
      y = sparse_to_dense(y, layout, block) if mode == "sdd" else y
      y.backward(dy)
      dx = x.grad.clone()
      dw = w.grad.clone()
      x.grad.zero_()
      w.grad.zero_()
      y = dense_to_sparse(y, layout, block) if mode == "sdd" else y
      dx = dense_to_sparse(dx, layout, block) if mode == "dsd" else dx
      dw = dense_to_sparse(dw, layout, block) if mode == "dds" else dw
      return y, dx, dw
  
file_path: DeepSpeed/tests/unit/ops/sparse_attention/test_sparse_attention.py
imports: import pytest
  import torch
  import deepspeed
  from deepspeed.accelerator import get_accelerator
  from deepspeed.ops.op_builder import SparseAttnBuilder
  from unit.util import skip_on_arch, skip_on_cuda
label_desc: Use image node_id 9 for calling a global function with example usage: run_matmul_reference(x, w, mode, trans_a, trans_b, layout, block, dy) and returns: y,  dx,  dw