def METHOD_NAME(test_case, placement, ndim):
    x_shape = [8, 8] + [5] * ndim
    m = eval(f"torch.nn.AvgPool{ndim}d")(kernel_size=random(2, 5).to(int))
    x = random_tensor(len(x_shape), *x_shape).to_global(
        placement=placement, sbp=random_sbp(placement, max_dim=2)
    )
    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_global(
        placement=placement, sbp=random_sbp(placement, max_dim=2)
    )
    init_grad_x = random_tensor(len(x.oneflow.shape), *x.oneflow.shape).to_global(
        placement=placement, sbp=random_sbp(placement, max_dim=2)
    )
    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")