def METHOD_NAME(
    self, inputs, momentum, nesterov, lr, data_strategy, gc, dc
):
    w, grad, m = inputs
    # Create an indexing array containing values which index into grad
    indices = data_strategy.draw(
        hu.tensor(
            max_dim=1,
            min_value=1,
            max_value=grad.shape[0],
            dtype=np.int64,
            elements=st.sampled_from(np.arange(grad.shape[0])),
        ),
    )
    # Verify that the generated indices are unique
    assume(
        np.array_equal(
            np.unique(indices.flatten()),
            np.sort(indices.flatten())))
    # Sparsify grad
    grad = grad[indices]
    # Make momentum >= 0
    m = np.abs(m)
    # Convert lr to a numpy array
    lr = np.asarray([lr], dtype=np.float32)
    op = core.CreateOperator(
        "SparseMomentumSGDUpdate", ["grad", "m", "lr", "param", "indices"],
        ["adjusted_grad", "m", "param"],
        momentum=momentum,
        nesterov=int(nesterov),
        device_option=gc
    )
    # Reference
    def momentum_sgd(grad, m, lr):
        lr = lr[0]
        if not nesterov:
            adjusted_gradient = lr * grad + momentum * m
            return (adjusted_gradient, adjusted_gradient)
        else:
            m_new = momentum * m + lr * grad
            return ((1 + momentum) * m_new - momentum * m, m_new)
    def sparse(grad, m, lr, param, i):
        grad_new, m_new = momentum_sgd(grad, m[i], lr)
        m[i] = m_new
        param[i] -= grad_new
        return (grad_new, m, param)
    self.assertReferenceChecks(
        gc,
        op,
        [grad, m, lr, w, indices],
        sparse)