code: def test_multiprocess_sparse_emb_get_set_optm_state(num_workers):
      if (
          F.ctx().type == "cuda"
          and th.cuda.device_count() < num_workers
      ):
          pytest.skip("Not enough GPUs to run test.")
  
      worker_list = []
  
      num_embs, emb_dim = 1000, 8
      state_step = th.randint(1000, (num_embs,))
      state_mem = th.rand((num_embs, emb_dim))
      state_power = th.rand((num_embs, emb_dim))
  
      ctx = mp.get_context("spawn")
      for i in range(num_workers):
          p = ctx.Process(
              target=start_sparse_worker,
              args=(
                  i,
                  num_workers,
                  check_all_set_all_get_optm_state,
                  (state_step, state_mem, state_power),
              ),
          )
          p.start()
          worker_list.append(p)
  
      for p in worker_list:
          p.join()
      for p in worker_list:
          assert p.exitcode == 0
  
file_path: dgl/tests/python/pytorch/nn/test_sparse_emb.py
imports: import multiprocessing
  import os
  import unittest
  import backend
  import pytest
  import torch
  from dgl.nn import NodeEmbedding
  from dgl.optim import SparseAdam
label_desc: Use image node_id 6 for calling a global function with example usage: test_multiprocess_sparse_emb_get_set_optm_state(num_workers) without return types