def METHOD_NAME(
    test_case,
    device,
    x_shape,
    learning_rate,
    momentum,
    dampening,
    nesterov,
    maximize,
    weight_decay,
    clip_grad_max_norm,
    clip_grad_norm_type,
    train_iters,
):
    random_grad_seq = []
    for _ in range(train_iters):
        random_grad_seq.append(np.random.uniform(size=x_shape).astype(np.float32))
    init_value = np.random.uniform(size=x_shape).astype(np.float32)
    class CustomModule(flow.nn.Module):
        def __init__(self):
            super().__init__()
            self.para0 = flow.nn.Parameter(
                flow.tensor(init_value, device=flow.device(device))
            )
        def forward(self, mask):
            return self.para0 * mask
    simp_module = CustomModule()
    simp_module.to(device)
    simp_module.train()
    sgd0 = flow.optim.SGD(
        [
            {
                "params": simp_module.parameters(),
                "lr": learning_rate,
                "weight_decay": weight_decay,
                "clip_grad_max_norm": clip_grad_max_norm,
                "clip_grad_norm_type": clip_grad_norm_type,
            }
        ],
        momentum=momentum,
        dampening=dampening,
        nesterov=nesterov,
        maximize=maximize,
    )
    class CustomSGDGraph(flow.nn.Graph):
        def __init__(self):
            super().__init__()
            self.m = simp_module
            self.add_optimizer(sgd0)
        def build(self, mask_tensor):
            loss = flow.sum(self.m(mask_tensor))
            loss.backward()
            return loss
    of_res_list = []
    sgd_graph = CustomSGDGraph()
    for i in range(train_iters):
        mask_tensor = flow.tensor(
            random_grad_seq[i], requires_grad=False, device=flow.device(device)
        )
        sgd_x = sgd_graph(mask_tensor)
        of_res_list.append(copy.copy(simp_module.para0.numpy()))
    np_res_list = []
    def train_by_numpy():
        x = init_value
        vt = np.zeros_like(x)
        def np_train_one_iter(grad):
            norm, grad = clip_grad_norm_np(
                grad, clip_grad_max_norm, clip_grad_norm_type
            )
            grad = grad + weight_decay * x
            if momentum > 0.0:
                next_momentum = momentum * vt + (1 - dampening) * grad
                v = next_momentum
                if nesterov:
                    grad += momentum * next_momentum
                else:
                    grad = next_momentum
                alpha = -learning_rate
                if maximize:
                    alpha = learning_rate
                next_model = x + alpha * grad
                param = next_model
            else:
                v = learning_rate * grad
                param = x - v
            return (param, v)
        for i in range(train_iters):
            (x, vt) = np_train_one_iter(random_grad_seq[i])
            np_res_list.append(x)
    train_by_numpy()
    for np_res, of_res in zip(np_res_list, of_res_list):
        test_case.assertTrue(np.allclose(np_res, of_res, rtol=0.001, atol=0.001))