def METHOD_NAME(test_case):
    N = randint(1, 8)
    C = randint(1, 8)
    in_D = randint(1, 8)
    in_H = randint(1, 8)
    in_W = randint(1, 8)
    out_D = randint(1, 8)
    out_H = randint(1, 8)
    out_W = randint(1, 8)
    device = random_device()
    mode = choice(["bilinear", "nearest"])
    padding_mode = choice(["zeros", "border", "reflection"])
    align_corners = choice([True, False])
    theta = random_tensor(ndim=3, dim0=N, dim1=3, dim2=4).to(device)
    grid = torch.nn.functional.affine_grid(
        theta, (N, C, out_D, out_H, out_W), align_corners=align_corners
    ).to(device)
    input = random_tensor(
        ndim=5, dim0=N, dim1=C, dim2=in_D, dim3=in_H, dim4=in_W
    ).to(device)
    output = torch.nn.functional.grid_sample(
        input,
        grid,
        mode=mode,
        padding_mode=padding_mode,
        align_corners=align_corners,
    )
    return output