def METHOD_NAME(test_case, ndim):
    device = random_device()
    minibatch = random(1, 5).to(int).value()
    channels = random(1, 5).to(int).value()
    padding = random(0, 3).to(int).value()
    dilation = random(1, 3).to(int).value()
    ceil_mode = random_bool().value()
    return_indices = random_bool().value()
    kernel_size = random(4, 6).to(int).value()
    stride = random(1, 3).to(int).value()
    x_shape = [minibatch, channels] + [
        random(10, 12).to(int).value() for i in range(ndim)
    ]
    m = eval(f"torch.nn.MaxPool{ndim}d")(
        kernel_size=kernel_size,
        stride=oneof(stride, nothing()),
        padding=oneof(padding, nothing()),
        dilation=oneof(dilation, nothing()),
        ceil_mode=ceil_mode,
        return_indices=return_indices,
    )
    m.to(device)
    x = random_tensor(len(x_shape), *x_shape).to(device)
    if return_indices:
        y_and_indices = m(x)
        y, indices = y_and_indices[0], y_and_indices[1]
    else:
        y = m(x)
    _check_equal(test_case, y.pytorch, y.oneflow, "y")
    init_grad_y = random_tensor(len(y.oneflow.shape), *y.oneflow.shape).to(device)
    init_grad_x = random_tensor(len(x.oneflow.shape), *x.oneflow.shape).to(device)
    dx = torch.autograd.grad(y, x, init_grad_y, True, True)[0]
    _check_equal(test_case, dx.pytorch, dx.oneflow, "dx")
    ddx_ddy = torch.autograd.grad(dx, [x, init_grad_y], init_grad_x, True, True)
    ddx, ddy = ddx_ddy[0], ddx_ddy[1]
    _check_equal(test_case, ddx.pytorch, ddx.oneflow, "ddx")
    _check_equal(test_case, ddy.pytorch, ddy.oneflow, "ddy")