def METHOD_NAME(test_case, placement, sbp, n):
    device = random_device()
    dim0 = random(high=4).to(int).value() * 8
    dim1 = random(high=4).to(int).value() * 8
    if n == 1:
        _size_n_t = _size_1_t
        MaxPoolNd = torch.nn.MaxPool1d
        max_unpool_nd = torch.nn.functional.max_unpool1d
        x = random_tensor(
            ndim=3, dim0=dim0, dim1=dim1, dim2=random(20, 31), requires_grad=False
        ).to_global(placement=placement, sbp=sbp)
    elif n == 2:
        _size_n_t = _size_2_t
        MaxPoolNd = torch.nn.MaxPool2d
        max_unpool_nd = torch.nn.functional.max_unpool2d
        x = random_tensor(
            ndim=4,
            dim0=dim0,
            dim1=dim1,
            dim2=random(10, 21),
            dim3=random(10, 21),
            requires_grad=False,
        ).to_global(placement=placement, sbp=sbp)
    elif n == 3:
        _size_n_t = _size_3_t
        MaxPoolNd = torch.nn.MaxPool3d
        max_unpool_nd = torch.nn.functional.max_unpool3d
        x = random_tensor(
            ndim=5,
            dim0=dim0,
            dim1=dim1,
            dim2=random(10, 14),
            dim3=random(10, 14),
            dim4=random(10, 14),
            requires_grad=False,
        ).to_global(placement=placement, sbp=sbp)
    kernel_size = random(4, 6).to(_size_n_t)
    stride = random(1, 3).to(_size_n_t)
    padding = random(1, 3).to(_size_n_t)
    m = MaxPoolNd(
        kernel_size=kernel_size, stride=stride, padding=padding, return_indices=True,
    )
    m.train(random())
    m.to(device)
    y = m(x)
    pooling_results = y[0]
    indices = y[1]
    pooling_results.requires_grad_()
    output_size = _get_valid_output_size(
        x.shape, pooling_results.shape, kernel_size, stride, padding
    )
    return max_unpool_nd(
        pooling_results,
        indices,
        kernel_size=kernel_size,
        stride=stride,
        padding=padding,
        output_size=output_size,
    )